本文整理汇总了PHP中Illuminate\Auth\Guard类的典型用法代码示例。如果您正苦于以下问题:PHP Guard类的具体用法?PHP Guard怎么用?PHP Guard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created snippet in storage.
*
* @param SnippetsRequest $request
* @return Response
*/
public function store(SnippetsRequest $request, Guard $auth)
{
$data = ['user_id' => $auth->user() ? $auth->user()->id : null];
$snippet = $this->dispatchFrom(StoreNewSnippetCommand::class, $request, $data);
flash('Snippet was successfully created.');
return redirect()->route('snippets.show', $snippet->slug->slug);
}
开发者ID:elvios,项目名称:darkshare,代码行数:13,代码来源:SnippetsController.php
示例2: store
/**
* Create new Income Service
*
* @param IncomeServiceRequest $request
* @param Guard $guard
* @param Response $response
* @param Gate $gate
* @return ItemResponse|\Symfony\Component\HttpFoundation\Response
*/
public function store(IncomeServiceRequest $request, Guard $guard, Response $response, Gate $gate)
{
if (!$gate->check('putPostDelete', new IncomeService())) {
return $response->setContent('Unauthorized')->setStatusCode(401);
}
return new ItemResponse($this->dispatch(new CreateIncomeServiceCommand($request->get('service_id'), $request->get('service_date'), $guard->user()->id, 3, 'status')));
}
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:16,代码来源:IncomeServicesController.php
示例3: collections
public function collections(Collection $collection, Guard $guard)
{
$collections = $collection->with(['votes' => function ($query) {
$query->select('collection_user_vote.vote', 'collection_user_vote.user_id');
}, 'user' => function ($query) {
$query->select('users.id', 'users.name');
}, 'blueprints' => function ($query) {
$query->select('blueprint.id', 'blueprint.name');
}])->paginate(8);
$collectionsAsArray = $collections->toArray()['data'];
foreach ($collectionsAsArray as $key => $value) {
if (!empty($value['votes'])) {
$totalVotes = 0;
foreach ($value['votes'] as $vote) {
// get total number of votes
$totalVotes += $vote['vote'];
// check if the current user has voted
if ($guard->check()) {
if ($vote['user_id'] == $guard->user()->getAuthIdentifier()) {
$collectionsAsArray[$key]['user_has_voted'] = true;
$collectionsAsArray[$key]['user_vote'] = $vote['vote'];
}
}
}
$collectionsAsArray[$key]['total_votes'] = $totalVotes;
} else {
$collectionsAsArray[$key]['user_has_voted'] = false;
$collectionsAsArray[$key]['total_votes'] = 0;
}
}
return view('buildcraft.collections')->with(['collections' => $collections, 'collectionsAsArray' => $collectionsAsArray]);
}
开发者ID:JunkyPic,项目名称:Minecraft-Files,代码行数:32,代码来源:CollectionController.php
示例4: getWardrobeAuth
public function getWardrobeAuth()
{
$provider = $this->createEloquentProvider();
$guard = new Guard($provider, App::make('session.store'), App::make('request'));
$guard->setCookieJar(App::make('cookie'));
return $guard;
}
开发者ID:sekouzed,项目名称:core,代码行数:7,代码来源:Wardrobe.php
示例5: handle
/**
* Handle the command.
*
* @param Guard $auth
*/
public function handle(Guard $auth)
{
/* @var UserInterface|null $user */
$user = $auth->user();
/* @var PageInterface $page */
foreach ($this->pages as $key => $page) {
$roles = $page->getAllowedRoles();
/**
* If there are role restrictions
* but no user is signed in then
* we can't authorize anything!
*/
if (!$roles->isEmpty() && !$user) {
$this->pages->forget($key);
continue;
}
/**
* If there are role restrictions
* and the user does not belong to
* any of them then don't show it.
*/
if (!$roles->isEmpty() && !$user->hasAnyRole($roles)) {
$this->pages->forget($key);
continue;
}
}
}
开发者ID:AkibaTech,项目名称:pages-module,代码行数:32,代码来源:RemoveRestrictedPages.php
示例6: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(Guard $auth)
{
view()->composer(array('partials.navbar', 'runs.edit', 'index'), function ($view) use($auth) {
$view->with('currentUserSuper', $auth->user()->super);
// does what you expect
});
}
开发者ID:famorted,项目名称:seqtrack,代码行数:12,代码来源:AppServiceProvider.php
示例7: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(Guard $auth, Request $request)
{
//
view()->composer('*', function ($view) use($auth, $request) {
$uri = $request->path();
$uri = explode("/", $uri);
$breadcrumb = "<li>Home</li>";
$stopped = false;
$menuPath = "";
foreach ($uri as $segment) {
if (is_numeric($segment)) {
$stopped = true;
} else {
$breadcrumb .= "<li>" . ucfirst($segment) . "</li>";
if (!$stopped) {
$menuPath = $menuPath . "/" . $segment;
}
}
}
$allSites = array();
foreach (Site::orderBy('name', 'ASC')->get() as $site) {
$allSites[$site->id] = $site->name;
}
$view->with('user', $auth->user())->with('breadcrumb', $breadcrumb)->with('menupath', $menuPath)->with('siteList', $allSites);
});
view()->composer('modals.pressJob', function ($view) use($auth, $request) {
$presses = \App\Press::where('site_id', session('site'))->get();
$view->with('presses', $presses);
});
}
开发者ID:jhansen69,项目名称:MangoV2,代码行数:35,代码来源:ViewComposerServiceProvider.php
示例8: index
public function index(Guard $guard)
{
if (!$guard->guest()) {
return redirect(route('app.dashboard.index'));
}
return view('layouts.login.index');
}
开发者ID:andersonef,项目名称:RestoApp,代码行数:7,代码来源:AuthController.php
示例9: logout
/**
* Log the user out.
*
* @param UserAuthenticator $authenticator
* @param Guard $auth
* @return \Illuminate\Http\RedirectResponse|Redirector
*/
public function logout(UserAuthenticator $authenticator, Guard $auth)
{
if (!$auth->guest()) {
$authenticator->logout();
}
$this->messages->success('anomaly.module.users::message.logged_out');
return redirect('admin/login');
}
开发者ID:AkibaTech,项目名称:users-module,代码行数:15,代码来源:LoginController.php
示例10: postProfile
public function postProfile(Request $request, Guard $auth)
{
if ($auth->user()->getAuthIdentifier() == $request->get($this->model->getKeyName())) {
$this->postEdit($request);
return $this->getProfile($auth);
}
abort(403, trans('permission-util::errors.unthorized'));
}
开发者ID:budiprasetyo,项目名称:Expendable,代码行数:8,代码来源:UserController.php
示例11: __construct
/**
* @param CommentContract $comment
* @param Guard $auth
* @param CommentService $commentService
* @param ReportService $report
*/
public function __construct(CommentContract $comment, Guard $auth, CommentService $commentService, ReportService $report)
{
$this->middleware('auth', ['only' => 'vote']);
$this->currentUser = $auth->user();
$this->comment = $comment;
$this->commentService = $commentService;
$this->report = $report;
}
开发者ID:vjaykoogu,项目名称:smile-media-laravel,代码行数:14,代码来源:CommentsController.php
示例12: logout
/**
* Logout the active user.
*
* @param UserAuthenticator $authenticator
* @param Guard $auth
* @return \Illuminate\Http\RedirectResponse
*/
public function logout(UserAuthenticator $authenticator, Guard $auth)
{
if (!$auth->guest()) {
$authenticator->logout();
}
$this->messages->success($this->request->get('message', 'anomaly.module.users::message.logged_out'));
return $this->response->redirectTo($this->request->get('redirect', '/'));
}
开发者ID:jacksun101,项目名称:users-module,代码行数:15,代码来源:LoginController.php
示例13: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request\RegisterUserRequest $request, Guard $auth)
{
//
$input = $request->only('email', 'password', 'name');
$input['password'] = bcrypt($input['password']);
$user = User::create($input);
$auth->login($user);
return redirect('/');
}
开发者ID:ememhr,项目名称:laravel_test_app,代码行数:15,代码来源:RegisterController.php
示例14: show
public function show($id, Guard $auth)
{
if ($auth->user()->id == $id) {
$personne = User::findOrFail($id);
return view('parents.show', compact('personne'));
}
$personne = User::findOrFail($auth->user()->id);
return redirect()->action('UserController@show', $auth->user()->id);
}
开发者ID:InfoTeamUPS,项目名称:projetTarabel,代码行数:9,代码来源:UserController.php
示例15: submit
public function submit($id, Request $request, Guard $auth)
{
$this->validate($request, ['comment' => 'required|max:250', 'link' => 'url']);
$comment = new TicketComments($request->only('comment', 'link'));
$comment->user_id = $auth->id();
$ticket = Ticket::findOrFail($id);
$ticket->comments()->save($comment);
session()->flash('success', 'Tu comentario fue guardado exitosamente');
return redirect()->back();
}
开发者ID:Burris19,项目名称:First-Aplication-Laravel-5.1,代码行数:10,代码来源:CommentsController.php
示例16: __construct
public function __construct(Request $request, Guard $auth)
{
// TODO: Add API keys and check here
// Check the session token and authenticate the user.
if ($sessionToken = $request->get('sessionToken')) {
$user = $this->validateSessionToken($sessionToken);
$auth->setUser($user);
}
parent::__construct($request, $auth);
}
开发者ID:stickableapp,项目名称:stickable-api,代码行数:10,代码来源:ApiController.php
示例17: filter
public function filter(Route $route, Request $request)
{
if ($this->auth->check()) {
$config = $this->config->get('c::redirect-login');
$url = $config ? $this->url->to($config) : '/';
return $this->redirect->to($url);
}
}
开发者ID:anlutro,项目名称:l4-core,代码行数:8,代码来源:GuestFilter.php
示例18: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->check()) {
return new RedirectResponse(route('login'));
}
return $next($request);
}
开发者ID:imanghafoori1,项目名称:boom-core,代码行数:15,代码来源:RequireLogin.php
示例19: store
/**
* Store a newly created snippet in storage.
*
* @param SnippetsRequest $request
* @return Response
*/
public function store(SnippetsRequest $request)
{
$this->auth->basic('username');
$data = ['title' => $request->input('title') ?: null, 'user_id' => $this->auth->user() ? $this->auth->id() : null, 'password' => $request->input('password') ?: null, 'mode' => $request->input('mode') ?: 'markdown'];
$snippet = $this->dispatchFrom(StoreNewSnippetCommand::class, $request, $data);
return 'http://drk.sh/s/' . $snippet->slug->slug . PHP_EOL;
}
开发者ID:elvios,项目名称:darkshare,代码行数:13,代码来源:SnippetsController.php
示例20: store
/**
* Store a newly created file in storage.
*
* @param FilesRequest $request
* @return Response
*/
public function store(FilesRequest $request)
{
$this->auth->basic('username');
$data = ['title' => $request->input('title') ?: null, 'password' => $request->input('password') ?: null, 'file' => $request->file('path')];
$file = $this->dispatchFrom(StoreNewFileCommand::class, $request, $data);
return 'http://drk.sh/' . $file->slug->slug . PHP_EOL;
}
开发者ID:elvios,项目名称:darkshare,代码行数:13,代码来源:FilesController.php
注:本文中的Illuminate\Auth\Guard类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论