add row laravel code example

Example: php artisan add row in table

First, create the file via Artisan (or do it manually if you like):
	php artisan make:migration name_of_the_generated_file --table=table_to_be_added_to
  
Edit the file and add on the 'function up()' so the column will be created once you do 'migrate':
	$table->define_the_type('name_of_the_column')->nullable();
	ps.: 'define_the_type' needs to be changed by the type of field you want to create.
    ps.: 'name_of_the_column' needs to be changed by the name you want the column to have.
  
Then, add on the 'function down()' so we can remove the column with the 'rollback' if needed:
	$table->dropColumn('name_of_the_column');

Tags:

Php Example