当前位置: 首页>>代码示例>>PHP>>正文


PHP Student::findOrFail方法代码示例

本文整理汇总了PHP中app\models\Student::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::findOrFail方法的具体用法?PHP Student::findOrFail怎么用?PHP Student::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Student的用法示例。


在下文中一共展示了Student::findOrFail方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getXoa

 function getXoa($id)
 {
     $data['list_students'] = Student::findOrFail($id);
     $data['list_students']->delete();
     return redirect()->route('student');
 }
开发者ID:b0yblake1,项目名称:duan,代码行数:6,代码来源:StudentController.php

示例2: studentEditSubmit

 /**
  *
  * @return Response
  */
 public function studentEditSubmit($id)
 {
     $student = Student::findOrFail($id);
     // WEI payment form
     if (Request::has(['wei', 'sandwich', 'wei-total'])) {
         $input = Request::only(['wei', 'sandwich', 'wei-total', 'mean', 'cash-number', 'cash-color', 'check-number', 'check-bank', 'check-name', 'check-write', 'card-write']);
         $rules = ['wei' => 'required', 'sandwich' => 'required', 'wei-total' => 'required', 'mean' => 'required|in:card,check,cash'];
         $informations = [];
         switch ($input['mean']) {
             case 'card':
                 $rules['card-write'] = 'accepted';
                 break;
             case 'cash':
                 $rules['cash-number'] = 'required';
                 $rules['cash-color'] = 'required';
                 $informations = Request::only(['cash-number', 'cash-color']);
                 break;
             case 'check':
                 $rules['check-number'] = 'required';
                 $rules['check-bank'] = 'required';
                 $rules['check-name'] = 'required';
                 $rules['check-write'] = 'accepted';
                 $informations = Request::only(['check-number', 'check-bank', 'check-name']);
                 break;
         }
         $this->validate(Request::instance(), $rules, ['mean.required' => 'Le champ Moyen de paiement est obligatoire.', 'card-write.accepted' => 'Vous devez avoir écris le numéro indiqué derrière le ticket de CB', 'check-write.accepted' => 'Vous devez avoir écris le numéro indiqué derrière le chèque', 'check-number.required' => 'Le champ Numéro de chèque est obligatoire.', 'check-bank.required' => 'Le champ Banque du chèque est obligatoire.', 'check-name.required' => 'Le champ Émetteur du chèque est obligatoire.', 'cash-number.required' => 'Le champ Numéro de caisse est obligatoire.', 'cash-color.required' => 'Le champ Couleur de caisse est obligatoire.']);
         // Check errors
         $oldSandwich = $student->sandwichPayment && in_array($student->sandwichPayment->state, ['paid']) ? 1 : 0;
         $oldWei = $student->weiPayment && in_array($student->weiPayment->state, ['paid']) ? 1 : 0;
         $sandwich = $input['sandwich'] ? 1 : 0;
         $wei = $input['wei'] ? 1 : 0;
         if ($input['sandwich'] && $oldSandwich) {
             return Redirect::back()->withError('Vous ne pouvez pas prendre un deuxieme panier repas')->withInput();
         }
         if ($input['wei'] && $oldWei) {
             return Redirect::back()->withError('Vous ne pouvez pas prendre un deuxieme weekend d\'intégration')->withInput();
         }
         if (!$input['wei'] && !$oldWei && $input['sandwich']) {
             return Redirect::back()->withError('Vous ne pouvez pas prendre un panier repas sans prendre le weekend')->withInput();
         }
         //calculate price
         $price = Config::get('services.wei.price-other');
         if ($student->ce && $student->team_accepted && $student->team_id) {
             $price = Config::get('services.wei.price-ce');
         } elseif ($student->orga) {
             $price = Config::get('services.wei.price-orga');
         }
         // Calculate amount
         $amount = ($sandwich * Config::get('services.wei.sandwichPrice') + $wei * $price) * 100;
         if ($amount / 100 != $input['wei-total']) {
             return Redirect::back()->withError('Erreur interne sur le calcul des montants, contactez un administrateur')->withInput();
         }
         // Create payment
         $payment = new Payment(['type' => 'payment', 'mean' => $input['mean'], 'amount' => $amount, 'state' => 'paid', 'informations' => $informations]);
         $payment->save();
         // Save paiement in user object
         $user = $student;
         if ($wei) {
             $user->wei_payment = $payment->id;
         }
         if ($sandwich) {
             $user->sandwich_payment = $payment->id;
         }
         $user->updateWei();
         $user->save();
         return Redirect(route('dashboard.wei.student.edit', ['id' => $student->student_id]))->withSuccess('Vos modifications ont été enregistrées.');
     }
     // Guarantee payment form
     if (Request::has(['guarantee', 'guarantee-total'])) {
         $input = Request::only(['guarantee', 'guarantee-total', 'check2-number', 'check2-bank', 'check2-name', 'check2-write']);
         $informations = Request::only(['check-number', 'check-bank', 'check-name']);
         $this->validate(Request::instance(), ['guarantee' => 'required', 'guarantee-total' => 'required', 'check2-number' => 'required', 'check2-bank' => 'required', 'check2-name' => 'required', 'check2-write' => 'accepted'], ['check2-write.accepted' => 'Vous devez avoir écris le numéro indiqué derrière le chèque', 'check2-number.required' => 'Le champ Numéro de chèque est obligatoire.', 'check2-bank.required' => 'Le champ Banque du chèque est obligatoire.', 'check2-name.required' => 'Le champ Émetteur du chèque est obligatoire.']);
         // Check errors
         $oldGuarantee = $student->guaranteePayment && in_array($student->guaranteePayment->state, ['paid']) ? 1 : 0;
         $guarantee = $input['guarantee'] ? 1 : 0;
         if ($input['guarantee'] && $oldGuarantee) {
             return Redirect::back()->withError('Vous ne pouvez pas payer deux fois la caution')->withInput();
         }
         // Calculate amount
         $amount = $guarantee * Config::get('services.wei.guaranteePrice') * 100;
         if ($amount / 100 != $input['guarantee-total']) {
             return Redirect::back()->withError('Erreur interne sur le calcul des montants, contactez un administrateur')->withInput();
         }
         // Create payment
         $payment = new Payment(['type' => 'guarantee', 'mean' => 'check', 'amount' => $amount, 'state' => 'paid', 'informations' => $informations]);
         $payment->save();
         // Save paiement in user object
         if ($guarantee) {
             $student->guarantee_payment = $payment->id;
         }
         $student->updateWei();
         $student->save();
         return Redirect(route('dashboard.wei.student.edit', ['id' => $student->student_id]))->withSuccess('Vos modifications ont été enregistrées.');
     }
     return Redirect(route('dashboard.wei.student.edit', ['id' => $student->student_id]))->withError('Y\'a un soucis !');
 }
开发者ID:ungdev,项目名称:integration-UTT,代码行数:100,代码来源:WEIController.php

示例3: editSubmit

 /**
  * Execute edit form for a student from admin dashboard
  *
  * @param  int $id
  * @return RedirectResponse|array
  */
 public function editSubmit($id)
 {
     $student = Student::findOrFail($id);
     $data = Request::only(['surname', 'sex', 'email', 'phone', 'branch', 'level', 'facebook', 'city', 'postal_code', 'country', 'referral', 'referral_max', 'referral_text', 'referral_validated', 'admin', 'orga']);
     $this->validate(Request::instance(), ['surname' => 'max:50', 'sex' => 'boolean', 'email' => 'email', 'phone' => 'min:8|max:20', 'facebook' => 'url', 'postal_code' => 'integer', 'referral_max' => 'integer|max:5|min:1']);
     // Add or remove from sympa
     if (!$student->orga && $data['orga']) {
         $sent = Mail::raw('QUIET ADD integration-liste ' . $student->email . ' ' . $student->first_name . ' ' . $student->last_name, function ($message) use($student) {
             $message->from('integrat@utt.fr', 'Intégration UTT');
             $message->to('sympa@utt.fr');
         });
     } elseif ($student->orga && !$data['orga']) {
         $sent = Mail::raw('QUIET DELETE integration-liste ' . $student->email, function ($message) use($student) {
             $message->from('integrat@utt.fr', 'Intégration UTT');
             $message->to('sympa@utt.fr');
         });
     }
     // Update team informations
     $student->surname = $data['surname'];
     $student->sex = $data['sex'];
     $student->email = $data['email'];
     $student->phone = $data['phone'];
     $student->branch = $data['branch'];
     $student->level = $data['level'];
     $student->facebook = $data['facebook'];
     $student->city = $data['city'];
     $student->postal_code = $data['postal_code'];
     $student->country = $data['country'];
     $student->referral = !empty($data['referral']);
     $student->referral_max = $data['referral_max'];
     $student->referral_text = $data['referral_text'];
     $student->referral_validated = !empty($data['referral_validated']);
     $student->admin = !empty($data['admin']) ? 100 : 0;
     $student->orga = !empty($data['orga']);
     $student->save();
     return Redirect::back()->withSuccess('Vos modifications ont été sauvegardées.');
 }
开发者ID:ungdev,项目名称:integration-UTT,代码行数:43,代码来源:StudentsController.php

示例4: getStudentAttribute

 public function getStudentAttribute()
 {
     return \App\Models\Student::findOrFail($this->userable_id);
 }
开发者ID:joaonzangoII,项目名称:find_my_campuses_friend,代码行数:4,代码来源:User.php

示例5: postValidation

 /**
  * Handle text validation.
  *
  * @return RedirectResponse
  */
 public function postValidation()
 {
     $id = Request::input('student-id');
     $referral = Student::findOrFail($id);
     if ($referral->referral_validated) {
         return Redirect::back()->withError('Quelqu\'un a déjà validé cette personne :-(');
     }
     $referral->referral_validated = 1;
     $referral->referral_text = Request::input('referral_text');
     $referral->save();
     return Redirect::back()->withSuccess('Texte validé pour ' . $referral->first_name . ' ' . $referral->last_name . ' !');
 }
开发者ID:ungdev,项目名称:integration-UTT,代码行数:17,代码来源:ReferralsController.php


注:本文中的app\models\Student::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。