Mise à jour
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Botanic\Family;
|
||||
use App\Models\Botanic\Genre;
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
|
||||
class checkdb extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'checkdb';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Consistency from old version';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$varieties = Variety::whereNull('specie_id')->get();
|
||||
foreach ($varieties as $variety) {
|
||||
$specie_name = trim($variety->specie_name);
|
||||
/*
|
||||
$specie = Specie::firstOrCreate(['name' => $specie_name]);
|
||||
if ($specie) {
|
||||
$variety->specie_id = $specie->id;
|
||||
$variety->save();
|
||||
}
|
||||
*/
|
||||
dump($specie_name);
|
||||
}
|
||||
/*
|
||||
|
||||
$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) {
|
||||
$specie_name = $variety->specie;
|
||||
dump($specie_name);
|
||||
if (!empty($specie_name)) {
|
||||
$specie = Specie::byName($specie_name)->first();
|
||||
if (isset($specie->name))
|
||||
{
|
||||
dump($specie->name);
|
||||
$variety->specie_id = $specie->id;
|
||||
$variety->save();
|
||||
} else {
|
||||
dump("non trouvé");
|
||||
}
|
||||
} else {
|
||||
dump("Aucune espèce");
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$species = Specie::all();
|
||||
foreach ($species as $specie) {
|
||||
$genre_name = $specie->genre;
|
||||
dump($genre_name);
|
||||
if (!empty($genre_name)) {
|
||||
$genre = Genre::byName($genre_name)->first();
|
||||
if (isset($genre->name))
|
||||
{
|
||||
dump($genre->name);
|
||||
$specie->genre_id = $genre->id;
|
||||
$specie->save();
|
||||
} else {
|
||||
dump("non trouvé");
|
||||
}
|
||||
} else {
|
||||
dump("Aucun genre");
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$genres = Genre::all();
|
||||
foreach ($genres as $genre) {
|
||||
$family_name = $genre->family;
|
||||
dump($family_name);
|
||||
if (!empty($family_name)) {
|
||||
$family = Family::byName($family_name)->first();
|
||||
if (isset($family->name))
|
||||
{
|
||||
dump($family->name);
|
||||
$genre->family_id = $family->id;
|
||||
$genre->save();
|
||||
} else {
|
||||
dump("non trouvé");
|
||||
}
|
||||
} else {
|
||||
dump("Aucune famille");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Botanic\Family;
|
||||
use App\Models\Botanic\Genre;
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
|
||||
class migrate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'create_relation';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migration from old version';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
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) {
|
||||
$specie_name = $variety->specie;
|
||||
dump($specie_name);
|
||||
if (!empty($specie_name)) {
|
||||
$specie = Specie::byName($specie_name)->first();
|
||||
if (isset($specie->name))
|
||||
{
|
||||
dump($specie->name);
|
||||
$variety->specie_id = $specie->id;
|
||||
$variety->save();
|
||||
} else {
|
||||
dump("non trouvé");
|
||||
}
|
||||
} else {
|
||||
dump("Aucune espèce");
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$species = Specie::all();
|
||||
foreach ($species as $specie) {
|
||||
$genre_name = $specie->genre;
|
||||
dump($genre_name);
|
||||
if (!empty($genre_name)) {
|
||||
$genre = Genre::byName($genre_name)->first();
|
||||
if (isset($genre->name))
|
||||
{
|
||||
dump($genre->name);
|
||||
$specie->genre_id = $genre->id;
|
||||
$specie->save();
|
||||
} else {
|
||||
dump("non trouvé");
|
||||
}
|
||||
} else {
|
||||
dump("Aucun genre");
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$genres = Genre::all();
|
||||
foreach ($genres as $genre) {
|
||||
$family_name = $genre->family;
|
||||
dump($family_name);
|
||||
if (!empty($family_name)) {
|
||||
$family = Family::byName($family_name)->first();
|
||||
if (isset($family->name))
|
||||
{
|
||||
dump($family->name);
|
||||
$genre->family_id = $family->id;
|
||||
$genre->save();
|
||||
} else {
|
||||
dump("non trouvé");
|
||||
}
|
||||
} else {
|
||||
dump("Aucune famille");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\ArticleAttributeFamilies;
|
||||
use App\DataTables\Shop\ArticleAttributeFamiliesDataTable;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
56
app/Http/Controllers/Shop/Admin/PriceFamilyController.php
Normal file
56
app/Http/Controllers/Shop/Admin/PriceFamilyController.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\PriceFamilies;
|
||||
use App\DataTables\Shop\PriceFamiliesDataTable;
|
||||
|
||||
class PriceFamilyController extends Controller
|
||||
{
|
||||
public function index(PriceFamiliesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.PriceFamilies.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return PriceFamilies::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Shop.Admin.PriceFamilies.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = PriceFamilies::store($request->all());
|
||||
return redirect()->route('Shop.Admin.PriceFamilies.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = PriceFamilies::get($id);
|
||||
return view('Shop.Admin.PriceFamilies.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = PriceFamilies::get($id);
|
||||
return view('Shop.Admin.PriceFamilies.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return PriceFamilies::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\PriceFamilies;
|
||||
use App\Repositories\Shop\PriceFamilyValues;
|
||||
use App\DataTables\Shop\PriceFamilyValuesDataTable;
|
||||
|
||||
class PriceFamilyValueController extends Controller
|
||||
{
|
||||
public function index(PriceFamilyValuesDataTable $dataTable)
|
||||
{
|
||||
$data['families'] = PriceFamilies::getOptions();
|
||||
return $dataTable->render('Shop.Admin.PriceFamilyValues.list', $data);
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return PriceFamilyValues::getTables($request->all());
|
||||
}
|
||||
|
||||
public function getOptionsByFamily(Request $request)
|
||||
{
|
||||
$id = $request->input('family_id');
|
||||
return response()->json(PriceFamilyValues::getSelectByFamily($id));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Shop.Admin.PriceFamilyValues.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = PriceFamilyValues::store($request->all());
|
||||
return redirect()->route('Shop.Admin.PriceFamilyValues.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = PriceFamilyValues::get($id);
|
||||
return view('Shop.Admin.PriceFamilyValues.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = PriceFamilyValues::get($id);
|
||||
return view('Shop.Admin.PriceFamilyValues.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return PriceFamilyValues::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,49 +9,52 @@ use App\Models\Shop\PriceGeneric;
|
||||
use App\Repositories\Shop\PriceGenerics;
|
||||
use App\Repositories\Shop\PriceGenericCategories;
|
||||
use App\Repositories\Shop\Taxes;
|
||||
use App\Repositories\Shop\Unities;
|
||||
use App\DataTables\Shop\PriceGenericsDataTable;
|
||||
|
||||
class PriceGenericController extends Controller
|
||||
{
|
||||
public function index(PriceGenericsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.PriceGenerics.list');
|
||||
}
|
||||
public function index(PriceGenericsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.PriceGenerics.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return PriceGenerics::getTables($request->all());
|
||||
}
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return PriceGenerics::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceGenericCategories::getOptions();
|
||||
return view('Shop.Admin.PriceGenerics.create',$data);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
$data['unities'] = Unities::getOptions();
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceGenericCategories::getOptions();
|
||||
return view('Shop.Admin.PriceGenerics.create',$data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['generic'] = PriceGenerics::get($id)->toArray();
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceGenericCategories::getOptions();
|
||||
return view('Shop.Admin.PriceGenerics.edit', $data);
|
||||
}
|
||||
public function edit($id)
|
||||
{
|
||||
$data['generic'] = PriceGenerics::get($id)->toArray();
|
||||
$data['unities'] = Unities::getOptions();
|
||||
$data['taxes'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceGenericCategories::getOptions();
|
||||
return view('Shop.Admin.PriceGenerics.edit', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = PriceGenerics::store($request->all());
|
||||
return redirect()->route('Shop.Admin.PriceGenerics.index');
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = PriceGenerics::store($request->all());
|
||||
return redirect()->route('Shop.Admin.PriceGenerics.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = PriceGenerics::get($id);
|
||||
return view('Shop.Admin.PriceGenerics.view', $data);
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
$data = PriceGenerics::get($id);
|
||||
return view('Shop.Admin.PriceGenerics.view', $data);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return PriceGenerics::destroy($id);
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
return PriceGenerics::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
64
app/Http/Controllers/Shop/Admin/UnityController.php
Normal file
64
app/Http/Controllers/Shop/Admin/UnityController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\PriceFamilies;
|
||||
use App\Repositories\Shop\UnityValues;
|
||||
use App\DataTables\Shop\UnityValuesDataTable;
|
||||
|
||||
class UnityValueController extends Controller
|
||||
{
|
||||
public function index(UnityValuesDataTable $dataTable)
|
||||
{
|
||||
$data['families'] = PriceFamilies::getOptions();
|
||||
return $dataTable->render('Shop.Admin.UnityValues.list', $data);
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return UnityValues::getTables($request->all());
|
||||
}
|
||||
|
||||
public function getOptionsByFamily(Request $request)
|
||||
{
|
||||
$id = $request->input('family_id');
|
||||
return response()->json(UnityValues::getSelectByFamily($id));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Shop.Admin.UnityValues.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = UnityValues::store($request->all());
|
||||
return redirect()->route('Shop.Admin.UnityValues.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = UnityValues::get($id);
|
||||
return view('Shop.Admin.UnityValues.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = UnityValues::get($id);
|
||||
return view('Shop.Admin.UnityValues.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return UnityValues::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,14 +19,14 @@ class Shop
|
||||
->activeIfRoute(['Shop.Admin.Categories.*'])->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', 'Familles d\'attributs', [ 'route' => 'Shop.Admin.ArticleAttributeFamilies.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeFamilies.*'])->order(4);
|
||||
/*
|
||||
$menu->addTo('shop', 'Attributs', [ 'route' => 'Shop.Admin.ArticleAttributeValues.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(5);
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(4);
|
||||
*/
|
||||
$menu->addTo('shop', 'Familles de tags', [ 'route' => 'Shop.Admin.TagGroups.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.TagGroups.*'])->order(6);
|
||||
->activeIfRoute(['Shop.Admin.TagGroups.*'])->order(5);
|
||||
$menu->addTo('shop', 'Tags', [ 'route' => 'Shop.Admin.Tags.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Tags.*'])->order(7);
|
||||
->activeIfRoute(['Shop.Admin.Tags.*'])->order(6);
|
||||
|
||||
/*
|
||||
$menu->addTo('shop', 'Réductions', [ 'route' => 'Shop.Admin.ArticleAttributeValues.index', 'permission' => 'backend_access' ])
|
||||
|
||||
@@ -22,9 +22,14 @@ class Price extends Model
|
||||
return $this->belongsTo('App\Models\Shop\PriceFamily');
|
||||
}
|
||||
|
||||
public function price()
|
||||
public function generic()
|
||||
{
|
||||
return $this->morphTo();
|
||||
return $this->belongsTo('App\Models\Shop\PriceGeneric', 'price_generic_id');
|
||||
}
|
||||
|
||||
public function generic_prices()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
@@ -37,4 +42,14 @@ class Price extends Model
|
||||
return $query->where('price_family_id', $id);
|
||||
}
|
||||
|
||||
public function scopeGeneric($query)
|
||||
{
|
||||
return $query->whereNotNull('price_generic_id');
|
||||
}
|
||||
|
||||
public function scopeNotGeneric($query)
|
||||
{
|
||||
return $query->whereNull('price_generic_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class PriceFamilyValue extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_familiy_values';
|
||||
protected $table = 'shop_price_family_values';
|
||||
|
||||
public function price_family()
|
||||
{
|
||||
|
||||
@@ -7,39 +7,34 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceGeneric extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_generics';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_generics';
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\PriceGenericCategory','id','category_id');
|
||||
}
|
||||
public function category()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\PriceGenericCategory','id','category_id');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price','price_id')->where('price_type','App\Models\Shop\PriceGeneric');
|
||||
return $this->hasMany('App\Models\Shop\PriceGenericValue','price_generic_id')->whereNotNull('price_generic_id');
|
||||
}
|
||||
|
||||
public function values()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceGenericValue');
|
||||
}
|
||||
public function priceByUnit()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\PriceGenericValue')->orderBy('quantity','asc');
|
||||
}
|
||||
|
||||
public function priceByUnit()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\PriceGenericValue')->orderBy('quantity','asc');
|
||||
}
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\Article','App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\Article','App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $id)
|
||||
{
|
||||
return $query->where('category_id', $id);
|
||||
}
|
||||
public function scopeByCategory($query, $id)
|
||||
{
|
||||
return $query->where('category_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,21 +6,21 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function group()
|
||||
{
|
||||
public function group()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\TagGroup','id','tag_group_id');
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeByGroup($query, $id)
|
||||
{
|
||||
return $query->where('tag_group_id', $id);
|
||||
}
|
||||
public function scopeByGroup($query, $id)
|
||||
{
|
||||
return $query->where('tag_group_id', $id);
|
||||
}
|
||||
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
return json_decode($value)->fr;
|
||||
}
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
return json_decode($value)->fr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TagGroup extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'tag_groups';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'tag_groups';
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Tag');
|
||||
}
|
||||
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Tag');
|
||||
}
|
||||
}
|
||||
|
||||
13
app/Models/Shop/Unity.php
Normal file
13
app/Models/Shop/Unity.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Unity extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_unities';
|
||||
|
||||
|
||||
}
|
||||
@@ -14,62 +14,49 @@ use App\Models\Shop\Price;
|
||||
class Prices
|
||||
{
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
$prices = Price::byArticle($id)->with('price')->get()->toArray();
|
||||
$data = [];
|
||||
foreach ($prices as $price)
|
||||
{
|
||||
if ($price['price_type'] == 'App\Models\Shop\ArticlePrice')
|
||||
{
|
||||
$data[] = $price['price'];
|
||||
} else {
|
||||
$values = PriceGenericValues::getByPriceGeneric($price['price']['id'])->toArray();
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$data[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
$data['prices'] = Price::byArticle($id)->notGeneric()->get()->toArray();
|
||||
$data['generics'] = Price::byArticle($id)->generic()->with(['generic.prices','generic.category'])->get()->toArray();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Price::find($id);
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Price::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 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 Price::create($data);
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return Price::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Price::find($id)->update($data);
|
||||
}
|
||||
public static function update($data)
|
||||
{
|
||||
return Price::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Price::destroy($id);
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Price::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
58
app/Repositories/Shop/Unities.php
Normal file
58
app/Repositories/Shop/Unities.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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\Unity;
|
||||
|
||||
class Unities
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Unity::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Unity::orderBy('value','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Unity::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 Unity::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Unity::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Unity::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
111
app/Twiggy.php
111
app/Twiggy.php
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
use Twig_SimpleFilter;
|
||||
|
||||
use function Stringy\create as s;
|
||||
|
||||
use App\Repositories\Languages;
|
||||
use App\Repositories\Users;
|
||||
|
||||
class Twiggy extends Twig_Extension
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new Twig_SimpleFunction('translate', [$this, 'translate']),
|
||||
new Twig_SimpleFunction('hasRole', [$this, 'hasRole']),
|
||||
new Twig_SimpleFunction('hasPermission', [$this, 'hasPermission']),
|
||||
new Twig_SimpleFunction('showMenu', [$this, 'showMenu']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new Twig_SimpleFilter('pretty_date', [$this, 'pretty_date']),
|
||||
];
|
||||
}
|
||||
|
||||
public function translate($string)
|
||||
{
|
||||
return Languages::translate($string);
|
||||
}
|
||||
|
||||
public function hasRole($string)
|
||||
{
|
||||
return Users::hasRole($string);
|
||||
}
|
||||
|
||||
public function hasPermission($string)
|
||||
{
|
||||
return Users::hasPermission($string);
|
||||
}
|
||||
|
||||
public function showMenu($menu)
|
||||
{
|
||||
return $menu->get('menu_admin')->asUl();
|
||||
}
|
||||
|
||||
public function pretty_date($date)
|
||||
{
|
||||
$time = strtotime($date);
|
||||
$now = time();
|
||||
$ago = $now - $time;
|
||||
$futur = 0;
|
||||
|
||||
if ($ago < 0) {
|
||||
$ago = (-1 * $ago);
|
||||
$futur = 1;
|
||||
}
|
||||
|
||||
if ($ago < 60) {
|
||||
$when = round($ago);
|
||||
$s = ($when == 1) ? "seconde" : "secondes";
|
||||
$txt = "$when $s";
|
||||
} elseif ($ago < 3600) {
|
||||
$when = round($ago / 60);
|
||||
$m = ($when == 1) ? "minute" : "minutes";
|
||||
$txt = "$when $m";
|
||||
} elseif ($ago >= 3600 && $ago < 86400) {
|
||||
$when = round($ago / 60 / 60);
|
||||
$h = ($when == 1) ? "heure" : "heures";
|
||||
$txt = "$when $h";
|
||||
} elseif ($ago >= 86400 && $ago < 2629743.83) {
|
||||
$when = round($ago / 60 / 60 / 24);
|
||||
$d = ($when == 1) ? "jour" : "jours";
|
||||
$txt = "$when $d";
|
||||
} elseif ($ago >= 2629743.83 && $ago < 31556926) {
|
||||
$when = round($ago / 60 / 60 / 24 / 30.4375);
|
||||
$m = "mois";
|
||||
$txt = "$when $m";
|
||||
} else {
|
||||
$when = round($ago / 60 / 60 / 24 / 365);
|
||||
$y = ($when == 1) ? "an" : "ans";
|
||||
$txt = "$when $y";
|
||||
}
|
||||
|
||||
if ($futur) {
|
||||
$txt = "dans " . $txt;
|
||||
} else {
|
||||
$txt = "il y a " . $txt;
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user