From Javascript to Php Laravel — Models and Migrations
How to run a server
Go to your project folder, navigate to the public route then run the following command on the terminal.
sudo php -S localhost:8080
How to define objects in php
How to read an object prop in php
Done!. This is all you need to know about php.😂
MODELS — MIGRATIONS
Now I got to make a file upload functionality. This entity (SharePointFile) will be related to roles entity.
1. CREATE SharePointFile ENTIY
This will create the SharePointFile Model and Migration File.
Migration is a concept that let us create a scaffold (blueprint). That later we will run to create our database tables and relations.
php artisan make:model SharePointFile -mcr
2. MODIFY MIGRATION
This comes, empty so we got to write some code to define table fields
CREATE RoleHasSharePointFiles
php artisan make:model role_has_share_point_files -mcr
MODIFY MIGRATION
This changes a little bit. We are doing the relations between
- share_point_files table
- roles table
- users table: created_by
- users table: updated_by
Of course, don't forget the down function to drop foreign keys.
RUN MIGRATIONS
php artisan migrate
this ends with: