Open andrelandgraf opened 6 years ago
Creating a database table:
docker-compose exec app php artisan make:migration create_pizza_table --create=pizza
// Creates a migration file for the db table pizza
For the migration structure, see: https://laravel.com/docs/5.6/migrations
Creating a model and a factory for the table Pizza:
docker-compose exec app php artisan make:model --factory Pizza
And a Seeder to add demo data:
docker-compose exec app php artisan make:seeder PizzaTableSeeder
Also go to app/Pizza.php (the acutal model) and override the table name ($table), because default is plural form.
Refresh composer (do this whenever artisan tellls you it cannot find your new factory/seeder classes):
docker-compose exec app composer dump-autoload
Drop and refresh the dev database using the new seeder:
docker-compose exec app php artisan migrate:fresh --seed
For a permanent connection to the app docker container use:
docker-compose exec app bash -b
Now you can use tinker to check the results for the seeding: https://scotch.io/tutorials/tinker-with-the-data-in-your-laravel-apps-with-php-artisan-tinker
Inside routes/web.php add your new data to a route (like App/Pizza::all()). Now you can access the data, inside your views (resources/views/).
Problem regarding importing js inside a lower level blade template: https://stackoverflow.com/questions/51592054/laravel-right-way-to-import-javascript-into-blade-templates
So far we can add and delete pizzas of the pizza table. Missing:
https://laravel-news.com/your-first-laravel-application