[WIP] Add some features, categories, articles
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Shop\Family;
|
||||
use App\Models\Shop\Genre;
|
||||
use App\Models\Shop\Specie;
|
||||
use App\Models\Shop\Variety;
|
||||
use App\Models\Botanic\Family;
|
||||
use App\Models\Botanic\Genre;
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
|
||||
class migrate extends Command
|
||||
{
|
||||
@@ -41,6 +41,18 @@ class migrate extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$species = Specie::all();
|
||||
foreach ($species as $specie) {
|
||||
$specie->name = trim($specie->name);
|
||||
$specie->save();
|
||||
}
|
||||
|
||||
$varieties = Variety::all();
|
||||
foreach ($varieties as $variety) {
|
||||
$variety->name = trim($variety->name);
|
||||
$variety->save();
|
||||
}
|
||||
|
||||
/*
|
||||
$varieties = Variety::all();
|
||||
foreach ($varieties as $variety) {
|
||||
@@ -61,6 +73,7 @@ class migrate extends Command
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$species = Specie::all();
|
||||
foreach ($species as $specie) {
|
||||
$genre_name = $specie->genre;
|
||||
@@ -79,7 +92,7 @@ class migrate extends Command
|
||||
dump("Aucun genre");
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
$genres = Genre::all();
|
||||
foreach ($genres as $genre) {
|
||||
|
||||
30
app/DataTables/Shop/ArticleAttributeFamiliesDataTable.php
Normal file
30
app/DataTables/Shop/ArticleAttributeFamiliesDataTable.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\ArticleAttributeFamily;
|
||||
|
||||
class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticleAttributeFamilies';
|
||||
|
||||
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'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
30
app/DataTables/Shop/ArticleAttributeValuesDataTable.php
Normal file
30
app/DataTables/Shop/ArticleAttributeValuesDataTable.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\ArticleAttributeValue;
|
||||
|
||||
class ArticleAttributeValuesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticleAttributeValues';
|
||||
|
||||
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'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,6 @@ class ArticlesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
|
||||
@@ -21,6 +21,11 @@ class VarietyController extends Controller
|
||||
return Varieties::getDatatable($request->all());
|
||||
}
|
||||
|
||||
public function getOptionsWithSpecie()
|
||||
{
|
||||
return response()->json(Varieties::getOptionsWithSpecie());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Botanic.Admin.Varieties.create');
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Model\Shop\ArticleAttributeFamily;
|
||||
|
||||
class ArticleAttributeFamilyController extends Controller
|
||||
{
|
||||
public function index(ArticleAttributeFamiliesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.ArticleAttributeFamilies.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return ArticleAttributeFamilies::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Shop.Admin.ArticleAttributeFamilies.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = ArticleAttributeFamilies::store($request->all());
|
||||
return redirect()->route('Shop.Admin.ArticleAttributeFamilies.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = ArticleAttributeFamilies::get($id);
|
||||
return view('Shop.Admin.ArticleAttributeFamilies.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = ArticleAttributeFamilies::get($id);
|
||||
return view('Shop.Admin.ArticleAttributeFamilies.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return ArticleAttributeFamilies::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\Articles;
|
||||
use App\Repositories\Shop\ArticleFamilies;
|
||||
use App\Repositories\Shop\Categories;
|
||||
use App\DataTables\Shop\ArticlesDataTable;
|
||||
|
||||
class ArticleController extends Controller
|
||||
@@ -23,7 +25,9 @@ class ArticleController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$data = [];
|
||||
$data['categories'] = Articles::getOptions();
|
||||
$data['categories'] = Categories::getOptions();
|
||||
$data['families'] = ArticleFamilies::getOptions();
|
||||
$data['models'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
return view('Shop.Admin.Articles.create', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class Species
|
||||
public static function getOptions()
|
||||
{
|
||||
return Specie::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,22 @@ class Varieties
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
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[] = ['id' => $variety->id, 'text' => (isset($variety->specie->name) ? $variety->specie->name . ' ' : '') . $variety->name];
|
||||
}
|
||||
return collect($data)->sortBy('text')->values()->all();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Variety::orderBy('name','asc')->get();
|
||||
|
||||
@@ -15,6 +15,11 @@ class ArticleFamilies
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return ArticleFamily::get()->pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleFamily::orderBy('name','asc')->get();
|
||||
|
||||
Reference in New Issue
Block a user