fixes
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Datatables\Shop;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\PriceList;
|
||||
use App\Repositories\Shop\PriceLists;
|
||||
|
||||
class PriceListsDataTable extends DataTable
|
||||
{
|
||||
@@ -17,7 +18,7 @@ class PriceListsDataTable extends DataTable
|
||||
|
||||
public function query(PriceList $model)
|
||||
{
|
||||
$model = $model->with('sale_channel');
|
||||
$model = $model->with(['sale_channel','price_list_values']);
|
||||
$model = self::filterByTariff($model);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
@@ -28,10 +29,20 @@ class PriceListsDataTable extends DataTable
|
||||
return $tariff_id ? $model->byTariff($tariff_id) : $model;
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (PriceList $price_list) {
|
||||
return PriceLists::getStatus($price_list['status_id']);
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('status_id')->data('status')->title('etat'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channel.name')->title('Canal de vente'),
|
||||
self::makeColumnButtons(),
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Datatables\Shop;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Tariff;
|
||||
use App\Repositories\Shop\Tariffs;
|
||||
|
||||
class TariffsDataTable extends DataTable
|
||||
{
|
||||
@@ -16,9 +17,21 @@ class TariffsDataTable extends DataTable
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (Tariff $tariff) {
|
||||
return Tariffs::getStatus($tariff['status_id']);
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
;
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('status_id')->data('status')->title('status'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channel.name')->title('Canal de vente par défaut'),
|
||||
Column::make('code')->title('Code'),
|
||||
|
||||
@@ -28,7 +28,8 @@ class GenreController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = Genres::store($request);
|
||||
$data = $request->all();
|
||||
$ret = Genres::store($data);
|
||||
return redirect()->route('Admin.Botanic.Genres.index');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
|
||||
use App\Repositories\Botanic\Species;
|
||||
use App\Repositories\Botanic\Genres;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
use App\Datatables\Botanic\SpeciesDataTable;
|
||||
|
||||
class SpecieController extends Controller
|
||||
@@ -28,13 +29,14 @@ class SpecieController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$data['genres'] = Genres::getOptions();
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Admin.Botanic.Species.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$ret = Species::store($data);
|
||||
$ret = Species::storeFull($data);
|
||||
return redirect()->route('Admin.Botanic.Species.index');
|
||||
}
|
||||
|
||||
@@ -48,6 +50,7 @@ class SpecieController extends Controller
|
||||
{
|
||||
$data['specie'] = Species::get($id);
|
||||
$data['genres'] = Genres::getOptions();
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Admin.Botanic.Species.edit', $data);
|
||||
}
|
||||
|
||||
@@ -56,6 +59,21 @@ class SpecieController extends Controller
|
||||
return Species::destroy($id);
|
||||
}
|
||||
|
||||
public function getImages(Request $request, $id = false, $can_edit = true)
|
||||
{
|
||||
$id = $id ? $id : $request->input('id');
|
||||
$data['images'] = Species::getImages($id);
|
||||
$data['can_edit'] = $can_edit;
|
||||
return view('components.uploader.mini-gallery-items', $data);
|
||||
}
|
||||
|
||||
public function deleteImage(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$index = $request->input('index');
|
||||
return Species::deleteImage($id, $index);
|
||||
}
|
||||
|
||||
public function exportExcel()
|
||||
{
|
||||
return Species::exportExcel();
|
||||
|
||||
@@ -44,7 +44,7 @@ class VarietyController extends Controller
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Varieties::getFull($id);
|
||||
$data['variety'] = Varieties::getFull($id);
|
||||
$data['species'] = Species::getOptions();
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
return view('Admin.Botanic.Varieties.edit', $data);
|
||||
|
||||
@@ -13,10 +13,10 @@ class Customers
|
||||
->activeIfRoute('customers')
|
||||
->order(3);
|
||||
|
||||
$menu->addTo('customers', 'Clients', [ 'route' => 'Admin.Shop.Customers.index', 'permission' => 'backend_access' ])
|
||||
$menu->addTo('customers', __('customer.customers.name'), [ 'route' => 'Admin.Shop.Customers.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Admin.Shop.Customers.*'])->order(1);
|
||||
|
||||
$menu->addTo('customers', 'Canaux de vente', [ 'route' => 'Admin.Shop.SaleChannels.index', 'permission' => 'backend_access' ])
|
||||
$menu->addTo('customers', __('customer.sale_channels.name'), [ 'route' => 'Admin.Shop.SaleChannels.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Admin.Shop.SaleChannels.*'])->order(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
class Variety extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia, PowerJoins, Taggable, SoftDeletes, UserStamps;
|
||||
use InteractsWithMedia, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'botanic_varieties';
|
||||
|
||||
@@ -6,9 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
|
||||
class Tariff extends Model
|
||||
{
|
||||
use HasComments, HasRelationships;
|
||||
use HasComments, HasRelationships, PowerJoins;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_tariffs';
|
||||
@@ -27,4 +29,14 @@ class Tariff extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceList');
|
||||
}
|
||||
|
||||
public function scopeBySaleChanel($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.sale_channel_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.status_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,15 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
use App\Repositories\Core\Tag;
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Exports\Botanic\SpeciesExport;
|
||||
|
||||
|
||||
class Species
|
||||
{
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Specie::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
@@ -45,11 +41,23 @@ class Species
|
||||
return Specie::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = $data['images'] ?? false;
|
||||
$tags = $data['tags'] ?? false;
|
||||
unset($data['images']);
|
||||
unset($data['tags']);
|
||||
$specie = self::store($data);
|
||||
self::storeImages($variety, $images);
|
||||
self::storeTags($specie, $tags);
|
||||
return $specie;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
$id = $data['id'] ?? false;
|
||||
$specie = $id ? self::update($data, $id) : self::create($data);
|
||||
return $specie;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
@@ -70,6 +78,26 @@ class Species
|
||||
return Specie::destroy($id);
|
||||
}
|
||||
|
||||
public static function storeTags($specie, $tags)
|
||||
{
|
||||
return Tag::storeTags($specie, $tags);
|
||||
}
|
||||
|
||||
public static function storeImages($specie, $files)
|
||||
{
|
||||
return Media::storeImages($specie, $files);
|
||||
}
|
||||
|
||||
public static function getImages($id)
|
||||
{
|
||||
return Media::getImages(self::get($id));
|
||||
}
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
return Media::deleteImage(self::get($id), $index);
|
||||
}
|
||||
|
||||
public static function exportExcel()
|
||||
{
|
||||
return Excel::download(new SpeciesExport, 'species.xlsx');
|
||||
|
||||
@@ -62,7 +62,6 @@ class Varieties
|
||||
return Tag::getTagsByModel($variety);
|
||||
}
|
||||
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = isset($data['images']) ? $data['images'] : false;
|
||||
@@ -75,7 +74,6 @@ class Varieties
|
||||
return $variety;
|
||||
}
|
||||
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return isset($data['id']) ? self::update($data) : self::create($data);
|
||||
|
||||
@@ -10,6 +10,17 @@ use App\Models\Shop\PriceList;
|
||||
|
||||
class PriceLists
|
||||
{
|
||||
|
||||
public static function getStatus($status_id)
|
||||
{
|
||||
return self::getStatuses()[$status_id];
|
||||
}
|
||||
|
||||
public static function getStatuses()
|
||||
{
|
||||
return ['Actif','Suspendu','Invisible','Obsolete'];
|
||||
}
|
||||
|
||||
public static function getByTariff($id)
|
||||
{
|
||||
return PriceList::byTariff($id)->get();
|
||||
|
||||
@@ -26,6 +26,11 @@ class Tariffs
|
||||
return Tariff::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getStatus($status_id)
|
||||
{
|
||||
return self::getStatuses()[$status_id];
|
||||
}
|
||||
|
||||
public static function getStatuses()
|
||||
{
|
||||
return ['Actif','Suspendu','Invisible','Obsolete'];
|
||||
|
||||
Reference in New Issue
Block a user