fixes
This commit is contained in:
@@ -6,19 +6,15 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Repositories\Core\Tag;
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Exports\Botanic\SpeciesExport;
|
||||
|
||||
|
||||
class Species
|
||||
{
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Specie::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
@@ -45,11 +41,23 @@ class Species
|
||||
return Specie::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = $data['images'] ?? false;
|
||||
$tags = $data['tags'] ?? false;
|
||||
unset($data['images']);
|
||||
unset($data['tags']);
|
||||
$specie = self::store($data);
|
||||
self::storeImages($variety, $images);
|
||||
self::storeTags($specie, $tags);
|
||||
return $specie;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
$id = $data['id'] ?? false;
|
||||
$specie = $id ? self::update($data, $id) : self::create($data);
|
||||
return $specie;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
@@ -70,6 +78,26 @@ class Species
|
||||
return Specie::destroy($id);
|
||||
}
|
||||
|
||||
public static function storeTags($specie, $tags)
|
||||
{
|
||||
return Tag::storeTags($specie, $tags);
|
||||
}
|
||||
|
||||
public static function storeImages($specie, $files)
|
||||
{
|
||||
return Media::storeImages($specie, $files);
|
||||
}
|
||||
|
||||
public static function getImages($id)
|
||||
{
|
||||
return Media::getImages(self::get($id));
|
||||
}
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
return Media::deleteImage(self::get($id), $index);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new SpeciesExport, 'species.xlsx');
|
||||
|
||||
Reference in New Issue
Block a user