[WIP] Add some classes
This commit is contained in:
@@ -12,7 +12,7 @@ class FamiliesDataTable extends DataTable
|
||||
|
||||
public function query(Family $model)
|
||||
{
|
||||
$model = $model::withCount('genres');
|
||||
$model = $model::withCount(['genres','species','varieties']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ class FamiliesDataTable extends DataTable
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('genres_count')->title('Nb genres'),
|
||||
Column::make('genres_count')->title('Nb genres')->searchable(false),
|
||||
Column::make('species_count')->title('Nb espèces')->searchable(false),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
|
||||
@@ -12,7 +12,7 @@ class GenresDataTable extends DataTable
|
||||
|
||||
public function query(Genre $model)
|
||||
{
|
||||
$model = $model::with('family')->withCount('species');
|
||||
$model = $model::with('family')->withCount('species')->withCount('varieties');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class GenresDataTable extends DataTable
|
||||
Column::make('latin'),
|
||||
Column::make('family.name'),
|
||||
Column::make('species_count')->title('Nb Espèces')->searchable(false),
|
||||
Column::make('varieties_count')->title('Nb Variétés')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
|
||||
30
app/DataTables/Shop/ArticleFamiliesDataTable.php
Normal file
30
app/DataTables/Shop/ArticleFamiliesDataTable.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\DataTables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\ArticleFamily;
|
||||
|
||||
class ArticleFamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticleFamilies';
|
||||
|
||||
public function query(ArticleFamily $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,84 +5,55 @@ namespace App\Http\Controllers\Shop\Admin;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\Shop\Article;
|
||||
use App\Repositories\Shop\Articles;
|
||||
use App\DataTables\Shop\ArticlesDataTable;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(ArticlesDataTable $dataTable)
|
||||
{
|
||||
//
|
||||
return $dataTable->render('Shop.Admin.Articles.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return Articles::getTables($request->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
$data = [];
|
||||
$data['categories'] = Articles::getOptions();
|
||||
return view('Shop.Admin.Articles.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$ret = Articles::store($request->all());
|
||||
return redirect()->route('Shop.Admin.Articles.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Article $Article
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Article $Article)
|
||||
public function show($id)
|
||||
{
|
||||
$data = Articles::get($id);
|
||||
return view('Shop.Admin.Articles.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Articles::get($id);
|
||||
$data['categories'] = Articles::getOptions();
|
||||
return view('Shop.Admin.Articles.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Article $Article
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Article $Article)
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
return Articles::destroy($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Article $Article
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Article $Article)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Article $Article
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Article $Article)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
56
app/Http/Controllers/Shop/Admin/ArticleFamilyController.php
Normal file
56
app/Http/Controllers/Shop/Admin/ArticleFamilyController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\ArticleFamilies;
|
||||
use App\DataTables\Shop\ArticleFamiliesDataTable;
|
||||
|
||||
class ArticleFamilyController extends Controller
|
||||
{
|
||||
public function index(ArticleFamiliesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.ArticleFamilies.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return ArticleFamilies::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Shop.Admin.ArticleFamilies.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = ArticleFamilies::store($request->all());
|
||||
return redirect()->route('Shop.Admin.ArticleFamilies.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = ArticleFamilies::get($id);
|
||||
return view('Shop.Admin.ArticleFamilies.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = ArticleFamilies::get($id);
|
||||
return view('Shop.Admin.ArticleFamilies.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return ArticleFamilies::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,78 +14,44 @@ class CategoryController extends Controller
|
||||
public function index(CategoriesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.Categories.list');
|
||||
}
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return Categories::getTables($request->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data = [];
|
||||
$data['categories'] = Categories::getOptions();
|
||||
return view('Shop.Admin.Categories.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = Categories::store($request->all());
|
||||
return redirect()->route('Shop.Admin.Categories.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data = Categories::get($id);
|
||||
return view('Shop.Admin.Categories.view', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Categories::get($id);
|
||||
$data['categories'] = Categories::getOptions();
|
||||
return view('Shop.Admin.Categories.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
return Categories::destroy($id);
|
||||
|
||||
@@ -27,4 +27,9 @@ class CategoryController extends Controller
|
||||
return view('Shop.Categories.view', $data);
|
||||
}
|
||||
|
||||
public function getTree()
|
||||
{
|
||||
return response()->json(Categories::getTree());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,19 +9,19 @@ class Botanic
|
||||
{
|
||||
public function make(Builder $menu)
|
||||
{
|
||||
$menu->add('Botanique', [ 'permission' => 'backend', 'icon' => 'leaf' ])
|
||||
$menu->add('Botanique', [ 'permission' => 'backend_access', 'icon' => 'leaf' ])
|
||||
->id('botanic')
|
||||
->activeIfRoute('botanic')
|
||||
->order(2);
|
||||
|
||||
$menu->addTo('botanic', 'Familles', [ 'route' => 'Botanic.Admin.Families.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Botanic.Admin.Families.index'])->order(1);
|
||||
$menu->addTo('botanic', 'Genres', [ 'route' => 'Botanic.Admin.Genres.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Botanic.Admin.Genres.index'])->order(2);
|
||||
$menu->addTo('botanic', 'Espèces', [ 'route' => 'Botanic.Admin.Species.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Botanic.Admin.Species.index'])->order(3);
|
||||
$menu->addTo('botanic', 'Variétés', [ 'route' => 'Botanic.Admin.Varieties.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Botanic.Admin.Varieties.index'])->order(4);
|
||||
$menu->addTo('botanic', 'Familles', [ 'route' => 'Botanic.Admin.Families.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Botanic.Admin.Families.*'])->order(1);
|
||||
$menu->addTo('botanic', 'Genres', [ 'route' => 'Botanic.Admin.Genres.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Botanic.Admin.Genres.*'])->order(2);
|
||||
$menu->addTo('botanic', 'Espèces', [ 'route' => 'Botanic.Admin.Species.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Botanic.Admin.Species.*'])->order(3);
|
||||
$menu->addTo('botanic', 'Variétés', [ 'route' => 'Botanic.Admin.Varieties.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Botanic.Admin.Varieties.*'])->order(4);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,19 +9,23 @@ class Shop
|
||||
{
|
||||
public function make(Builder $menu)
|
||||
{
|
||||
$menu->add('Commerce', [ 'permission' => 'backend', 'icon' => 'shopping-basket' ])
|
||||
$menu->add('Commerce', [ 'permission' => 'backend_access', 'icon' => 'shopping-basket' ])
|
||||
->id('shop')
|
||||
->activeIfRoute('shop')
|
||||
->order(1);
|
||||
|
||||
$menu->addTo('shop', 'Categories', [ 'route' => 'Shop.Admin.Categories.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Categories.index'])->order(1);
|
||||
$menu->addTo('shop', 'Articles', [ 'route' => 'Shop.Admin.Articles.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Articles.index'])->order(2);
|
||||
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Orders.index'])->order(3);
|
||||
$menu->addTo('shop', 'Factures', [ 'route' => 'Shop.Admin.Invoices.index', 'permission' => 'backend' ])
|
||||
->activeIfRoute(['Shop.Admin.Invoices.index'])->order(4);
|
||||
$menu->addTo('shop', 'Categories', [ 'route' => 'Shop.Admin.Categories.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Categories.*'])->order(1);
|
||||
|
||||
$menu->addTo('shop', 'Articles', [ 'route' => 'Shop.Admin.Articles.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Articles.*'])->order(2);
|
||||
$menu->addTo('shop', 'Familles d\'articles', [ 'route' => 'Shop.Admin.ArticleFamilies.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleFamilies.*'])->order(3);
|
||||
|
||||
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Orders.*'])->order(4);
|
||||
$menu->addTo('shop', 'Factures', [ 'route' => 'Shop.Admin.Invoices.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Invoices.*'])->order(5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models\Botanic;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Family extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'botanic_families';
|
||||
|
||||
@@ -14,6 +17,16 @@ class Family extends Model
|
||||
return $this->hasMany('App\Models\Botanic\Genre');
|
||||
}
|
||||
|
||||
public function species()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Botanic\Specie', 'App\Models\Botanic\Genre');
|
||||
}
|
||||
|
||||
public function varieties()
|
||||
{
|
||||
return $this->hasManyDeep('App\Models\Botanic\Variety', ['App\Models\Botanic\Genre', 'App\Models\Botanic\Specie']);
|
||||
}
|
||||
|
||||
public function scopeByName($query,$name)
|
||||
{
|
||||
return $query->where('name', $name);
|
||||
|
||||
@@ -19,6 +19,11 @@ class Genre extends Model
|
||||
return $this->hasMany('App\Models\Botanic\Specie');
|
||||
}
|
||||
|
||||
public function varieties()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Botanic\Variety', 'App\Models\Botanic\Specie');
|
||||
}
|
||||
|
||||
public function scopeByName($query,$name)
|
||||
{
|
||||
return $query->where('name', $name);
|
||||
|
||||
@@ -44,4 +44,10 @@ class Article extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
|
||||
public function Product()
|
||||
{
|
||||
return $this->belongsTo($this->model, 'model_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class ArticleAttribute extends Model
|
||||
class ArticleAttribute extends Pivot
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function Attribute()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
}
|
||||
55
app/Repositories/Core/Tags.php
Normal file
55
app/Repositories/Core/Tags.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Botanic\Family;
|
||||
|
||||
class Tags
|
||||
{
|
||||
|
||||
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 getAll()
|
||||
{
|
||||
return Family::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Family::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Family::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Family::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Family::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
50
app/Repositories/Shop/ArticleAttributeFamilies.php
Normal file
50
app/Repositories/Shop/ArticleAttributeFamilies.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\ArticleAttributeFamily;
|
||||
|
||||
class ArticleAttributeFamilies
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleAttributeFamily::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleAttributeFamily::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleAttributeFamily::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticleAttributeFamily::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return ArticleAttributeFamily::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticleAttributeFamily::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
50
app/Repositories/Shop/ArticleAttributeValues.php
Normal file
50
app/Repositories/Shop/ArticleAttributeValues.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\ArticleAttributeValue;
|
||||
|
||||
class ArticleAttributeValues
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleAttributeValue::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleAttributeValue::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleAttributeValue::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticleAttributeValue::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return ArticleAttributeValue::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticleAttributeValue::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
50
app/Repositories/Shop/ArticleAttributes.php
Normal file
50
app/Repositories/Shop/ArticleAttributes.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\ArticleAttribute;
|
||||
|
||||
class ArticleAttributes
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleAttribute::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleAttribute::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleAttribute::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticleAttribute::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return ArticleAttribute::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticleAttribute::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
50
app/Repositories/Shop/ArticleCategories.php
Normal file
50
app/Repositories/Shop/ArticleCategories.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\ArticleCategory;
|
||||
|
||||
class ArticleCategories
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleCategory::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleCategory::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleCategory::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticleCategory::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return ArticleCategory::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticleCategory::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
54
app/Repositories/Shop/ArticleComponents.php
Normal file
54
app/Repositories/Shop/ArticleComponents.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
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\Article;
|
||||
|
||||
class Articles
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Article::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Article::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Article::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Article::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Article::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Article::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
50
app/Repositories/Shop/ArticleFamilies.php
Normal file
50
app/Repositories/Shop/ArticleFamilies.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\ArticleFamily;
|
||||
|
||||
class ArticleFamilies
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleFamily::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleFamily::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleFamily::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticleFamily::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return ArticleFamily::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticleFamily::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
54
app/Repositories/Shop/ArticlePrices.php
Normal file
54
app/Repositories/Shop/ArticlePrices.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
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\ArticlePrice;
|
||||
|
||||
class ArticlePrices
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePrice::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePrice::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePrice::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticlePrice::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return ArticlePrice::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePrice::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,16 @@ class Categories
|
||||
return Category::find($id);
|
||||
}
|
||||
|
||||
public static function getTree()
|
||||
{
|
||||
return CategoryTrees::getTree();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Category::get()->pluck('name','category_id')->toArray();
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
@@ -35,9 +45,7 @@ class Categories
|
||||
{
|
||||
$node = CategoryTrees::create($data);
|
||||
$data['category_id'] = $node->id;
|
||||
dump($data);
|
||||
$category = Category::create($data);
|
||||
exit;
|
||||
return $category;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,29 @@ use App\Models\Shop\Category;
|
||||
|
||||
class CategoryTrees
|
||||
{
|
||||
public static function getTree()
|
||||
{
|
||||
$categories = app('rinvex.categories.category')->get()->toTree()->toArray();
|
||||
return self::getChildren($categories[0]['children']);
|
||||
}
|
||||
|
||||
public static function getChildren($data)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($data as $item)
|
||||
{
|
||||
$leaf = [];
|
||||
$leaf['name'] = $item['name'];
|
||||
$leaf['id'] = $item['id'];
|
||||
$children = (isset($item['children'])) ? self::getChildren($item['children']) : false;
|
||||
if ($children) {
|
||||
$leaf['children'] = $children;
|
||||
}
|
||||
$tree[] = $leaf;
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user