2016-09-01 16:23:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2016-09-09 16:59:13 +01:00
|
|
|
use App\Album;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The policy mappings for the application.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $policies = [
|
|
|
|
'App\Model' => 'App\Policies\ModelPolicy',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any authentication / authorization services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
$this->registerPolicies();
|
|
|
|
|
2016-09-09 16:59:13 +01:00
|
|
|
Gate::define('album.view', function ($user, Album $album)
|
|
|
|
{
|
|
|
|
return (!$album->is_private || $album->user_id == $user->id);
|
|
|
|
});
|
2016-09-01 16:23:39 +01:00
|
|
|
Gate::define('admin-access', function ($user) {
|
|
|
|
return $user->is_admin;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|