public static function findOrCreateProp($request, $propNbr, $propId) { $prop = null; var_dump('find or create: ' . $propId); if ((int) $propId > 0) { var_dump('prop existante'); $prop = Propriete::find($propId); } elseif ((int) $propId < 0) { var_dump('nouvelle prop'); $prop = new Propriete(); $prop->prop_nom = $request->input('prop_' . $propNbr . '_name'); $prop->save(); } return $prop; }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $cats = Categorie::all(); $proprietes = Propriete::all(); return view('produit.create', ['cats' => $cats, 'proprietes' => $proprietes]); }