clean tests & other things

This commit is contained in:
2020-03-25 20:11:29 +01:00
parent 11511039e9
commit 7e5d022aa2
27 changed files with 1497 additions and 187 deletions

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -17,7 +17,7 @@ class UserPolicy
*/
public function viewAny(User $user)
{
return true;
return $user->isAdmin();
}
/**