Skip to content

Instantly share code, notes, and snippets.

@101t
Last active May 31, 2020 10:06
Show Gist options
  • Save 101t/7bf893bd4b6b6186301b694a02ff068b to your computer and use it in GitHub Desktop.
Save 101t/7bf893bd4b6b6186301b694a02ff068b to your computer and use it in GitHub Desktop.
Laravel 5 simple Tutorial

PHP / WordPress / Laravel

PHP

Correcting file permissions on server

chown www-data:www-data -R * # Let Apache be owner
find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r--

According to: StackOverflow Answer

Laravel Migrations

make sure doctrine/dbal is installed

create table

create new table called "users"

php artisan make:migration create_users_table --create=users
php artisan migrate

add column to table

add table's column to exists table

php artisan make:migration add_password_column_to_users_table --table=users
php artisan migrate

remove migration

to remove last migration only

php artisan migrate:rollback

to remove all migrations

php artisan migrate:reset

modify table

Modify column, e.g. modify column as nullable

php artisan make:migration update_users_set_bio_nullable --table=users

in up() function

$table->text('bio')->nullable()->change();

in down() function

$table->text('bio')->nullable(false)->change();

Rename column, e.g. rename column from 'bio' to 'about'

php artisan make:migration rename_bio_to_about_on_users_table --table=users

in up() function

$table->renameColumn('bio', 'about');

in down() function

$table->renameColumn('about', 'bio');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment