laravel-learn-bbs/tests/Traits/ActingJWTUser.php

16 lines
280 B
PHP
Raw Normal View History

2018-06-16 02:54:07 +00:00
<?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;
}
}