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


PHP Sentinel::getUser方法代碼示例

本文整理匯總了PHP中Sentinel::getUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentinel::getUser方法的具體用法?PHP Sentinel::getUser怎麽用?PHP Sentinel::getUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sentinel的用法示例。


在下文中一共展示了Sentinel::getUser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //get currrnt user
     $user = \Sentinel::getUser();
     if ($user->inRole('coder')) {
         return $next($request);
     } else {
         return \Redirect::back()->with('message', 'You do not have the permission to access this page');
     }
 }
開發者ID:umahatokula,項目名稱:academia,代碼行數:17,代碼來源:Admin.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\Sentinel::check() || !\Sentinel::getUser()->inRole('admin')) {
         return redirect('/');
     }
     return $next($request);
 }
開發者ID:sergiovilar,項目名稱:marmitex,代碼行數:14,代碼來源:AdminMiddleware.php

示例3: __construct

 /**
  * Set the resource's model and validator.
  * @param ResourceServiceModelContract            $model           Resource's model
  * @param InputValidatorContract          $inputValidator  Resource's input validator
  */
 public function __construct(ResourceServiceModelContract $model, InputValidatorContract $inputValidator = null)
 {
     $this->model = $model;
     $this->inputValidator = $inputValidator;
     $this->user = new SentinelServiceUserAdapter(\Sentinel::getUser());
     // TODO: extract out
 }
開發者ID:skimia,項目名稱:api-fusion,代碼行數:12,代碼來源:ResourceService.php

示例4: index

 public function index()
 {
     $user = \Sentinel::getUser();
     if (Sentinel::hasAccess('admin')) {
         return view('admin.index');
     }
 }
開發者ID:ramigit3D,項目名稱:article,代碼行數:7,代碼來源:AdminController.php

示例5: logout

 public function logout()
 {
     $user = \Sentinel::getUser();
     \Sentinel::logout($user);
     event(new Logout($user->getUserId()));
     return redirect('/');
 }
開發者ID:tankerkiller125,項目名稱:newscms,代碼行數:7,代碼來源:AuthController.php

示例6: doLogin

 public function doLogin(Request $request)
 {
     // dd($request);
     //get the users credentials
     $credentials = ['login' => $request->email];
     //check if there is a match for the email and pword provided
     $user = \Sentinel::findByCredentials($credentials);
     //if there is no match redirect to login page ith input
     if (is_null($user)) {
         // dd($user);
         session()->flash('flash_message', 'Login failure.');
         session()->flash('flash_message_important', true);
         return \Redirect::back()->withInput();
     }
     //attempt to login
     $login = isset($request->remember_me) && $request->remember_me == 1 ? $user = \Sentinel::login($user) : ($user = \Sentinel::login($user));
     // store user info in session
     $user = \Sentinel::getUser();
     \Session::put('user', $user);
     //store user's role in session
     $roles = [];
     foreach ($user->roles as $role) {
         $roles[] = $role;
     }
     \Session::put('roles', $roles);
     //store session and term info in session
     $term_info = DB::table('current_term')->orderBy('created_at', 'desc')->first();
     if (null !== $term_info) {
         \Session::put(['current_session' => $term_info->session, 'current_term' => $term_info->term]);
     }
     return \Redirect::intended();
 }
開發者ID:umahatokula,項目名稱:academia,代碼行數:32,代碼來源:loginController.php

示例7: logout

 /**
  * Log a user out
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function logout()
 {
     $user = \Sentinel::getUser();
     \Sentinel::getUserRepository()->recordLogout($user);
     \Sentinel::logout();
     return redirect('/');
 }
開發者ID:brucewu16899,項目名稱:Core,代碼行數:11,代碼來源:AuthController.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //get currrnt user
     $user = \Sentinel::getUser();
     if ($user->inRole('admin_dept_officer')) {
         return $next($request);
     } else {
         session()->flash('flash_message', 'You do not have the permission to access this page');
         session()->flash('flash_message_important', true);
         return \Redirect::back();
     }
 }
開發者ID:umahatokula,項目名稱:academia,代碼行數:19,代碼來源:AdminDeptOfficer.php

示例9: boot

 /**
  * Set created_by and updated_by to the current logged in user
  */
 public static function boot()
 {
     parent::boot();
     $user = Sentinel::getUser();
     // Setup event bindings...
     static::creating(function ($model) use($user) {
         $model->created_by = $user->id;
         $model->updated_by = $user->id;
     });
     static::updating(function ($model) use($user) {
         $model->updated_by = $user->id;
     });
 }
開發者ID:EpykOS,項目名稱:epykosLittleHelper,代碼行數:16,代碼來源:BaseModel.php

示例10: is_admin

 /**
  * extending hieu-le/active function
  *
  * @param int $user_id
  *
  * @return bool
  */
 function is_admin($user_id = null)
 {
     if ($user_id) {
         $user = Sentinel::findById($user_id);
     } else {
         if (Sentinel::check()) {
             $user = Sentinel::getUser();
         } else {
             return false;
         }
     }
     $admin = Sentinel::findRoleByName('Administrator');
     return $user && $user->inRole($admin);
 }
開發者ID:joonas-yoon,項目名稱:acm-oj,代碼行數:21,代碼來源:helpers.php

示例11: createOrUpdate

 public function createOrUpdate(Product $product)
 {
     if ($product === null) {
         return null;
     }
     $product->save();
     if (\Request::input('note')) {
         $note = new Note();
         $note->note = \Request::input('note');
         $note->user_id = \Sentinel::getUser()->id;
         $note->created_by = \Sentinel::getUser()->id;
         $note->reference_type = 'articles';
         $note->reference_id = $product->id;
         $note->save();
     }
     return $product;
 }
開發者ID:botble,項目名稱:product,代碼行數:17,代碼來源:ProductRepository.php

示例12: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->register('ErenMustafaOzdal\\LaravelUserModule\\LaravelUserModuleComposerServiceProvider');
     $this->app->register('ErenMustafaOzdal\\LaravelModulesBase\\LaravelModulesBaseServiceProvider');
     $this->mergeConfigFrom(__DIR__ . '/../config/laravel-user-module.php', 'laravel-user-module');
     // merge default configs with publish configs
     $this->mergeDefaultConfig();
     $router = $this->app['router'];
     $router->middleware('guest', \ErenMustafaOzdal\LaravelUserModule\Http\Middleware\RedirectIfAuthenticated::class);
     $router->middleware('auth', \ErenMustafaOzdal\LaravelUserModule\Http\Middleware\Authenticate::class);
     // model binding
     $router->bind(config('laravel-user-module.url.user'), function ($id) {
         $user = \App\User::findOrFail($id);
         if (config('laravel-user-module.non_visibility.super_admin') && !\Sentinel::getUser()->is_super_admin && $user->is_super_admin) {
             abort(403);
         }
         return $user;
     });
     $router->model(config('laravel-user-module.url.role'), 'App\\Role');
     $router->model('role', 'App\\Role');
 }
開發者ID:erenmustafaozdal,項目名稱:laravel-user-module,代碼行數:26,代碼來源:LaravelUserModuleServiceProvider.php

示例13: postEdit

 /**
  * Insert new Article into database
  *
  * @return Response Redirect
  */
 public function postEdit($id, ProductRequest $request)
 {
     $product = $this->productRepository->findById($id);
     $product->fill($request->all());
     if ($request->input('featured') == null) {
         $product->featured = false;
     }
     $product = $this->productRepository->createOrUpdate($product);
     $this->registerMediaLibraryProcessing($product);
     $tags = $product->tags->lists('name')->all();
     if (implode(',', $tags) !== $request->get('tag')) {
         $product->tags()->detach();
         $tagInputs = explode(',', $request->get('tag'));
         foreach ($tagInputs as $tagName) {
             $tag = $this->tagRepository->findByName($tagName);
             if ($tag === null) {
                 $tag = new Tag();
                 $tag->name = $tagName;
                 $tag->user_id = \Sentinel::getUser()->id;
                 $tag = $this->tagRepository->createOrUpdate($tag, $request);
             }
             $product->tags()->attach($tag->id);
         }
     }
     event(new AuditHandlerEvent('Product', 'updated', $product->id));
     \Cache::forget('home_widget_featured');
     if ($request->get('submit') === 'save') {
         return redirect()->route('products.list')->with('success_msg', trans('notices.update_success_message'));
     } elseif ($request->get('submit') === 'apply') {
         return redirect()->route('products.edit', $id)->with('success_msg', trans('notices.update_success_message'));
     }
 }
開發者ID:botble,項目名稱:product,代碼行數:37,代碼來源:ProductController.php

示例14: getOps

 /**
  * get operation buttons
  *
  * @param \Illuminate\Support\Collection $model
  * @param string $currentPage
  * @param boolean $isPublishable
  * @param \Illuminate\Support\Collection|null $relatedModel
  * @param string $modelRouteRegex
  * @return string
  */
 function getOps($model, $currentPage, $isPublishable = false, $relatedModel = null, $modelRouteRegex = '')
 {
     $routeName = snake_case(class_basename($model));
     $routeParams = ['id' => $model->id];
     if (!is_null($relatedModel)) {
         $routeName = snake_case(class_basename($relatedModel)) . '.' . $routeName;
         $routeParams = ['id' => $relatedModel->id, $modelRouteRegex => $model->id];
     }
     $ops = Form::open(['method' => 'DELETE', 'url' => lmbRoute("admin.{$routeName}.destroy", $routeParams), 'style' => 'margin:0', 'id' => "destroy_form_{$model->id}"]);
     // edit buton
     if ($currentPage !== 'edit') {
         $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.show") ? "admin.{$routeName}.show#####" . $relatedModel->id : "admin.{$routeName}.edit";
         if ($routeName === 'user' && $model->id === Sentinel::getUser()->id || hasPermission($hackedRoute)) {
             $ops .= '<a href="' . lmbRoute("admin.{$routeName}.edit", $routeParams) . '" class="btn btn-sm btn-outline yellow margin-right-10">';
             $ops .= '<i class="fa fa-pencil"></i>';
             $ops .= '<span class="hidden-xs">';
             $ops .= trans('laravel-modules-core::admin.ops.edit');
             $ops .= '</span>';
             $ops .= '</a>';
         }
     }
     // show buton
     if ($currentPage !== 'show') {
         $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.show") ? "admin.{$routeName}.show#####" . $relatedModel->id : "admin.{$routeName}.show";
         if ($routeName === 'user' && $model->id === Sentinel::getUser()->id || hasPermission($hackedRoute)) {
             $ops .= '<a href="' . lmbRoute("admin.{$routeName}.show", $routeParams) . '" class="btn btn-sm btn-outline green margin-right-10">';
             $ops .= '<i class="fa fa-search"></i>';
             $ops .= '<span class="hidden-xs">';
             $ops .= trans('laravel-modules-core::admin.ops.show');
             $ops .= '</span>';
             $ops .= '</a>';
         }
     }
     // silme butonu
     $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.destroy") ? "admin.{$routeName}.destroy#####" . $relatedModel->id : "admin.{$routeName}.destroy";
     if (hasPermission($hackedRoute)) {
         if ($routeName !== 'user' || $model->id !== Sentinel::getUser()->id) {
             $ops .= '<button type="submit" onclick="bootbox.confirm( \'' . trans('laravel-modules-core::admin.ops.destroy_confirmation') . '\', function(r){if(r) $(\'#destroy_form_' . $model->id . '\').submit();}); return false;" class="btn btn-sm red btn-outline margin-right-10">';
             $ops .= '<i class="fa fa-trash"></i>';
             $ops .= '<span class="hidden-xs">';
             $ops .= trans('laravel-modules-core::admin.ops.destroy');
             $ops .= '</span>';
             $ops .= '</button>';
         }
     }
     // yayınlama veya yayından kaldırma butonu
     if ($isPublishable) {
         // yayından kaldırma
         if ($model->is_publish) {
             $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.notPublish") ? "admin.{$routeName}.notPublish#####" . $relatedModel->id : "admin.{$routeName}.notPublish";
             if (hasPermission($hackedRoute)) {
                 $ops .= '<a href="' . lmbRoute("admin.{$routeName}.notPublish", $routeParams) . '" class="btn btn-sm btn-outline purple margin-right-10">';
                 $ops .= '<i class="fa fa-times"></i>';
                 $ops .= '<span class="hidden-xs">';
                 $ops .= trans('laravel-modules-core::admin.ops.not_publish');
                 $ops .= '</span>';
                 $ops .= '</a>';
             }
         } else {
             $hackedRoute = !is_null($relatedModel) && routeHackable("admin.{$routeName}.publish") ? "admin.{$routeName}.publish#####" . $relatedModel->id : "admin.{$routeName}.publish";
             if (hasPermission($hackedRoute)) {
                 $ops .= '<a href="' . lmbRoute("admin.{$routeName}.publish", $routeParams) . '" class="btn btn-sm btn-outline blue margin-right-10">';
                 $ops .= '<i class="fa fa-bullhorn"></i>';
                 $ops .= '<span class="hidden-xs">';
                 $ops .= trans('laravel-modules-core::admin.ops.publish');
                 $ops .= '</span>';
                 $ops .= '</a>';
             }
         }
     }
     $ops .= Form::close();
     return $ops;
 }
開發者ID:erenmustafaozdal,項目名稱:laravel-modules-core,代碼行數:83,代碼來源:helpers.php

示例15:

@extends('app')

@section('container')
    
    <div class="vd_content-section clearfix">
        <div class="row">
            <div class="col-sm-3">
                <div class="panel widget light-widget panel-bd-top">
                    <div class="panel-heading no-title"> </div>
                        <div class="panel-body">
                            <div class="text-center vd_info-parent"> <img src="/images/blog/avatar3.png"> </div>
                                
                                <?php 
$user = \Sentinel::getUser();
?>
                                <h2 class="font-semibold mgbt-xs-5">{{ $user->first_name . $user->last_name  }}</h2>
                                
                            <div class="mgtp-20">
                                <table class="table table-striped table-hover">
                                    <tbody>
                                        <tr>
                                            <td style="width:60%;">Status</td>
                                            @if (Activation::completed($user))
                                            <td><span class="label label-success">Active</span></td>
                                            @endif
                                        </tr>
                                        
                                        <tr>
                                            <td>Member Since</td>
                                            <td> {{ Carbon\Carbon::parse($user->created_at)->format('d-m-Y')  }} </td>
                                        </tr>
開發者ID:ramigit3D,項目名稱:article,代碼行數:31,代碼來源:password.blade.php


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