[WIP] Working on uploader
This commit is contained in:
@@ -45,11 +45,20 @@ class Varieties
|
||||
return Variety::find($id);
|
||||
}
|
||||
|
||||
public static function getWithImages($id)
|
||||
{
|
||||
$variety = self::get($id);
|
||||
$variety->getMedia();
|
||||
// $variety = $variety->toArray();
|
||||
foreach ($variety->media as $key => $media) {
|
||||
$variety->media[$key]['url'] = $media->getUrl();
|
||||
}
|
||||
return $variety;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
return isset($data['id']) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
@@ -59,7 +68,9 @@ class Varieties
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Variety::find($id)->update($data);
|
||||
$variety = self::get($data['id']);
|
||||
$variety->update($data);
|
||||
return $variety;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
@@ -67,4 +78,13 @@ class Varieties
|
||||
return Variety::destroy($id);
|
||||
}
|
||||
|
||||
public static function storeImages($variety, $files)
|
||||
{
|
||||
if ($files) {
|
||||
foreach ($files as $file) {
|
||||
$variety->addMedia($file)->toMediaCollection('images');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,25 +8,25 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Article;
|
||||
use App\Models\Shop\ArticleComponent;
|
||||
|
||||
class Articles
|
||||
class ArticleComponents
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Article::orderBy('name');
|
||||
$model = ArticleComponent::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Article::orderBy('name','asc')->get();
|
||||
return ArticleComponent::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Article::find($id);
|
||||
return ArticleComponent::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
@@ -38,17 +38,17 @@ class Articles
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Article::create($data);
|
||||
return ArticleComponent::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Article::find($id)->update($data);
|
||||
return ArticleComponent::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Article::destroy($id);
|
||||
return ArticleComponent::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\TagGroup;
|
||||
@@ -24,6 +20,23 @@ class TagGroups
|
||||
return TagGroup::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getTreeTags()
|
||||
{
|
||||
$items = TagGroup::with('tags')->get();
|
||||
$tags = [];
|
||||
foreach ($items as $group) {
|
||||
$group_tags = [];
|
||||
foreach ($group->tags as $tag) {
|
||||
$group_tags[$tag->id] = $tag->name;
|
||||
}
|
||||
$tags[] = [
|
||||
'label' => $group->name,
|
||||
'options' => $group_tags,
|
||||
];
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return TagGroup::orderBy('name','asc')->get();
|
||||
|
||||
@@ -8,25 +8,30 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\TagGroup;
|
||||
use App\Models\Shop\Tag;
|
||||
|
||||
class TagGroups
|
||||
class Tags
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = TagGroup::orderBy('name');
|
||||
$model = Tag::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Tag::get()->pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return TagGroup::orderBy('name','asc')->get();
|
||||
return Tag::orderBy('order','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return TagGroup::find($id);
|
||||
return Tag::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
@@ -38,17 +43,17 @@ class TagGroups
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return TagGroup::create($data);
|
||||
return Tag::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return TagGroup::find($id)->update($data);
|
||||
return Tag::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return TagGroup::destroy($id);
|
||||
return Tag::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user