當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::findOrFail方法代碼示例

本文整理匯總了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();
 }
開發者ID:Bottelet,項目名稱:Flarepoint-crm,代碼行數:5,代碼來源:ClientRepository.php

示例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');
 }
開發者ID:jbagaresgaray,項目名稱:invoiceninja,代碼行數:38,代碼來源:ExpenseController.php

示例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());
     }
 }
開發者ID:GBEY0402,項目名稱:LesCuirsBermont3.0,代碼行數:28,代碼來源:ClientsController.php


注:本文中的app\models\Client::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。