Add thumbs views in datatables with traits
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Repositories\Botanic;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
@@ -11,9 +9,11 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Repositories\Core\Tag;
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Exports\Botanic\SpeciesExport;
|
||||
use App\Traits\Repository\Imageable;
|
||||
|
||||
class Species
|
||||
{
|
||||
use Imageable;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
@@ -96,21 +96,6 @@ class Species
|
||||
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');
|
||||
|
||||
@@ -7,12 +7,14 @@ use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Repositories\Core\Tag;
|
||||
use App\Repositories\Core\Media;
|
||||
use App\Models\Botanic\Variety;
|
||||
use App\Exports\Botanic\VarietiesExport;
|
||||
use App\Traits\Repository\Imageable;
|
||||
|
||||
class Varieties
|
||||
{
|
||||
use Imageable;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Variety::orderBy('name')->get()->pluck('name', 'id')->toArray();
|
||||
@@ -102,21 +104,6 @@ class Varieties
|
||||
return Tag::storeTags($variety, $tags);
|
||||
}
|
||||
|
||||
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 deleteImage($id, $index)
|
||||
{
|
||||
return Media::deleteImage(self::get($id), $index);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new VarietiesExport, 'varieties.xlsx');
|
||||
|
||||
@@ -11,11 +11,14 @@ use App\Repositories\Botanic\Species;
|
||||
use App\Repositories\Botanic\Varieties;
|
||||
use App\Models\Shop\Article;
|
||||
|
||||
use App\Traits\Repository\Imageable;
|
||||
class Articles
|
||||
{
|
||||
use Imageable;
|
||||
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
$data = Article::where('name', 'LIKE', "%${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
|
||||
$data = Article::byAutocomplete($str)->orderBy('name')->limit(30)->get()->pluck('name', 'id');
|
||||
$export = [];
|
||||
foreach ($data as $key => $name) {
|
||||
$export[] = ['value' => $key, 'text' => $name];
|
||||
@@ -269,33 +272,4 @@ class Articles
|
||||
return Tag::storeTags($article, $tags);
|
||||
}
|
||||
|
||||
public static function storeImages($article, $files)
|
||||
{
|
||||
return Medias::storeImages($article, $files);
|
||||
}
|
||||
|
||||
public static function storeImage($article, $file)
|
||||
{
|
||||
return Medias::storeImage($article, $file);
|
||||
}
|
||||
|
||||
public static function getImages($id)
|
||||
{
|
||||
return Medias::getImages(self::get($id));
|
||||
}
|
||||
|
||||
public static function getThumbSrc($image)
|
||||
{
|
||||
return Medias::getThumbSrc($image);
|
||||
}
|
||||
|
||||
public static function getPreviewSrc($image)
|
||||
{
|
||||
return Medias::getPreviewSrc($image);
|
||||
}
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
return Medias::deleteImage(self::get($id), $index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user