예제 #1
0
파일: Products.php 프로젝트: pavhov93/blog2
 public static function getRulesArray()
 {
     $rulesArray = [];
     $requset = new Products();
     $rules = $requset->rules();
     foreach ($rules as $index => $rule) {
         $rule = explode('|', $rules[$index]);
         foreach ($rule as $i => $item) {
             $rulesArray[$index][$i] = $item;
         }
     }
     return $rulesArray;
 }
예제 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\Products $request)
 {
     Product::create($request->all());
     Session::flash('flash_message', 'Product added!');
     return redirect('products');
 }
예제 #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function update($id, Products $request)
 {
     $product = Product::findOrFail($id);
     $all = $request->all();
     if (isset($all['image'])) {
         $this->unlink($product['image']);
         $all['image'] = $this->upload($all['image']);
     }
     $product->update($all);
     Session::flash('flash_message', 'Product updated!');
     return redirect('products-grid/' . $id);
 }