Пример #1
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose($view)
 {
     if (!isset($view['categories'])) {
         $categories = ProductCategory::whereNull('category_id')->with('subitems')->get();
         $view->with('categories', $categories);
         $view->with('parent', null);
     }
 }
Пример #2
0
 public function __construct()
 {
     parent::__construct();
     if (Input::get('category')) {
         $this->category = ProductCategory::find((int) Input::get('category'));
     }
     $title = 'Produtos' . ($this->category ? ': ' . $this->category->name : '');
     View::share('pageTitle', $title);
     Breadcrumbs::addCrumb($title, route("admin.product.index"));
 }
 public function beforeRenderForm($view, $model)
 {
     $selectOtherCategories = [0 => 'Nenhuma'];
     if ($model->id) {
         $categories = ProductCategory::where('id', '!=', $model->id)->get();
     } else {
         $categories = ProductCategory::get();
     }
     foreach ($categories as $category) {
         $selectOtherCategories[$category->id] = $category->fullName;
     }
     $view->with('selectOtherCategories', $selectOtherCategories);
     return $view;
 }
Пример #4
0
 public function __construct()
 {
     parent::__construct();
     if (Input::get('category')) {
         $this->category = ProductCategory::where('slug', '=', Input::get('category'))->first();
     }
     if ($this->category) {
         $title = $this->category->name;
     } else {
         $title = 'Produtos';
     }
     View::share('pageTitle', $title);
     if ($this->category) {
         Breadcrumbs::addCrumb('Produtos', route("product.index"));
     }
     Breadcrumbs::addCrumb($title, route("product.index", ['category' => Input::get('category')]));
 }
Пример #5
0
 public function makeFields()
 {
     $this->reference = new CharField(['label' => Product::getAttributeName('reference')]);
     $this->name = new CharField(['label' => Product::getAttributeName('name')]);
     $this->price = new FloatField(['label' => Product::getAttributeName('price')]);
     $this->weight = new FloatField(['label' => Product::getAttributeName('weight')]);
     $this->text = new CharField(['label' => Product::getAttributeName('text')]);
     $this->stock = new IntegerField(['label' => Product::getAttributeName('stock')]);
     $this->description = new CharField(['label' => Product::getAttributeName('description')]);
     $this->category_id = new IntegerField(['label' => Product::getAttributeName('category_id')]);
     $this->category_id->setOptions(function () {
         $result = array('' => '');
         foreach (ProductCategory::get() as $category) {
             $result[$category->id] = $category->fullName;
         }
         return $result;
     });
 }