public static function getCategoriesByProjectId($project_id) { return \App\Models\CatalogModel::all(); $user = \Auth::user(); if (!$user) { return []; } /** * @var $project_model \App\Models\ProjectModel */ $project_model = \App\Models\ProjectModel::where('id', '=', $project_id)->where('user_id', '=', $user->id)->first(); if (!$project_model) { return []; } return $project_model->categories()->get(); }
@extends('seller.layout') @section('content') <?php $project_id = 1; $project = \App\Models\ProjectModel::find($project_id); $categories_models = \App\Helpers\ProjectHelper::getCategoriesByProjectId($project_id); $attributes_group_id = \App\Helpers\ProjectHelper::getDefaultAttributesGroupId(); $attributes = \App\Models\AttributeModel::where('attribute_group_id', '=', $attributes_group_id)->get(); ?> <div class="container"> <div class="row"> <div class="col-md-12"> <?php $supplier_id = \Input::get('supplier_id'); $supplier_model = null; if ($supplier_id) { $supplier_model = $user->suppliers()->find($supplier_id); \App\Helpers\Assistant::assertModel($supplier_model); } ?> <div class="btn-toolbar" role="toolbar" style="padding: 10px 0;"> <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#editProduct"> Добавить товар </button> </div> <table class="table table-condensed table-striped table-hover table-bordered">