本文整理汇总了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;
}
示例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'));
}
示例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();
}
示例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;
}
示例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);
}
示例6: getCreditLimit
public static function getCreditLimit($agent_id)
{
if (Entrust::hasRole('Agent')) {
return Agent::where('user_id', $agent_id)->first()->credit_limit;
}
return false;
}
示例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.');
}
}
示例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'));
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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'));
}
示例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'));
}
示例15: getInDebugModeAttribute
public function getInDebugModeAttribute()
{
//限管理員
if (!\Entrust::hasRole('admin')) {
return false;
}
if (!$this->debug) {
return false;
}
return true;
}