/**
  * 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);
     });
     //
 }
Ejemplo n.º 2
0
 public static function updateAddress($address)
 {
     try {
         $addressObj = Address::findOrFail($address['id']);
         $data = $addressObj->update(['lat' => $address['lat'], 'long' => $address['long']]);
     } catch (Exception $e) {
         $data = ['error' => 'Address not updated', 'message' => $e->getMessage()];
     }
     return $data;
     // dd(['$address' => $address, 'updated' => $data, 'addressObj' => $addressObj->toArray()]); exit;
 }
Ejemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['contact11' => 'integer|min:1000000000|max:9999999999', 'contact12' => 'integer|max:9999999999', 'std_pincode' => 'integer']);
     $studentData = Student::findOrFail($id);
     $studentAdds = $studentData->addresses->flatten()->toArray();
     foreach ($studentAdds as $key => $value) {
         $studentAdd = $value;
     }
     $addressData = Address::findOrFail($studentAdd['id']);
     $addressData->update(['contact11' => $request->contact11, 'contact12' => $request->contact12, 'add1' => ucwords($request->add1), 'add2' => ucwords($request->add2), 'street' => ucwords($request->street), 'pincode' => $request->pincode]);
     return Redirect::route('student.show', ['student' => $addressData]);
 }
Ejemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     try {
         $address = Address::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         throw new NotFoundHttpException();
     }
     return view('address.form_edit', compact('address'));
 }
Ejemplo n.º 5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $address = Address::findOrFail($id);
     // $address=Address::findOrFail($address->id);
     return view('editProperty', compact('address'));
 }
Ejemplo n.º 6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $staffData = User::findOrFail($id);
     if (isset($request->name)) {
         $staffData->update(['name' => $request->name, 'email' => $request->email, 'bday' => $request->bday]);
     }
     $staffAddresses = $staffData->addresses->flatten()->toArray();
     foreach ($staffAddresses as $key => $value) {
         $staffAddress = $value;
     }
     $addressData = Address::findOrFail($staffAddress['id']);
     $addressData->update(['contact11' => $request->contact11, 'contact12' => $request->contact12, 'add1' => $request->add1, 'add2' => $request->add2, 'street' => $request->street, 'pincode' => $request->pincode]);
     return Redirect::route('staff.show', ['staff' => $staffData]);
 }
Ejemplo n.º 7
0
 public function address($id)
 {
     return Address::findOrFail($id);
 }
Ejemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $address = Address::findOrFail($id);
     $address->delete();
     Session::flash('flash_message', 'Address successfully deleted!');
     return redirect()->action('ClientController@index');
 }
Ejemplo n.º 9
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit(Client $client)
 {
     $addressId = $client->addresses()->first()->id;
     $address = Address::findOrFail($addressId);
     return view('general.editAddress', compact('address', 'client'));
 }
 public function addNote(Request $request, $territoryId = null, $addressId = null)
 {
     if (!$this->hasAccess($request)) {
         return Response()->json(['error' => 'Access denied.'], 500);
     }
     if (empty($territoryId)) {
         return ['error' => 'Territory not found', 'message' => 'Territory not found'];
     }
     if (!empty($addressId)) {
         if (Gate::denies('create-notes')) {
             return Response()->json(['error' => 'Method not allowed'], 403);
         }
         // dd($this->unTransform($request->all(), 'note'));
         try {
             $transformedData = $this->unTransform($request->all(), 'note');
             // return ['data' => ['transformed'=>$transformedData, 'request' => $request->all()]];
             $address = Address::findOrFail($addressId);
             $data = $address && !empty($transformedData) ? $address->notes()->create($transformedData) : null;
         } catch (Exception $e) {
             $data = ['error' => 'Note not updated', 'message' => $e->getMessage()];
         }
     } else {
         $data = ['error' => 'Note not saved', 'message' => 'Note not saved'];
     }
     return ['data' => $data];
 }
Ejemplo n.º 11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['student' => 'string', 'email' => 'email', 'parentemail' => 'email']);
     $studentData = Student::findOrFail($id);
     $studentAdds = $studentData->addresses->flatten()->toArray();
     foreach ($studentAdds as $key => $value) {
         $studentAdd = $value;
     }
     $addressData = Address::findOrFail($studentAdd['id']);
     $studentData->update(['student' => ucwords($request->student), 'email' => $request->email, 'parentemail' => $request->parentemail]);
     return Redirect::route('student.show', ['student' => $studentData]);
 }
Ejemplo n.º 12
0
 /**
  * Update the specified resource in storage.
  * PUT /companies/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     if (!$request->input('name_commercial')) {
         $request->merge(['name_commercial' => $request->input('name_fiscal')]);
     }
     $company = Company::findOrFail($id);
     $address = Address::findOrFail($company->address_id);
     $this->validate($request, Company::$rules);
     $request->merge(['alias' => $address->alias]);
     // Alias is mandatory!
     $this->validate($request, ['address' => Address::$rules]);
     $company->update($request->all());
     $request->merge($request->input('address'));
     // also replace
     $address->update($request->except(['address']));
     return redirect('companies')->with('info', l('This record has been successfully updated &#58&#58 (:id) ', ['id' => $id], 'layouts') . $request->get('name_commercial'));
 }
Ejemplo n.º 13
0
 protected function updateAddress($addressArray)
 {
     $newAddress = $this->unTransform($addressArray, 'address');
     $address = Address::findOrFail($addressArray['id']);
     return $address->update($newAddress);
 }