clean tests & other things
This commit is contained in:
@@ -11,6 +11,13 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$this->authorize('viewAny', User::class);
|
||||
|
||||
return UserResource::collection(User::all());
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->authorize('create', User::class);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App;
|
||||
|
||||
use App\Models\Memo;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
@@ -39,12 +40,12 @@ class User extends Authenticatable
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function isAdmin()
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->role === 2;
|
||||
}
|
||||
|
||||
public function memos()
|
||||
public function memos() : HasMany
|
||||
{
|
||||
return $this->hasMany(Memo::class);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class UserPolicy
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
return true;
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user