Add new version in repository
This commit is contained in:
@@ -7,61 +7,61 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Models\Botanic\Family;
|
||||
use App\Exports\Botanic\FamiliesExport;
|
||||
|
||||
class Families
|
||||
{
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Family::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Family::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getOptions()
|
||||
{
|
||||
return Family::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Family::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Family::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Family::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Family::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Family::findOrFail($id);
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return Family::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Family::create($data);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Family::destroy($id);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new FamiliesExport, 'families.xlsx');
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Family::destroy($id);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new FamiliesExport, 'families.xlsx');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,60 +7,59 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Models\Botanic\Genre;
|
||||
use App\Exports\Botanic\GenresExport;
|
||||
|
||||
class Genres
|
||||
{
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Genre::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Genre::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getOptions()
|
||||
{
|
||||
return Genre::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Genre::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Genre::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Genre::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Genre::find($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Genre::find($id);
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return Genre::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Genre::create($data);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Genre::destroy($id);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Genre::destroy($id);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new GenresExport, 'genres.xlsx');
|
||||
}
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new GenresExport, 'genres.xlsx');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,13 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Exports\Botanic\SpeciesExport;
|
||||
|
||||
class Species
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Specie::orderBy('name');
|
||||
@@ -23,23 +22,33 @@ class Species
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Specie::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
return Specie::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Specie::orderBy('name','asc')->get();
|
||||
return Specie::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getDescription($id)
|
||||
{
|
||||
return self::get($id)->description;
|
||||
}
|
||||
|
||||
public static function getTags($id)
|
||||
{
|
||||
return self::get($id)->tags->toArray();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Specie::find($id);
|
||||
return Specie::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
@@ -50,7 +59,7 @@ class Species
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$id = $id ? $id : $data['id'];
|
||||
$model = self::get($id);
|
||||
$ret = $model->update($data);
|
||||
return $model;
|
||||
|
||||
@@ -13,106 +13,114 @@ use App\Exports\Botanic\VarietiesExport;
|
||||
|
||||
class Varieties
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return Variety::orderBy('name')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Variety::orderBy('name')->get()->pluck('name','id')->toArray();
|
||||
}
|
||||
public static function getOptionsWithSpecie()
|
||||
{
|
||||
$varieties = Variety::with('specie')->get();
|
||||
$data = [];
|
||||
foreach ($varieties as $variety) {
|
||||
$data[$variety->id] = (isset($variety->specie->name) ? $variety->specie->name . ' ' : '') . $variety->name;
|
||||
}
|
||||
asort($data, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getOptionsWithSpecie()
|
||||
{
|
||||
$varieties = Variety::with('specie')->get();
|
||||
$data = [];
|
||||
foreach ($varieties as $variety) {
|
||||
$data[$variety->id] = (isset($variety->specie->name) ? $variety->specie->name . ' ' : '') . $variety->name;
|
||||
}
|
||||
asort($data, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
return $data;
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Variety::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Variety::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function getDescription($id)
|
||||
{
|
||||
return self::get($id)->description;
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Variety::findOrFail($id);
|
||||
}
|
||||
public static function getTags($id)
|
||||
{
|
||||
return self::get($id)->tags;
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$variety = self::get($id);
|
||||
$data = $variety->toArray();
|
||||
$data['tags'] = self::getTagsByVariety($variety);
|
||||
return $data;
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Variety::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getTagsByVariety($variety)
|
||||
{
|
||||
return Tag::getTagsByModel($variety);
|
||||
}
|
||||
public static function getFull($id)
|
||||
{
|
||||
$variety = self::get($id);
|
||||
$data = $variety->toArray();
|
||||
$data['tags'] = self::getTagsByVariety($variety);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getTagsByVariety($variety)
|
||||
{
|
||||
return Tag::getTagsByModel($variety);
|
||||
}
|
||||
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = isset($data['images']) ? $data['images'] : false;
|
||||
$tags = isset($data['tags']) ? $data['tags'] : false;
|
||||
unset($data['images']);
|
||||
unset($data['tags']);
|
||||
$variety = self::store($data);
|
||||
self::storeImages($variety, $images);
|
||||
self::storeTags($variety, $tags);
|
||||
return $variety;
|
||||
}
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = isset($data['images']) ? $data['images'] : false;
|
||||
$tags = isset($data['tags']) ? $data['tags'] : false;
|
||||
unset($data['images']);
|
||||
unset($data['tags']);
|
||||
$variety = self::store($data);
|
||||
self::storeImages($variety, $images);
|
||||
self::storeTags($variety, $tags);
|
||||
return $variety;
|
||||
}
|
||||
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return isset($data['id']) ? self::update($data) : self::create($data);
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
return isset($data['id']) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Variety::create($data);
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return Variety::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$variety = self::get($id);
|
||||
$ret = $variety->update($data);
|
||||
return $variety;
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$variety = self::get($id);
|
||||
$ret = $variety->update($data);
|
||||
return $variety;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Variety::destroy($id);
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Variety::destroy($id);
|
||||
}
|
||||
|
||||
public static function storeTags($variety, $tags)
|
||||
{
|
||||
return Tag::storeTags($variety, $tags);
|
||||
}
|
||||
public static function storeTags($variety, $tags)
|
||||
{
|
||||
return Tag::storeTags($variety, $tags);
|
||||
}
|
||||
|
||||
public static function storeImages($variety, $files)
|
||||
{
|
||||
return Media::storeImages($variety, $files);
|
||||
}
|
||||
public static function storeImages($variety, $files)
|
||||
{
|
||||
return Media::storeImages($variety, $files);
|
||||
}
|
||||
|
||||
public static function getImages($id)
|
||||
{
|
||||
return Media::getImages(self::get($id));
|
||||
}
|
||||
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 VarietiesExport, 'varieties.xlsx');
|
||||
}
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
return Media::deleteImage(self::get($id), $index);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new VarietiesExport, 'varieties.xlsx');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user