Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

DefaultEnabledRecordPolicy.php 629B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Policies;
  3. use App\Models\User;
  4. use App\Traits\SyncsWithCompanyDefaults;
  5. use Illuminate\Database\Eloquent\Model;
  6. class DefaultEnabledRecordPolicy
  7. {
  8. /**
  9. * Create a new policy instance.
  10. */
  11. public function __construct()
  12. {
  13. //
  14. }
  15. /**
  16. * Determine whether the company can delete the existing record.
  17. */
  18. public function delete(User $user, Model $model): bool
  19. {
  20. $hasEnabledRecord = in_array(SyncsWithCompanyDefaults::class, class_uses_recursive($model), true);
  21. return ! ($hasEnabledRecord && $model->getAttribute('enabled') === true);
  22. }
  23. }