DocumentationFolderPermission.php 960 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Models;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. class DocumentationFolderPermission extends Model
  7. {
  8. public const SUBJECT_ALL = 'all';
  9. public const SUBJECT_ROLE = 'role';
  10. public const SUBJECT_USER = 'user';
  11. protected $fillable = [
  12. 'folder_id',
  13. 'subject_type',
  14. 'role_id',
  15. 'user_id',
  16. 'can_read',
  17. 'can_write',
  18. ];
  19. protected function casts(): array
  20. {
  21. return [
  22. 'can_read' => 'boolean',
  23. 'can_write' => 'boolean',
  24. ];
  25. }
  26. public function folder(): BelongsTo
  27. {
  28. return $this->belongsTo(DocumentationFolder::class, 'folder_id');
  29. }
  30. public function role(): BelongsTo
  31. {
  32. return $this->belongsTo(Role::class);
  33. }
  34. public function user(): BelongsTo
  35. {
  36. return $this->belongsTo(User::class);
  37. }
  38. }