라라벨 RequestGuard.php

1 개요[ | ]

라라벨 RequestGuard
<?php

namespace Illuminate\Auth;

use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\Guard;

class RequestGuard implements Guard
{
    use GuardHelpers;

    protected $callback;
    protected $request;

    public function __construct(callable $callback, Request $request)
    {
        $this->request = $request;
        $this->callback = $callback;
    }

    public function user()
    {
        if (! is_null($this->user)) {
            return $this->user;
        }
        return $this->user = call_user_func($this->callback, $this->request);
    }

    public function validate(array $credentials = [])
    {
        return ! is_null((new static(
            $this->callback, $credentials['request']
        ))->user());
    }

    public function setRequest(Request $request)
    {
        $this->request = $request;

        return $this;
    }
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}