本文整理汇总了PHP中app\Address::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::findOrFail方法的具体用法?PHP Address::findOrFail怎么用?PHP Address::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Address
的用法示例。
在下文中一共展示了Address::findOrFail方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* 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);
});
//
}
示例2: updateAddress
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;
}
示例3: update
/**
* 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]);
}
示例4: edit
/**
* 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'));
}
示例5: edit
/**
* 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'));
}
示例6: update
/**
* 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]);
}
示例7: address
public function address($id)
{
return Address::findOrFail($id);
}
示例8: destroy
/**
* 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');
}
示例9: edit
/**
* 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'));
}
示例10: addNote
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];
}
示例11: update
/**
* 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]);
}
示例12: update
/**
* 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 :: (:id) ', ['id' => $id], 'layouts') . $request->get('name_commercial'));
}
示例13: updateAddress
protected function updateAddress($addressArray)
{
$newAddress = $this->unTransform($addressArray, 'address');
$address = Address::findOrFail($addressArray['id']);
return $address->update($newAddress);
}