0
0
Laravelframework~10 mins

Timestamps management in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable automatic timestamps in a Laravel model.

Laravel
class Post extends Model {
    public $[1] = true;
}
Drag options to blanks, or click blank then click option'
AsoftDeletes
Btimestamps
Cfillable
Dguarded
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'softDeletes' instead of 'timestamps'.
Forgetting to set the property as public.
Confusing 'fillable' with timestamp management.
2fill in blank
medium

Complete the code to disable timestamps in a Laravel model.

Laravel
class Comment extends Model {
    public $[1] = false;
}
Drag options to blanks, or click blank then click option'
Atimestamps
Bhidden
CsoftDeletes
Dincrementing
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'softDeletes' instead of 'timestamps'.
Setting the property to true instead of false.
Confusing 'incrementing' with timestamp control.
3fill in blank
hard

Fix the error in the code to correctly set a custom timestamp column name.

Laravel
class User extends Model {
    const CREATED_AT = '[1]';
}
Drag options to blanks, or click blank then click option'
Acreated_at
BcreatedAt
CcreatedAtAt
Dcreate_at
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase instead of snake_case.
Misspelling the column name.
Adding extra letters or missing underscores.
4fill in blank
hard

Fill both blanks to customize the timestamp column names for created and updated times.

Laravel
class Article extends Model {
    const CREATED_AT = '[1]';
    const UPDATED_AT = '[2]';
}
Drag options to blanks, or click blank then click option'
Acreated_on
Bupdated_on
Cupdated_at
Dcreated_at
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up created and updated constants.
Using camelCase instead of snake_case.
Not matching the database column names exactly.
5fill in blank
hard

Fill all three blanks to create a model that disables timestamps and sets a custom date format.

Laravel
class Event extends Model {
    public $[1] = [2];
    protected $dateFormat = '[3]';
}
Drag options to blanks, or click blank then click option'
Atimestamps
Bfalse
CY-m-d H:i:s
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting timestamps to true instead of false.
Using an invalid date format string.
Confusing public and protected visibility.