本文整理汇总了PHP中Phone::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Phone::find方法的具体用法?PHP Phone::find怎么用?PHP Phone::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phone
的用法示例。
在下文中一共展示了Phone::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: borrar_telefono
public function borrar_telefono()
{
$id = Input::get('idedit');
$telefono = Phone::find($id);
if ($telefono->delete()) {
Session::flash('message', 'Eliminado correctamente');
Session::flash('class', 'success');
} else {
Session::flash('message', 'Ha ocurrido un error, intentelo nuevamente');
Session::flash('class', 'danger');
}
return Redirect::to('telefono');
}
示例2: selfUpdatePhone
/**
* Update (basically create new one but with provided id) mine phone
* This functions requires token - user must validate phone number via sms
* @param $id
*
* @return Response
*/
public function selfUpdatePhone($id)
{
$token = Input::get('token');
$smsEntry = SMS::where('token', $token)->orderBy('id')->first();
if (!$smsEntry) {
return $this->respondInsufficientPrivileges('user.invalid-token');
}
if (!$smsEntry->verified) {
return Response::json(['error' => ['message' => 'Your number is not yet verified. Please re-register', 'status' => 1]], 403);
}
$phone = Phone::find($id);
if (!$phone) {
return $this->respondNotFound('user.phone-not-found');
}
$phone->fill(['number' => $smsEntry->phone]);
if ($phone->save()) {
$smsEntry->delete();
// $user = Auth::user();
return $this->respond($phone);
// return $user->phones;
}
return $this->respondNotFound('user.phone-not-found');
}
示例3: function
$contactList->put("/phones/:id", function ($id) use($contactList) {
$phone = $contactList->request->params('phone');
$editPhone = Phone::find($id);
$editPhone->phone = $phone;
if ($editPhone->save()) {
$data['msg'] = 'Phone saved successfully!';
$data['id'] = $editPhone->id;
} else {
$data['msg'] = 'An error occurred while saving the phone!';
}
$contactList->response()->header('Content-Type', 'application/json');
echo json_encode($data);
});
// Delete phone
$contactList->delete("/phones/:id", function ($id) use($contactList) {
$phone = Phone::find($id);
if ($phone->delete()) {
$data['msg'] = 'Phone deleted successfully!';
} else {
$data['msg'] = 'An error occurred while deleting the phone!';
}
$contactList->response()->header('Content-Type', 'application/json');
echo json_encode($data);
});
// Get all address to one contact
$contactList->get("/contact/:id/address", function ($id) use($contactList) {
$addresses = Address::where('contactId', '=', $id)->get();
$contactList->response()->header('Content-Type', 'application/json');
echo json_encode(objectToArray(json_decode($addresses)));
});
// Add new address