/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(CreateProductRequest $request) { $product = Product::create($request->all()); $message = $product->name . trans('messages.new'); Session::flash('new', $message); return redirect()->route('dashboard.products.index'); }
public function scopeProductid($query, $product_id) { $products = Product::select('id')->where('status_id', 1)->get(); $array = []; foreach ($products as $product) { $array[$product->id] = $product->id; } if ($product_id != "" && isset($array[$product_id])) { $query->where("product_id", $product_id); } }
public function get() { //obtengo todos las productos $products = Product::all(); $array[''] = ''; foreach ($products as $product) { //solo los activos if ($product->status->type == 'active') { $array[$product->id] = $product->name; } } return $array; }
public static function filterProducts($name, $company) { return Product::name($name)->company($company)->simplePaginate(5); }