Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OswalSnow/AR-Barber/llms.txt

Use this file to discover all available pages before exploring further.

The Workday model stores a barber’s availability for a specific calendar date. Each record pairs a user_id with a day and records whether the barber is working that day (is_open) along with their start_time and end_time. The booking form queries these records to generate the list of available time slots for a given barber and date.

Fields

id
integer
required
Auto-incrementing primary key.
user_id
integer
required
Foreign key referencing the users table. Identifies which barber this schedule entry belongs to.
day
date
required
The calendar date this record applies to, stored as a DATE column (YYYY-MM-DD). Combined with user_id, this forms a unique constraint — there can be at most one Workday record per barber per date.
is_open
boolean
required
Indicates whether the barber is working on this date. When false, no time slots are generated for this day regardless of what start_time and end_time contain. A barber can be marked unavailable for a holiday or day off by setting is_open = false.
start_time
time
required
The time the barber starts accepting bookings, stored as a TIME column (HH:MM:SS). Together with end_time, this drives 30-minute slot generation in the booking form. Defaults to 10:00:00.
end_time
time
required
The time the barber stops accepting bookings. Slots are generated from start_time up to (but not including) end_time in 30-minute increments. Defaults to 20:00:00.
created_at
datetime
Timestamp set automatically when the record is created.
updated_at
datetime
Timestamp updated automatically on every save.

Unique constraint and updateOrCreate

The workdays table enforces a unique constraint on (user_id, day). This means you cannot accidentally create two conflicting schedule records for the same barber on the same date. The application uses updateOrCreate with this pair as the lookup key when a barber saves or updates their schedule:
Workday::updateOrCreate(
    ['user_id' => $barberId, 'day' => $date],  // lookup key
    [                                           // values to set or update
        'is_open'    => $request->is_open,
        'start_time' => $request->start_time,
        'end_time'   => $request->end_time,
    ]
);
If a record for that barber and date already exists, it is updated in place. If not, a new record is inserted.

Slot generation

When a customer selects a barber and date in the booking form, the application looks up the matching Workday record and generates available 30-minute slots between start_time and end_time. For example, a barber with start_time = '09:00' and end_time = '13:00' produces slots at 09:00, 09:30, 10:00, 10:30, 11:00, 11:30, 12:00, and 12:30. Slots that fall in the past (earlier than the current time on today’s date) are filtered out so customers can only book future appointments.
If no Workday record exists for a barber on a given date, that date shows no available slots in the booking form. Barbers must create a Workday record for each date they intend to work — there is no default or recurring schedule at the database level.

is_open = false behavior

Setting is_open to false blocks the day entirely, even if start_time and end_time are populated with valid times. This is useful for marking planned closures (holidays, vacations) without deleting the record.
// Block a barber's day off without removing their time configuration
Workday::updateOrCreate(
    ['user_id' => $barberId, 'day' => '2026-12-25'],
    ['is_open' => false, 'start_time' => '09:00', 'end_time' => '18:00']
);
To quickly check whether a barber has any open days scheduled in the future, query for records where is_open = true and day >= today:
$barber->workdays()
    ->where('is_open', true)
    ->where('day', '>=', today())
    ->orderBy('day')
    ->get();

Relations

user() — belongsTo User

Each Workday record belongs to one barber.
$workday->user; // Returns the User (barber) this schedule entry belongs to

$fillable fields

protected $fillable = ['user_id', 'day', 'is_open', 'start_time', 'end_time'];

Build docs developers (and LLMs) love