本文整理汇总了PHP中Illuminate\Support\Facades\Auth::admin方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::admin方法的具体用法?PHP Auth::admin怎么用?PHP Auth::admin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::admin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if ($this->route('users') == Auth::admin()->get()->id) {
return false;
}
return true;
}
示例2: getCanceled
/**
* Get the canceled order numbers
*
* @param $state
* @param null $orderNumber
* @return mixed
*/
public static function getCanceled($state, $orderNumber = null, $page)
{
$perPage = 10;
$companyIds = [];
if (Auth::admin()->check()) {
$companyIds = Company::all()->lists('id')->toArray();
} elseif (Auth::user()->check()) {
$companyIds = [Auth::user()->get()->company->id];
}
$query = DB::table('canceled_orders')->whereIn('company_id', $companyIds)->take($perPage)->skip($perPage * ($page - 1));
switch ($state) {
case 'unconfirmed':
$query = $query->where('confirmed', false)->where('denied', false);
break;
case 'confirmed':
$query = $query->where('confirmed', true);
break;
case 'denied':
$query = $query->where('denied', true)->where('confirmed_denied', false);
break;
}
if ($orderNumber) {
$query = $query->where('order_number', $orderNumber);
}
return $query->lists('order_number');
}
示例3: loginAs
/**
* Login as the
*
* @param $companyId
* @return \Illuminate\Http\RedirectResponse
*/
public function loginAs($companyId)
{
$company = Company::findOrFail($companyId);
$user = $company->users()->first();
Auth::admin()->impersonate('user', $user->id);
return redirect()->route('user.dashboard');
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->check()) {
return redirect()->guest('backend');
}
return $next($request);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->check()) {
return $next($request);
}
return redirect()->route('admin.login');
}
示例6: handle
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string $role
* @return mixed
*/
public function handle($request, Closure $next, $permissionName)
{
$permission = Permission::where('name', $permissionName)->first();
if (!Auth::admin()->user()->hasPermission($permission)) {
abort(403);
}
return $next($request);
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->get()) {
return $next($request);
} else {
return redirect()->guest('admin');
}
}
示例8: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
Auth::admin()->login($this->create($request->all()));
return redirect($this->redirectadminPath());
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::other()->check()) {
return back();
}
if (Auth::admin()->check()) {
return back();
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->get()) {
if ($request->ajax()) {
return response('Authorized.', 403);
} else {
return redirect()->route('lara-mvcms.dashboard');
}
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::admin()->get()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->route('lara-mvcms.sessions.create');
}
}
return $next($request);
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect('auth/login');
}
}
return $next($request);
}
示例13: login
public function login(Form $form)
{
$request = $form->request->all();
if (!Auth::admin()->logAttempt($request, $mustBeConfirmed = false)) {
if (Auth::admin()->isThrottled($request)) {
$error = trans('account.alerts.too_many_attempts');
} else {
$error = trans('account.alerts.wrong_credentials');
}
Message::addError($error);
throw new \Exception($error);
}
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
}
return redirect()->guest('admin/login');
}
// Bind the Backend Kernel to our request
// todo find a better place to register our backend form kernel
app()->singleton('Lavender\\Contracts\\Form\\Kernel', 'App\\Form\\BackendKernel');
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::admin()->check()) {
return back();
}
if (Auth::other()->check()) {
return back();
}
if (Auth::user()->check()) {
return redirect('userdashboard');
}
return $next($request);
}