-
app/Policies/EarningPolicy.php
Open in GitHubuse App\Models\User; use App\Models\Earning; class EarningPolicy { public function view(User $user, Earning $earning) { return $user->spaces->contains($earning->space_id); } public function edit(User $user, Earning $earning) { return $user->spaces->contains($earning->space_id); } public function update(User $user, Earning $earning) { return $user->spaces->contains($earning->space_id); } public function delete(User $user, Earning $earning) { return $user->spaces->contains($earning->space_id); } public function restore(User $user, Earning $earning) { return $user->spaces->contains($earning->space_id); } }
-
app/Providers/AuthServiceProvider.php
Open in GitHubuse App\Models\Earning; use App\Policies\EarningPolicy; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider { protected $policies = [ // Earning::class => EarningPolicy::class, // ]; public function boot() { $this->registerPolicies(); // } }