fixes
This commit is contained in:
@@ -16,13 +16,24 @@ class GenresDataTable extends DataTable
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('family_name', function(Genre $genre) {
|
||||
return $genre->family ? $genre->family->name : '';
|
||||
})
|
||||
->rawColumns(['genre_name', 'action'])
|
||||
;
|
||||
return Parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('family.name')->title('Famille'),
|
||||
Column::make('family.name')->data('family_name')->title('Famille'),
|
||||
Column::make('species_count')->title('Nb Espèces')->searchable(false)->addClass('text-right'),
|
||||
Column::make('varieties_count')->title('Nb Variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
|
||||
@@ -8,24 +8,36 @@ use App\Models\Botanic\Specie;
|
||||
|
||||
class SpeciesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'species';
|
||||
public $model_name = 'species';
|
||||
|
||||
public function query(Specie $model)
|
||||
{
|
||||
$model = $model::withCount('varieties')->with('genre');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Specie $model)
|
||||
{
|
||||
$model = $model::withCount('varieties')->with('genre');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('genre.name')->title('Genre'),
|
||||
Column::make('latin'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('genre_name', function(Specie $specie) {
|
||||
return $specie->genre ? $specie->genre->name : '';
|
||||
})
|
||||
->rawColumns(['genre_name', 'action'])
|
||||
;
|
||||
return Parent::modifier($datatables);
|
||||
}
|
||||
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('genre.name')->data('genre_name')->title('Genre'),
|
||||
Column::make('latin'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,9 +13,16 @@ class PackagesDataTable extends DataTable
|
||||
public function query(Package $model)
|
||||
{
|
||||
$model = $model::with(['article_family'])->select('shop_packages.*');
|
||||
$model = self::filterByFamily($model);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
public static function filterByFamily($model, $family_id = false)
|
||||
{
|
||||
$family_id = $family_id ? $family_id : self::isFilteredByField('family_id');
|
||||
return $family_id ? $model->byArticleFamily($family_id) : $model;
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -14,68 +14,65 @@ use App\Models\Shop\Variety;
|
||||
|
||||
class VarietyController extends Controller
|
||||
{
|
||||
public function index(VarietiesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Botanic.Admin.Varieties.list');
|
||||
}
|
||||
public function index(VarietiesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Botanic.Admin.Varieties.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return Varieties::getDatatable($request->all());
|
||||
}
|
||||
public function getOptionsWithSpecie()
|
||||
{
|
||||
return response()->json(Varieties::getOptionsWithSpecie());
|
||||
}
|
||||
|
||||
public function getOptionsWithSpecie()
|
||||
{
|
||||
return response()->json(Varieties::getOptionsWithSpecie());
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Botanic.Admin.Varieties.create', $data);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Botanic.Admin.Varieties.create', $data);
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
Varieties::storeFull($data);
|
||||
return redirect()->route('Botanic.Admin.Varieties.index');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
Varieties::storeFull($data);
|
||||
return redirect()->route('Botanic.Admin.Varieties.index');
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
return view('Botanic.Admin.Varieties.view', Varieties::get($id));
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return view('Botanic.Admin.Varieties.view', Varieties::get($id));
|
||||
}
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Varieties::getFull($id);
|
||||
$data['species'] = Species::getOptions();
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Botanic.Admin.Varieties.edit', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Varieties::getFull($id);
|
||||
$data['species'] = Species::getOptions();
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Botanic.Admin.Varieties.edit', $data);
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
return Varieties::destroy($id);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return Varieties::destroy($id);
|
||||
}
|
||||
public function getImages(Request $request, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $request->input('id');
|
||||
$data['images'] = Varieties::getImages($id);
|
||||
return view('components.uploader.mini-gallery-items', $data);
|
||||
}
|
||||
|
||||
public function getImages(Request $request, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $request->input('id');
|
||||
$data['images'] = Varieties::getImages($id);
|
||||
return view('components.uploader.mini-gallery-items', $data);
|
||||
}
|
||||
public function deleteImage(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$index = $request->input('index');
|
||||
return Varieties::deleteImage($id, $index);
|
||||
}
|
||||
|
||||
public function exportExcel()
|
||||
{
|
||||
return Varieties::exportExcel();
|
||||
}
|
||||
|
||||
public function deleteImage(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$index = $request->input('index');
|
||||
return Varieties::deleteImage($id, $index);
|
||||
}
|
||||
|
||||
public function exportExcel()
|
||||
{
|
||||
return Varieties::exportExcel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ class ArticleController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
dump($data);
|
||||
exit;
|
||||
// dump($data);
|
||||
// exit;
|
||||
Articles::storeFull($data);
|
||||
return redirect()->route('Shop.Admin.Articles.index');
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
use App\Repositories\Shop\ArticleFamilies;
|
||||
use App\DataTables\Shop\TagGroupsDataTable;
|
||||
|
||||
class TagGroupController extends Controller
|
||||
@@ -40,6 +41,7 @@ class TagGroupController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$data = TagGroups::get($id);
|
||||
$data['article_families'] = ArticleFamilies::getOptions();
|
||||
return view('Shop.Admin.TagGroups.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,20 +10,18 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
|
||||
class Variety extends Model implements HasMedia
|
||||
{
|
||||
use HasMediaTrait;
|
||||
use EloquentJoin;
|
||||
use Taggable;
|
||||
use EloquentJoin, HasMediaTrait, Taggable;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'botanic_varieties';
|
||||
|
||||
public function Specie()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Botanic\Specie');
|
||||
}
|
||||
{
|
||||
return $this->belongsTo('App\Models\Botanic\Specie');
|
||||
}
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphMany('App\Models\Shop\Article','product');
|
||||
}
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphMany('App\Models\Shop\Article','product');
|
||||
}
|
||||
}
|
||||
@@ -11,65 +11,60 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
|
||||
class Article extends Model implements HasMedia
|
||||
{
|
||||
use Categorizable, Taggable, HasMediaTrait, EloquentJoin;
|
||||
use Categorizable, EloquentJoin, HasMediaTrait, Taggable;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_articles';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_articles';
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
|
||||
public function attributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
public function images()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function images()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||
}
|
||||
public function image()
|
||||
{
|
||||
return $this->hasOne('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function image()
|
||||
{
|
||||
return $this->hasOne('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||
}
|
||||
public function inventories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Inventory');
|
||||
}
|
||||
|
||||
public function inventories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Inventory');
|
||||
}
|
||||
public function invoiceItems()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
|
||||
public function invoiceItems()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
public function product()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.id',$id);
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.id',$id);
|
||||
}
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.article_family_id',$id);
|
||||
}
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.article_family_id',$id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -58,7 +58,8 @@ class Varieties
|
||||
|
||||
public static function getTagsByVariety($variety)
|
||||
{
|
||||
return $variety->tags->pluck('id')->toArray();
|
||||
$tags = $variety->tags;
|
||||
return $tags ? $tags->pluck('id')->toArray() : null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class Articles
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$article = self::get($id);
|
||||
$article = Article::with('product')->findOrFail($id);
|
||||
$data = $article->toArray();
|
||||
$data['categories'] = self::getCategoriesByArticle($article);
|
||||
$data['tags'] = self::getTagsByArticle($article);
|
||||
@@ -177,6 +177,9 @@ class Articles
|
||||
|
||||
public static function getThumbSrc($image)
|
||||
{
|
||||
if (!$image) {
|
||||
return null;
|
||||
}
|
||||
$id = $image['id'];
|
||||
$images = json_decode($image['responsive_images'], true);
|
||||
$urls = $images['medialibrary_original']['urls'];
|
||||
|
||||
Reference in New Issue
Block a user