- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
public function product(Request $request, $id = null)
{
$this->template['product'] = $id ? Product::find($id) : new Product();
$this->template['product'] || abort(404);
if(!$this->template['product']->exists && count($input)){
if(array_key_exists('category', $input) && $input['category']){
$category = Category::where('alias','=',$input['category'])->first();
if($category){
$this->template['product']->category_id = $category->id;
}
}
if(array_key_exists('brand', $input) && $input['brand']){
$car = Car::where('alias','=', $input['brand'])->first();
if($car){
$this->template['product']->car_id = $car->id;
}
}
if(array_key_exists('model', $input) && $input['model']){
$car_model = CarModel::where('alias','=',$input['model'])->first();
if($car_model){
$this->template['product']->car_model_id = $car_model->id;
}
}
if(array_key_exists('year', $input) && $input['year']){
$this->template
}
}
$this->template['categories'] = Category::all();
$this->template['brands'] = Brand::all();
$this->template['years'] = Year::all()->sortBy('year');
$this->template['cars'] = Car::all();
$this->template['car_models'] = CarModel::all();
return View::make('dashboard.product', $this->template);
}
Не знаю наверное у Вас так не принято) но подскажите как избавиться от говноёлки?!)