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


PHP Company::findOrFail方法代码示例

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


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

示例1: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $type = $this->input('type_request');
     if ($type == 0) {
         return ['name' => 'required|max:255|unique:companies', 'email' => 'required|email|unique:users', 'first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'password' => 'required|min:5|max:20|same:confirm_password', 'confirm_password' => 'required|min:5'];
     } else {
         $email = $this->input('email');
         $name = $this->input('name');
         $user_id = $this->input('user_id');
         $company_id = $this->input('company_id');
         $company = Company::findOrFail($company_id);
         $user = User::findOrFail($user_id);
         if ($user->email == $email) {
             if ($company->name == $name) {
                 return ['first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'password' => 'min:5|max:20', 'new_password' => 'min:5|same:confirm_password'];
             } else {
                 return ['name' => 'required|max:255|unique:companies', 'first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'password' => 'min:5|max:20', 'new_password' => 'min:5|same:confirm_password'];
             }
         } else {
             if ($company->name == $name) {
                 return ['email' => 'required|email|unique:users', 'first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'password' => 'min:5|max:20', 'new_password' => 'min:5|same:confirm_password'];
             } else {
                 return ['name' => 'required|max:255|unique:companies', 'email' => 'required|email|unique:users', 'first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'password' => 'min:5|max:20', 'new_password' => 'min:5|same:confirm_password'];
             }
         }
     }
 }
开发者ID:villar88,项目名称:salesperformanceindicator,代码行数:32,代码来源:UpdateAndSaveCompany.php

示例2: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $project = \App\Project::findOrFail($id);
     $yearslist = \App\Year::lists('year', 'id');
     $companies = \App\Company::findOrFail($project->company_id);
     $officers_for_dropdown = \App\Officer::lists('last_name', 'id');
     return view('pages.project.edit', compact('project', 'companies', 'officers_for_dropdown', 'yearslist'));
 }
开发者ID:raulpulido,项目名称:p4,代码行数:14,代码来源:ProjectController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $company = Company::findOrFail($id);
     $this->validate($request, ['name' => 'required|unique:companies,name,' . $id . '|max:255']);
     $company->name = $request->input('name');
     $company->description = $request->input('description', "");
     $company->save();
     return redirect()->route('company.index');
 }
开发者ID:millwardesque,项目名称:GameCollection,代码行数:16,代码来源:CompanyController.php

示例4: destroy

 public function destroy($id)
 {
     $company = Company::findOrFail($id);
     $company->delete();
     session()->flash('flash_message_danger', 'Empresa borrada correctamente.');
     //        Si flash_message_important esta presente, el mensaje no desaparece hasta que el usuario lo cierre
     //        session()->flash('flash_message_important', true);
     return redirect('empresas');
 }
开发者ID:johanWP,项目名称:pandora,代码行数:9,代码来源:CompaniesController.php

示例5: methodToInvoke

 /**
  * @return company  The return value is suspended Company instance.
  */
 public function methodToInvoke($params)
 {
     // check does all parameters are sent
     $requiredParams = ['companyId'];
     $this->checkParameters($params, $requiredParams);
     $company = Company::findOrFail($params['companyId']);
     $company->suspend();
     $company->save();
     return $company;
 }
开发者ID:vukanac,项目名称:l5-admin-panel,代码行数:13,代码来源:ActionCommandSuspendCompanyReceiver.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $array_sale_order = ['name' => 'SO' . \DB::table('sale_orders')->max('id'), 'sale_order_time' => Input::get('sale_datetime'), 'subTotal' => Input::get('subtotal'), 'discount' => Input::get('discount'), 'total' => Input::get('total'), 'type' => Input::get('type'), 'partner_id' => Input::get('partner_id'), 'paymentMethod_id' => Input::get('paymentMethod_id')];
     $sale_order_id = SaleOrder::create($array_sale_order);
     $lines = sizeof(Input::get('sale_order_line_product_id'));
     $products_ids = Input::get('sale_order_line_product_id');
     $products_name_ids = Input::get('sale_order_line_name');
     $products_qty_ids = Input::get('sale_order_line_qty');
     $products_unitPrice_ids = Input::get('sale_order_line_unitPrice');
     $products_subTotal_ids = Input::get('sale_order_line_subtotal');
     for ($i = 0; $i < $lines; $i++) {
         $sale_line = ['name' => $products_name_ids[$i], 'qty' => $products_qty_ids[$i], 'unitPrice' => $products_unitPrice_ids[$i], 'subTotal' => $products_subTotal_ids[$i], 'sale_order_id' => $sale_order_id->id, 'product_id' => $products_ids[$i]];
         SaleOrderLine::create($sale_line);
     }
     $saleOrder = $sale_order_id;
     $company = Company::findOrFail(1);
     if (Input::get('type') === 'saleOrder') {
         return view('POS.partials.ticket_report', compact('saleOrder', 'company'));
     } else {
         return view('POS.partials.invoice', compact('saleOrder', 'company'));
     }
 }
开发者ID:raulbravo23,项目名称:salepoint,代码行数:27,代码来源:SaleOrdersController.php

示例7: ordered

 function ordered($date_from_user)
 {
     $arr = [];
     $date_from_user = new Carbon\Carbon($this->formated_date($date_from_user));
     if (!is_null($this->orders)) {
         foreach ($this->orders as $order) {
             $from = new Carbon\Carbon($this->formated_date($order->from));
             $to = new Carbon\Carbon($this->formated_date($order->to));
             if ($date_from_user->between($from, $to)) {
                 //$order = \App\Order::where('from', $from)->where('to', $to)->first();
                 $user = \App\User::findOrFail($order->user_id);
                 $name = $user->name;
                 $company = \App\Company::findOrFail($user->company_id);
                 $updated_time = $order->updated_at;
                 // return array('name'=>$name, 'updated_at'=>$updated_time->toDateTimeString(), 'company'=>$company->name);
                 array_push($arr, array('name' => $name, 'updated_at' => $updated_time->toDateTimeString(), 'company' => $company->name));
             }
         }
     }
     return $arr;
     //print_r($arr);
     //echo count($arr);
 }
开发者ID:soniczhangss,项目名称:Ordering-System,代码行数:23,代码来源:calendar.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     $company = Company::findOrFail($id);
     $company->delete();
     return redirect('company');
 }
开发者ID:emadv,项目名称:yellow-stone,代码行数:12,代码来源:CompanyController.php

示例9: update

 public function update($id, CompanyRequest $request)
 {
     $company = Company::findOrFail($id);
     $company->update($request->all());
 }
开发者ID:Garad,项目名称:project-new,代码行数:5,代码来源:CompaniesController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $user = User::findOrFail($id);
     $date = new \DateTime();
     //this returns the current date time
     //$dtStr = $date->format('Y-m-d-H-i-s');
     //$user->email = $dtStr . '_' . $user->email;
     $user->status = 'INACTIVE';
     $user->inactive_date = $date;
     $user->save();
     $user_role = Auth::user()->role->id;
     $users = $this->getActiveCompanyUsers(null);
     $message = 'You have successfully disabled ' . $user->last_name . ', ' . $user->first_name;
     if ($user_role == 1) {
         $company = Company::findOrFail(Auth::user()->company_id);
         return view('company.show', ['company' => $company, 'users' => $users, 'message' => $message]);
     } else {
         $keyword = '';
         \Session::flash('message', 'You have successfully disabled ' . $user->last_name . ', ' . $user->first_name);
         return Redirect::action('CompanyUserController@index');
     }
 }
开发者ID:villar88,项目名称:salesperformanceindicator,代码行数:28,代码来源:CompanyUserController.php

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     if (Auth::user()->hasRole('member')) {
         $id = Company::where('comUserId', '=', Auth::user()->id)->first()->comId;
     }
     $a = Company::findOrFail($id);
     if (!$a->validate(Input::all())) {
         return redirect('company/' . $id . '/edit')->withErrors($a->errors())->withInput();
     }
     $a->fill(Input::all());
     $a->save();
     Flash::success('Company is updated');
     return Redirect::to('company');
 }
开发者ID:e11en,项目名称:allocatie,代码行数:21,代码来源:CompanyController.php

示例12: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $company = Company::findOrFail($id);
     $company->delete();
     return redirect()->route('settings.company.index');
 }
开发者ID:raulbravo23,项目名称:salepoint,代码行数:12,代码来源:CompanysController.php

示例13: delete

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $company = Company::findOrFail($id);
     //goals
     DB::table('goal_managements')->whereIn('user_id', function ($query) use($company) {
         $query->select('id')->from('users')->whereRaw('users.company_id = ?', array($company->id));
     })->delete();
     //points
     DB::table('points')->where('company_id', '=', $company->id)->delete();
     //points_audit
     DB::table('point_audits')->where('company_id', '=', $company->id)->delete();
     //sales
     DB::table('sales')->where('company_id', '=', $company->id)->delete();
     //sales_audits
     DB::table('sale_audits')->where('company_id', '=', $company->id)->delete();
     //user_passwords
     DB::table('user_passwords')->whereIn('user_id', function ($query) use($company) {
         $query->select('id')->from('users')->whereRaw('users.company_id = ?', array($company->id));
     })->delete();
     //users
     DB::table('users')->where('company_id', '=', $company->id)->delete();
     //company
     DB::table('companies')->where('id', '=', $company->id)->delete();
     \Session::flash('message', 'You have successfully delete ' . $company->name);
     $keyword = '';
     $companies = Company::paginate(15);
     return view('company.list', compact('companies', 'keyword'));
 }
开发者ID:villar88,项目名称:salesperformanceindicator,代码行数:34,代码来源:CompanyController.php

示例14: tooltips

 /**
  * Return the tooltips in Json.
  *
  * @return Response
  */
 public function tooltips(Request $request)
 {
     $rp_arr = [];
     $user = \Auth::user();
     $data = $request->json()->get('data');
     if ($user->role->name == ('admin' or 'root')) {
         for ($i = 0; $i < count($data); $i++) {
             $location_id = \App\Location::where('name', $data[$i]['location'])->first()['id'];
             $from = Carbon::parse($data[$i]['from']);
             $to = Carbon::parse($data[$i]['to']);
             $orders = \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->get();
             $tooltip = '';
             for ($j = 0; $j < count($orders); $j++) {
                 $thisUser = \App\User::findOrFail($orders[$j]->user_id);
                 $company = \App\Company::findOrFail($thisUser->company_id);
                 if ($j != 0) {
                     $tooltip .= "\r\n";
                 }
                 $tooltip .= "Ordered by " . $thisUser->name . " from " . $company->name . " at " . $orders[$j]->created_at;
             }
             array_push($rp_arr, ['from' => \Carbon\Carbon::parse($from)->format('d-m-Y'), 'to' => \Carbon\Carbon::parse($to)->format('d-m-Y'), 'location' => $data[$i]['location'], 'tooltip' => $tooltip]);
         }
     } elseif ($user->role->name == 'staff') {
         for ($i = 0; $i < count($data); $i++) {
             $location_id = \App\Location::where('name', $data[$i]['location'])->first()['id'];
             $from = Carbon::parse($data[$i]['from']);
             $to = Carbon::parse($data[$i]['to']);
             $orders = \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->get();
             $tooltip = '';
             for ($j = 0; $j < count($orders); $j++) {
                 $thisUser = \App\User::findOrFail($orders[$j]->user_id);
                 if ($thisUser->company_id == $user->company_id) {
                     $company = \App\Company::findOrFail($thisUser->company_id);
                     if ($j != 0) {
                         $tooltip .= "\r\n";
                     }
                     $tooltip .= "Ordered by " . $thisUser->name . " from " . $company->name . " at " . $orders[$j]->created_at;
                 }
             }
             array_push($rp_arr, ['from' => \Carbon\Carbon::parse($from)->format('d-m-Y'), 'to' => \Carbon\Carbon::parse($to)->format('d-m-Y'), 'location' => $data[$i]['location'], 'tooltip' => $tooltip]);
         }
     }
     return response()->json(['data' => $rp_arr]);
 }
开发者ID:soniczhangss,项目名称:Ordering-System,代码行数:49,代码来源:PagesController.php

示例15: test_suspend_company_with_command_on_expiration_date

 public function test_suspend_company_with_command_on_expiration_date()
 {
     $expirationDate = new Carbon('2017-06-30');
     $company = factory(Company::class)->create();
     $user = factory(User::class, 'admin')->create();
     $this->actingAs($user)->visit('/company/' . $company->id . '/edit')->see($company->name)->see('name="licence_expire_at"')->type($expirationDate->toDateString(), 'licence_expire_at')->press('Save Edit')->seeInDatabase('companies', ['id' => $company->id, 'licence_expire_at' => $expirationDate->toDateString(), 'is_suspended' => false])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $company->id, 'run_at' => $expirationDate->toDateString(), 'action' => ActionCommandSuspendCompanyCommand::class]);
     // enter to testing time - set date to be expiration date
     Carbon::setTestNow($expirationDate);
     $company = Company::findOrFail($company->id);
     $this->assertEquals(false, $company->is_suspended);
     $results = \App\Model\ActionQueue\ActionCommandScheduled::run();
     $company = Company::findOrFail($company->id);
     $this->assertEquals(true, $company->is_suspended);
     // exit from testing time - reset current time
     Carbon::setTestNow();
 }
开发者ID:vukanac,项目名称:l5-admin-panel,代码行数:16,代码来源:CompanyLicenceManagementTest.php


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