本文整理匯總了PHP中app\models\Client::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::findOrFail方法的具體用法?PHP Client::findOrFail怎麽用?PHP Client::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Client
的用法示例。
在下文中一共展示了Client::findOrFail方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
public function update($id, $requestData)
{
$client = Client::findOrFail($id);
$client->fill($requestData->all())->save();
}
示例2: bulk
public function bulk()
{
$action = Input::get('action');
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
switch ($action) {
case 'invoice':
$expenses = Expense::scope($ids)->get();
$clientId = null;
$data = [];
// Validate that either all expenses do not have a client or if there is a client, it is the same client
foreach ($expenses as $expense) {
if ($expense->client_id) {
if (!$clientId) {
$clientId = $expense->client_id;
} elseif ($clientId != $expense->client_id) {
Session::flash('error', trans('texts.expense_error_multiple_clients'));
return Redirect::to('expenses');
}
}
if ($expense->invoice_id) {
Session::flash('error', trans('texts.expense_error_invoiced'));
return Redirect::to('expenses');
}
$account = Auth::user()->account;
$data[] = ['publicId' => $expense->public_id, 'description' => $expense->public_notes, 'qty' => 1, 'cost' => $expense->present()->converted_amount];
}
$clientPublicId = $clientId ? Client::findOrFail($clientId)->public_id : '';
return Redirect::to("invoices/create/{$clientPublicId}")->with('expenses', $data);
break;
default:
$count = $this->expenseService->bulk($ids, $action);
}
if ($count > 0) {
$message = Utils::pluralize($action . 'd_expense', $count);
Session::flash('message', $message);
}
return Redirect::to('expenses');
}
示例3: update
/**
* Mise à jour dans la base de donnée en utilisant l'Id de la personne.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update($id)
{
try {
$input = Input::all();
$client = Client::findOrFail($id);
$client->prenom = $input['prenom'];
$client->nom = $input['nom'];
$client->adresse = $input['adresse'];
$client->ville = $input['ville'];
$client->noTel = $input['noTel'];
$client->courriel = $input['courriel'];
$client->relation = $input['relation'];
$client->actif = $input['actif'];
} catch (ModelNotFoundException $e) {
App::abort(404);
}
if ($client->save()) {
return Redirect::action('ClientsController@index');
} else {
return Redirect::back()->withInput()->withErrors($client->validationMessages());
}
}