本文整理汇总了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());
}
}