/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); $router->bind('client', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return Client::findOrFail($id); }); $router->bind('bank', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return BankDetail::findOrFail($id); }); $router->bind('address', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return Address::findOrFail($id); }); $router->bind('property', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return Property::findOrFail($id); }); $router->bind('agreement', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return RentalAgreement::findOrFail($id); }); // }
public function destroy($id) { $property = Property::findOrFail($id); $contract = Contract::where('property_id', '=', $id)->delete(); $property->delete(); return redirect('properties'); }
/** * update meta data. * * temporary method while i spec out a better way to do this. * * @param Request $request * @return array|string */ public function postUpdate(Request $request) { $property_id = $request->input('property_id'); $image_alt = $request->input('imgalt'); $image_clean = $request->input('cleanimagename'); $meta_title = $request->input('meta-title'); $meta_desc = $request->input('meta-description'); foreach ($image_clean as $image_id => $value) { self::saveCleanImageName($image_id, $value); } foreach ($image_alt as $image_id => $value) { self::saveImageAlt($image_id, $value); } $Property = \App\Property::findOrFail($property_id); $Property->metatitle = $meta_title; $Property->metadescription = $meta_desc; $Property->meta_set = 1; $Property->save(); return back(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, contractRequest $request) { // use my custom handler to fix dates, check if dates are valid and see if the stores are available to rent $contractFormHandler = new ContractFormHandler($request); if ($contractFormHandler->hasErrors) { \Session::flash('message', $contractFormHandler->errorMessages); \Session::flash('messageType', 'warning'); return redirect()->route('contracts.edit', ['contracts' => $id])->withInput(); } // remove previous associations to replace with new form $contract = Contract::findOrFail($id); $contract->tenant()->dissociate(); $contract->properties()->detach(); // update info $contract->description = $request->description; $contract->effective_date = $request->effective_date; $contract->expiry_date = $request->expiry_date; $contract->terms = $request->terms; $contract->signing_date = $request->signing_date; $contract->amount = $request->amount; $contract->currency = $request->currency; // associate with tenant $tenant = Tenant::findOrFail($request->tenant); $contract->tenant()->associate($tenant); // attach properties foreach ($request->properties as $key => $property) { $propertyInFocus = Property::findOrFail($property); $contract->properties()->attach($propertyInFocus); } $contract->save(); return redirect()->route('contracts.index'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, propertyRequest $request) { $property = Property::findOrFail($id); $property->update($request->all()); return Redirect::route('properties.index'); }
public function removeDevice(Request $request, $id) { $property = Property::findOrFail($id); $deviceId = $request->Input('device_id'); $property->devices()->detach($deviceId); $property->save(); return Redirect::route('properties.show', [$property->id]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $property = Property::findOrFail($id); $property->delete(); return redirect()->route('properties.index')->with('message', 'Item deleted successfully.'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $property = Property::findOrFail($id); return view('properties.show', compact('property')); }