You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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. }