$scheduledUserDishes * * @method static create(array $array) * @method static Builder where(array|Closure|Expression|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and') * @method static ScheduleFactory factory($count = null, $state = []) * @method static firstOrCreate(array $array, false[] $array1) */ class Schedule extends Model { /** @use HasFactory */ use HasFactory; protected $table = 'schedules'; public $timestamps = false; protected $dateFormat = 'Y-m-d'; protected $fillable = ['planner_id', 'date', 'is_skipped']; protected $casts = [ 'date' => 'date', 'is_skipped' => 'boolean', ]; protected static function booted(): void { static::addGlobalScope(new BelongsToPlanner); } public function scheduledUserDishes(): HasMany { return $this->hasMany(ScheduledUserDish::class); } public function hasAllUsersScheduled(): bool { return $this->scheduledUserDishes->count() === User::where('planner_id', $this->planner_id)->count(); } }