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


PHP Entrust类代码示例

本文整理汇总了PHP中Entrust的典型用法代码示例。如果您正苦于以下问题:PHP Entrust类的具体用法?PHP Entrust怎么用?PHP Entrust使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isAdmin

 public static function isAdmin()
 {
     if (!Entrust::hasRole('admin')) {
         return false;
     }
     return true;
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:7,代码来源:helper.php

示例2: index

 /**
  * Display a listing of rateinquiries
  *
  * @return Response
  */
 public function index()
 {
     //RateInquiry::where('viewed', 0)->where('status', 1)->update(array('viewed'=> 1));
     $from = null;
     $to = null;
     if (Input::has('search')) {
         //dd(Input::all());
         $from = Input::get('from');
         $to = Input::get('to');
         if (Entrust::hasRole('Admin')) {
             $user_id = Input::get('agent_id');
             $rateinquiries = RateInquiry::whereHas('user', function ($q) use($user_id) {
                 $q->where('users.id', 'like', '%' . $user_id . '%');
             });
         } elseif (Entrust::hasRole('Agent')) {
             $rateinquiries = RateInquiry::whereHas('user', function ($q) {
                 $q->where('users.id', '=', Auth::id());
             });
         }
         if (!empty($from) && !empty($to)) {
             $rateinquiries = $rateinquiries->where('from', '>=', $from)->where('to', '<=', $to);
         }
         $rateinquiries = $rateinquiries->get();
     } else {
         if (Entrust::hasRole('Admin')) {
             $rateinquiries = RateInquiry::orderBy('updated_at', 'desc')->get();
         } elseif (Entrust::hasRole('Agent')) {
             $rateinquiries = RateInquiry::where('user_id', Auth::id())->orderBy('updated_at', 'desc')->get();
         }
     }
     return View::make('inquiries.rate-inquiries.index', compact('rateinquiries', 'user_id', 'from', 'to'));
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:37,代码来源:RateInquiriesController.php

示例3: postSchimbaStadiu

 public function postSchimbaStadiu($id_livrabil)
 {
     $actualizare_ore = Input::get('ore_lucrate') > 0;
     $is_stadiu = Input::get('stadiu_selectionat') != null && Input::get('stadiu_selectionat') > 0;
     $array_update = array();
     if ($is_stadiu) {
         //Face insert in tabela de istoric de stadii
         //Actualizeaza stadiul livrabilului
         $array_update = array_add($array_update, 'id_stadiu', Input::get('stadiu_selectionat'));
     }
     if ($actualizare_ore) {
         //Actualizeaza numarul de ore lucrate la acest livrabil
         $array_update = array_add($array_update, 'ore_lucrate', Input::get('ore_lucrate'));
     }
     // Start transaction!
     DB::beginTransaction();
     if ($is_stadiu) {
         try {
             DB::table('istoric_stadii_livrabil')->insertGetId(array('id_livrabil_etapa' => Input::get('id_livrabil_etapa'), 'id_stadiu' => Input::get('stadiu_selectionat'), 'id_user' => Entrust::user()->id));
         } catch (Exception $e) {
             DB::rollback();
             return Redirect::back()->with('message', 'Eroare salvare date: ' . $e);
         }
     }
     if ($is_stadiu || $actualizare_ore) {
         try {
             DB::table('livrabile_etapa')->where('id', Input::get('id_livrabil_etapa'))->update($array_update);
         } catch (Exception $e) {
             DB::rollback();
             return Redirect::back()->with('message', 'Eroare salvare date: ' . $e);
         }
     }
     DB::commit();
     return Redirect::back()->with('message', 'Actualizare realizata cu succes!')->withInput();
 }
开发者ID:binaryk,项目名称:lareab,代码行数:35,代码来源:StadiuLivrabilController.php

示例4: allowed

 public function allowed($sAction = null, $sRole = null)
 {
     if (static::isAdmin() || \Entrust::hasRole('admin') || \Entrust::can($sAction) || \Entrust::hasRole($sRole)) {
         return true;
     }
     return false;
 }
开发者ID:laravel-blog,项目名称:laravel51-sandbox,代码行数:7,代码来源:Helper.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (\Auth::check() && !\Entrust::hasRole($role)) {
         return redirect()->back();
     }
     return $next($request);
 }
开发者ID:alkzzz,项目名称:mycms,代码行数:14,代码来源:RoleMiddleware.php

示例6: getCreditLimit

 public static function getCreditLimit($agent_id)
 {
     if (Entrust::hasRole('Agent')) {
         return Agent::where('user_id', $agent_id)->first()->credit_limit;
     }
     return false;
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:7,代码来源:Agent.php

示例7: __construct

 public function __construct()
 {
     $this->middleware('auth');
     // Check for the right roles to access these pages
     if (!\Entrust::can('view-admin-panel')) {
         abort(403, 'Unauthorized access - you do not have the necessary role to see this page.');
     }
 }
开发者ID:tahirghori,项目名称:dick,代码行数:8,代码来源:AdminController.php

示例8: __construct

 public function __construct()
 {
     $this->data['crud'] = $this->crud;
     // Check for the right roles to access these pages
     if (!\Entrust::can('view-admin-panel')) {
         abort(403, trans('crud.unauthorized_access'));
     }
 }
开发者ID:hramose,项目名称:crud,代码行数:8,代码来源:CrudController.php

示例9: userHasAgent

 public static function userHasAgent()
 {
     if (Entrust::hasRole('Agent')) {
         if ($x = User::getAgentOfUser(Auth::user())) {
             return Agent::with('market')->find($x->agent_id);
         }
     }
     return false;
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:9,代码来源:User.php

示例10: inicio

 /**
  * Funcion que retorna la vista de inicio del modulo de Equipo, esta retorna la vista con los datos
  * @param Request $request - variable interna que controla los elementos de la vista para obtner su valor
  * @return $this
  */
 public function inicio(Request $request)
 {
     if (!\Entrust::can('crud-empleados')) {
         return \Redirect::to('/');
     } else {
         $registros = \DB::table('users')->join('role_user', 'users.id', '=', 'user_id')->join('roles', 'roles.id', '=', 'role_id')->where('users.type', '=', 0)->select('users.id AS id_usuario', 'users.name AS nombre_usuario', 'users.email', 'users.avatar', 'roles.display_name')->orderBy('roles.display_name', 'asc')->paginate(6);
         return view('Center.empleados.ver')->with('registros', $registros);
     }
 }
开发者ID:JFSolorzano,项目名称:Acordes,代码行数:14,代码来源:EmpleadosCtrl.php

示例11: inicio

 public function inicio(Request $request)
 {
     if (!\Entrust::can('crud-promociones')) {
         return \Redirect::to('/');
     } else {
         $registros = Promociones::buscar($request->get('parametros'))->orderBy('nombre', 'desc')->paginate(6);
         return view('Center.promociones.ver')->with('registros', $registros);
     }
 }
开发者ID:JFSolorzano,项目名称:Acordes,代码行数:9,代码来源:PromocionesCtrl.php

示例12: __construct

 public function __construct()
 {
     $this->_user = Auth::user();
     $this->_parameters = Route::current()->parameters();
     if (!User::hasHotelPermission($this->_user, $this->_parameters['hotels'])) {
         if (!Entrust::hasRole('Admin')) {
             App::abort(403);
         }
     }
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:10,代码来源:SupplementRatesController.php

示例13: index

 /**
  * Display a listing of xcasts
  *
  * @return Response
  */
 public function index()
 {
     $search = Request::get('q');
     $xcasts = $search ? Xcast::search($search) : Xcast::latest('updated_at');
     if (!Entrust::can('manage_premium_casts') && !Entrust::can('delete_casts')) {
         $xcasts = $xcasts->onlyFree();
     }
     $xcasts = $xcasts->paginate(8);
     return View::make('admin.xcasts.index', compact('xcasts'));
 }
开发者ID:xfyuan,项目名称:xemecasts,代码行数:15,代码来源:XcastsController.php

示例14: destroy

 public function destroy(Comment $comment)
 {
     if ($comment->user_id != Auth::user()->id && !Entrust::hasRole('admin')) {
         return redirect()->back()->withErrors(config('constants.INVALID_LINK'));
     }
     $belongs_to = $comment->belongs_to;
     $comment->delete();
     $activity = 'Deleted a commented on a ' . ucfirst($belongs_to);
     Activity::log($activity);
     return redirect()->back()->withSuccess(config('constants.DELETED'));
 }
开发者ID:EneaWeb,项目名称:aliangel,代码行数:11,代码来源:CommentController.php

示例15: getInDebugModeAttribute

 public function getInDebugModeAttribute()
 {
     //限管理員
     if (!\Entrust::hasRole('admin')) {
         return false;
     }
     if (!$this->debug) {
         return false;
     }
     return true;
 }
开发者ID:alhs1995,项目名称:DBFP,代码行数:11,代码来源:User.php


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