/** * Store a newly created resource in storage. * * @return Response */ public function store() { try { $request = \Request::all(); $validator = \Validator::make($request, ['title' => 'required', 'code' => 'required', 'type' => 'required', 'model_goal' => 'required', 'model_initiator' => 'required', 'link_id' => 'required|numeric', 'sort' => 'required|numeric']); if ($validator->fails()) { return Response::json(['error' => 1, 'errors' => $validator->errors()], 500); } $property = Property::create($request); //$property->type = $this->propertiesType[$property->type]; return $property->toJson(); } catch (Exception $e) { dd($e); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(propertyRequest $request) { $input = $request->all(); // we don't want the attached image to be part of the mass assignment unset($input['image']); $property = Property::create($input); if ($request->hasfile('image')) { // get file's name $filename = $request->file('image')->getClientOriginalName(); // prepare destination $destinationPath = public_path() . "/img/properties/"; // put copy of uploaded image at destination folder $request->file('image')->move($destinationPath, $filename); $property->image = $filename; $property->save(); } \Session::flash('messageType', 'success'); \Session::flash('message', 'Property Successfully created'); return Redirect::route('properties.index'); }
/** * Execute the job. * * @return void */ public function handle() { $images = []; try { $createdProperty = \App\Property::where('MLSNumber', '=', $this->property['MLSNumber'])->with('propertyImages')->first(); } catch (Exception $e) { Bugsnag::notifyException($e); } switch (true) { case !is_null($createdProperty): $createProperty = $createdProperty->update($this->property); break; default: $createProperty = \App\Property::create($this->property); $listingAgent = dispatch((new CreateListingAgent($createProperty, $this->property))->onQueue('additionalInformation')); $community = dispatch((new CreateListingCommunity($createProperty, $this->property))->onQueue('additionalInformation')); if ($this->property['PhotoCount'] > 0) { $images = dispatch((new GetPropertyImages($createProperty, $this->property['Matrix_Unique_ID']))->onQueue('images')); } $createdAt = $this->setCreatedAt($createProperty->toArray()); dispatch((new IndexProperty($this->property, $createdAt))->onQueue('indexProperty')); break; } }
public function run() { Property::create(['name' => 'Carlton Scott', 'abbreviation' => 'CS']); Property::create(['name' => 'Stonegate', 'abbreviation' => 'SG']); Property::create(['name' => '1807 House', 'abbreviation' => '1807H']); }
public function store(PropertyRequest $request) { $input = $request->all(); Property::create($input); return redirect('properties'); }