0
0
Laravelframework~10 mins

Schema builder (columns, types) 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 add a string column named 'title' to the table.

Laravel
Schema::create('posts', function (Blueprint $table) {
    $table->[1]('title');
});
Drag options to blanks, or click blank then click option'
Ainteger
Btext
Cboolean
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' instead of 'string' for short text columns.
2fill in blank
medium

Complete the code to add an integer column named 'age' to the table.

Laravel
Schema::table('users', function (Blueprint $table) {
    $table->[1]('age');
});
Drag options to blanks, or click blank then click option'
Ainteger
Bdate
Cstring
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' for numeric columns.
3fill in blank
hard

Fix the error in the code to add a boolean column named 'is_active'.

Laravel
Schema::table('accounts', function (Blueprint $table) {
    $table->[1]('is_active');
});
Drag options to blanks, or click blank then click option'
Ainteger
Bstring
Cboolean
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'integer' or 'string' instead of 'boolean' for flags.
4fill in blank
hard

Fill both blanks to add a decimal column named 'price' with 8 digits total and 2 decimal places.

Laravel
Schema::table('products', function (Blueprint $table) {
    $table->[1]('price', [2], 2);
});
Drag options to blanks, or click blank then click option'
Adecimal
Binteger
C8
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'integer' instead of 'decimal' for prices.
5fill in blank
hard

Fill all three blanks to add a string column 'email' that is unique and nullable.

Laravel
Schema::table('users', function (Blueprint $table) {
    $table->[1]('email')->[2]()->[3]();
});
Drag options to blanks, or click blank then click option'
Astring
Bunique
Cnullable
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add 'unique' or 'nullable' methods.