Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $catalog_tree = \App\Models\CatalogModel::find(1)->descendants()->get()->toTree();
     $this->line(PHP_EOL);
     $tags_ids_arr = [];
     foreach ($catalog_tree as $catalog_tree_item) {
         $children = $catalog_tree_item->children;
         if ($children->count() < 1) {
             continue;
         }
         foreach ($children as $child) {
             $tags_ids_arr[] = $child->id;
         }
     }
     $products_mix_arr = \DB::table('products')->select('id')->get();
     $products_mix_arr = array_rand($products_mix_arr, 100);
     foreach ($products_mix_arr as $product_mix) {
         \DB::table('products_tags')->insert(['tag_id' => $tags_ids_arr[rand(0, count($tags_ids_arr) - 1)], 'product_id' => $product_mix]);
         echo '.';
     }
     $this->line(PHP_EOL);
 }
Ejemplo n.º 3
0
<?php

$catalog_tree = \App\Models\CatalogModel::find(1)->descendants()->get()->toTree();
if (!$catalog_tree->count()) {
    return '';
}
?>

@foreach($catalog_tree as $root_item)
    <div class="col-lg-4">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">{{ $root_item->name }}</h3>
            </div>
            <div class="panel-body">
        @foreach($root_item->children as $children_item)
            <div>
                <a href="#" data-cid="{{ $children_item->id }}">{{ $children_item->name }}</a>
                @foreach($children_item->children as $sub_children_item)
                    <a href="">{{ $sub_children_item->name }}</a>
                @endforeach
            </div>
        @endforeach
                Panel content
            </div>
        </div>
    </div>
@endforeach
 /**
  * Создание или сохранение категории
  * @param Request $request
  * @return string
  */
 public function postSaveCategory(Request $request)
 {
     $post_fields_arr = $request->all();
     /**
      * @var $category \Illuminate\Database\Eloquent\Model
      */
     if (isset($post_fields_arr['id'])) {
         $category = \App\Models\CatalogModel::find($post_fields_arr['id']);
         if (!$category) {
             return 'Ошибка: нет категории с таким ID - ' . $post_fields_arr['id'];
         }
         $category->name = $post_fields_arr['name'];
         $category->parent_id = $post_fields_arr['parent_id'];
         $category->project_id = $post_fields_arr['project_id'];
         $category->save();
     } else {
         \App\Models\CatalogModel::create($post_fields_arr);
     }
     return redirect('/seller/products');
 }
                    Поставщик: {{ $purchase_model->supplier->name }}
                </a>
                <h3 style="margin: 5px 0 25px">Закупка: {{ $purchase_model->name }}</h3>
                <ul class="nav nav-pills">
                    <li><a href="/seller/purchases/{{ $purchase_model->id }}">Основная</a></li>
                    <li class="active"><a href="/seller/purchases/products/{{ $purchase_model->id }}">Товары в закупке</a></li>
                    <li><a href="/seller/purchases/history/{{ $purchase_model->id }}">История</a></li>
                </ul>

                <div style="height: 20px"></div>

                <div class="row">
                    <!--div class="col-md-3">
                        <div style="padding: 10px 20px">
                            <?php 
$catalog = \App\Models\CatalogModel::getRootNode()->getDescendants()->toTree();
?>
                            <ul class="list-unstyled">
                                @foreach($catalog as $catalog_item)
                                <li><h5>{{ $catalog_item->name }}</h5>
                                  <ul>
                                      @foreach($catalog_item->children as $catalog_sub_item)
                                      <li><a href="#" onclick="loadCatalog({{ $catalog_sub_item->id }}); return false;">{{ $catalog_sub_item->name }}</a></li>
                                      @endforeach
                                  </ul>
                                </li>
                                @endforeach
                            </ul>
                        </div>
                    </div-->
                    <div class="col-md-6">
Ejemplo n.º 6
0
 public function render()
 {
     $catalog_tree = \App\Models\CatalogModel::find(1)->descendants()->get()->toTree();
     return view('catalog.widgets.side_nav', ['catalog_tree' => $catalog_tree]);
 }