您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CompanyOwned.php 793B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Traits;
  3. use Filament\Notifications\Notification;
  4. use Illuminate\Support\Facades\Auth;
  5. trait CompanyOwned
  6. {
  7. public static function bootCompanyOwned(): void
  8. {
  9. static::created(static function ($model) {
  10. if (Auth::check() && Auth::user()->currentCompany) {
  11. $model->company_id = Auth::user()->currentCompany->id;
  12. } else {
  13. Notification::make()
  14. ->danger()
  15. ->title('Oops! Unable to Assign Company')
  16. ->body('We encountered an issue while creating the record. Please ensure you are logged in and have a valid company associated with your account.')
  17. ->persistent()
  18. ->send();
  19. }
  20. });
  21. }
  22. }