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


PHP Language::findOrFail方法代码示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  * PUT /languages/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $language = Language::findOrFail($id);
     $this->validate($request, Language::$rules);
     $language->update($request->all());
     return redirect('languages')->with('success', l('This record has been successfully updated &#58&#58 (:id) ', ['id' => $id], 'layouts') . $request->get('name'));
 }
开发者ID:rogerapras,项目名称:aBillander,代码行数:14,代码来源:LanguagesController.php

示例2: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // bind article
     $router->model('article', 'App\\Article');
     $router->bind('admin.article', function ($id) {
         return \App\Article::findOrFail($id);
     });
     // bind category
     $router->model('category', 'App\\Category');
     $router->bind('admin.category', function ($id) {
         return \App\Category::findOrFail($id);
     });
     // bind language
     $router->model('language', 'App\\Language');
     $router->bind('admin.language', function ($id) {
         return \App\Language::findOrFail($id);
     });
     // bind language
     $router->model('page', 'App\\Page');
     $router->bind('admin.page', function ($id) {
         return \App\Page::findOrFail($id);
     });
     // bind setting
     $router->model('setting', 'App\\Setting');
     $router->bind('admin.setting', function ($id) {
         return \App\Setting::findOrFail($id);
     });
     // bind user
     $router->model('user', 'App\\User');
     $router->bind('admin.user', function ($id) {
         return \App\User::findOrFail($id);
     });
     parent::boot($router);
 }
开发者ID:abada,项目名称:laravel-5-simple-cms,代码行数:40,代码来源:RouteServiceProvider.php

示例3: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $language = Language::findOrFail($id);
     return view('languages.show', ['language' => $language, 'languages' => Language::all()]);
 }
开发者ID:alexpcoleman,项目名称:fitl,代码行数:11,代码来源:LanguageController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $language = Language::findOrFail($id);
     $language->delete();
     return redirect()->route('admin.languages.index')->with('message', '<div class="alert alert-info">The language was deleted.</div>');
 }
开发者ID:alexpcoleman,项目名称:fitl,代码行数:12,代码来源:LanguageController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $language = Language::findOrFail($id);
     $language->city()->detach();
     $language->delete();
     $statusCode = 200;
     $response = ["success" => "Language {$id} successfully destroyed"];
     return response($response, $statusCode);
 }
开发者ID:mudragel,项目名称:matematika-test.loc,代码行数:16,代码来源:LanguageController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id, Request $request)
 {
     $language = Language::findOrFail($id);
     $language->delete();
     if ($request->ajax()) {
         return "El idioma " . $language->Name . " se ha eliminado correctamente.";
     }
 }
开发者ID:serranozafra,项目名称:pruebaHectorSerrano,代码行数:14,代码来源:LanguageController.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     /*
     |--------------------------------------------------------------------------
     | Application Configuration
     |--------------------------------------------------------------------------
     |
     | Load Configuration Keys.
     |
     */
     Configuration::loadConfiguration();
     if (Auth::check()) {
         $user = User::with('language')->find(Auth::id());
         // $email = Auth::user()->email;
         $language = $user->language;
     } else {
         $user = NULL;
         $language = Language::find(intval(Request::cookie('user_language')));
         if (!$language) {
             $language = Language::findOrFail(intval(Configuration::get('DEF_LANGUAGE')));
         }
     }
     $company = Company::with('currency')->findOrFail(intval(Configuration::get('DEF_COMPANY')));
     Context::getContext()->user = $user;
     Context::getContext()->language = $language;
     Context::getContext()->company = $company;
     Context::getContext()->currency = $company->currency;
     Context::getContext()->controller = $request->segment(1);
     if ($request->segment(3) == 'attributes') {
         Context::getContext()->controller = $request->segment(3);
     }
     Context::getContext()->action = NULL;
     //$action;
     /* * /
     		// echo_r($request->route()->getAction());
     		// http://laravel.io/forum/10-15-2014-laravel-5-passing-parameters-to-middleware-handlers
     		// http://www.codeheaps.com/php-programming/laravel-5-middleware-stack-decoded/
     		// http://blog.elliothesp.co.uk/coding/passing-parameters-middleware-laravel-5/
     		// https://gist.github.com/dwightwatson/6200599
     		// http://stackoverflow.com/questions/26840278/laravel-5-how-to-get-route-action-name
     		    $action = $request->route()->getAction();
     		    $routeArray = Str::parseCallback($action['controller'], null);
     
     		    if (last($routeArray) != null) {
     		        // Remove 'controller' from the controller name.
     		        $controller = str_replace('Controller', '', class_basename(head($routeArray)));
     
     		        // Take out the method from the action.
     		        $action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', last($routeArray));
     
     		        // return Str::slug($controller . '-' . $action);
     		    } else {
     		        // return 'closure';
     		        $controller = 'closure';
     		        $action = '';
     		    }
     		// gist ENDS
     
     		Context::getContext()->controller = $controller;
     		Context::getContext()->action     = $action; 
     		echo Str::slug($controller . '-' . $action);
     / * */
     // Changing Timezone At Runtime. But this change does not seem to be taken by Carbon... Why?
     Config::set('app.timezone', Configuration::get('TIMEZONE'));
     // Changing The Default Language At Runtime
     App::setLocale(Context::getContext()->language->iso_code);
     return $next($request);
 }
开发者ID:rogerapras,项目名称:aBillander,代码行数:75,代码来源:SetContextMiddleware.php

示例8: setLanguage

 /**
  * Update DEFAULT language (application wide, not logged-in usersS).
  *
  * @return Response
  */
 public function setLanguage($id)
 {
     $language = \App\Language::findOrFail($id);
     Cookie::queue('user_language', $language->id, 5 * 24 * 60);
     return redirect('/');
 }
开发者ID:rogerapras,项目名称:aBillander,代码行数:11,代码来源:WelcomeController.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $lang = Language::findOrFail($id)->delete();
     return Redirect::route('admin.setup.qualification.languages.index')->withFlashSuccess('Language data was successfully deleted.');
 }
开发者ID:krizzna,项目名称:hrportal,代码行数:11,代码来源:LanguageController.php


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