当前位置: 首页>>代码示例>>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;未经允许,请勿转载。