copy and pasted from https://scotch.io/tutorials/a-guide-to-using-eloquent-orm-in-laravel
Hello Laravel
Get start with Laravel
Install Laravel
- install composer
- open cmd, run
composer global require "laravel/installer"
Create Laravel Project
open cmd, cd directory, run
laravel new project name
Alternative:
composer create-project --prefer-dist laravel/laravel blog
Run Laravel Project
php artisan serve
go to http://localhost:8000
or http://127.0.0.1:8000/
, hello world
Database with Laravel
get start with using database with laraval
Config the database
- address
- database (created beforehand)
- username (created beforehand)
- password (created beforehand)
config/database.php
.env
Create Table for Class in database (migration)
create a class named bears
php artisan make:migration create_bears_table --create=bears
a new file will appear at database\migrations
define the columns in the table
To really create a new table
php artisan migrate
errors faced
1. cant connect
set .env
2. laravel-5-4-key-too-long-error
in app/providers/AppServiceProvider.php
Create Models (to hold an entry in table)
create at app\Models
(directory created)
use full name when using other models
Create Seed for Testing
at database\seeds
, create testing datasets
Run seed
Database Functions in Short
Create
find
update
delete
query
one to one
one to many
many to many
Web Frontend and Routing
Basic Routing
goto routes\web.php
(this is automatically loaded by the framework)
parameter
Views
basically html files to be loaded by php
resources/views/myview.blade.php
route to myview