$users * @property Collection $realUsers * @property-read Collection $organizationInvitations * @property Member $membership * @property NumberFormat $number_format * @property CurrencyFormat $currency_format * @property DateFormat $date_format * @property IntervalFormat $interval_format * @property TimeFormat $time_format * * @method static OrganizationFactory factory() */ class Organization extends Model implements AuditableContract { use CustomAuditable; /** @use HasFactory */ use HasFactory; use HasUuids; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'name' => 'string', 'personal_team' => 'boolean', 'currency' => 'string', 'employees_can_see_billable_rates' => 'boolean', 'employees_can_manage_tasks' => 'boolean', 'prevent_overlapping_time_entries' => 'boolean', 'number_format' => NumberFormat::class, 'currency_format' => CurrencyFormat::class, 'date_format' => DateFormat::class, 'interval_format' => IntervalFormat::class, 'time_format' => TimeFormat::class, ]; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'personal_team', ]; /** * The model's default values for attributes. * * @var array */ protected $attributes = [ ]; /** * Get all the users that belong to the team. * * @return BelongsToMany */ public function users(): BelongsToMany { return $this->belongsToMany(User::class, Member::class) ->withPivot([ 'id', 'role', 'billable_rate', ]) ->withTimestamps() ->as('membership'); } /** * Get the owner of the team. * * @return BelongsTo */ public function owner(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } /** * @return HasMany */ public function members(): HasMany { return $this->hasMany(Member::class); } /** * @return BelongsToMany */ public function realUsers(): BelongsToMany { return $this->users() ->where('is_placeholder', false); } /** * @return HasMany */ public function organizationInvitations(): HasMany { return $this->hasMany(OrganizationInvitation::class, 'organization_id'); } /** * Find a model by its primary key or throw an exception. * * @param array $columns * * @throws ModelNotFoundException */ public static function findOrFail(string $id, array $columns = ['*']): Model { if (! Str::isUuid($id)) { throw (new ModelNotFoundException)->setModel( self::class, $id ); } return parent::findOrFail($id, $columns); } }