laravel-learn-bbs/tests/Traits/ActingJWTUser.php
2018-06-16 10:54:07 +08:00

16 lines
280 B
PHP

<?php
namespace Tests\Traits;
use App\Models\User;
trait ActingJWTUser
{
public function JWTActingAs(User $user)
{
$token = \Auth::guard('api')->fromUser($user);
$this->withHeaders(['Authorization' => 'Bearer ' . $token]);
return $this;
}
}