StaffCoder
Laravel
LaravelLaravel 13PHP 8
2 modules · 8 challengesSign up
Module 2 of 2 · 4 challenges

Laravel Eloquent Models & Migrations

Reversible migrations (correct types/defaults/indexes), model casts (date/bool/decimal/JSON), fillable, accessors/mutators, and lifecycle events. Star: Gym Membership Records (migration + model + first belongsTo with FK).
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Product Schema Migration

Sign up to unlock
100%1 of 1 solvedeasy
About this challenge

This problem covers writing the migration for a products table so prices are stored exactly, missing values get sensible defaults, the name is indexed, and the change can be rolled back.

Solved in a browser IDE and graded by tests. Sign up to solve

Member Model Casts

Sign up to unlock
100%1 of 1 solvedeasy
About this challenge

This problem covers configuring a model so dates, flags, money, statuses and settings read back as the right PHP types, only safe fields can be mass assigned, and a full name is worked out on demand.

Solved in a browser IDE and graded by tests. Sign up to solve

Booking Defaults

Sign up to unlock
100%1 of 1 solvedeasy
About this challenge

This problem covers filling in a booking's reference and status automatically when it is created, and cleaning its email every time it is saved.

Solved in a browser IDE and graded by tests. Sign up to solve

Gym Membership Records

STAR
Solving it completes the module
100%1 of 1 solvedeasy
About this challenge

This problem covers building a gym's members table and model from scratch: a migration with the right types and defaults, safe mass assignment, casts, a status worked out from the expiry date, a generated member code and a cleaned email.

Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.