Simple App using Laravel 7

Setup

composer create-project --prefer-dist laravel/laravel supertodolist "7.*"

Test everything works

php artisan serve --host=0.0.0.0
php artisan --version
//Laravel Framework 7.30.4

Setup database

in MySQL

create database todolist;
create user 'ouser'@'%' identified by 'QqX05.SA%>UNdd';
GRANT ALL PRIVILEGES ON *.* TO 'ouser'@'%';

then in /etc/my.cnf

bind-address=*

and then

systemctl restart mysqld

Email

sudo yum install sendmail sendmail-cf m4

Create Account on mailtrap.io

https://mailtrap.io/inboxes

in the .env file we modify

APP_NAME=SuperTodoList
...
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=todolist
DB_USERNAME=ouser
DB_PASSWORD=QqX05.SA%>UNdd

Talk about routes, composer, app

Talk about M-V-C

php artisan make:controller UserController

Talk about database and the migrations

php artisan migrate
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class UserController extends Controller
{
    public function index()
    {
        //DB::insert('insert into users (name,email,password) values (?,?,?)', ['donhk', 'hk@donhk.dev', 'awesome']);
        //DB::update('update users set name= ? where id = 1',['testing']);
        //DB::delete('delete  from users');
        return DB::select('select * from users');
        //return view('home');
    }
}
 $user = new User();
 //dd($user);
 $user->name = 'test';
 $user->email = 'test@test.com';
 $user->password = 'password';
 $user->save();

User::all();
User::where('id',2)->delete(); 
User:where('id',3)->update(['name' => 'el homie']);

Login creation

composer require laravel/ui "^2.0"
php artisan ui bootstrap
php artisan ui:auth
npm install
npm run dev

Blade

php artisan route:list

Configurations .env datatabase.php

Upload Image

  <form action="{{route('uploadPic')}}" method="post" enctype="multipart/form-data">
                            @csrf
                            <input type="file" name="image"/>
                            <input type="submit" name="upload"/>
                        </form>
Route::post('/upload', 'HomeController@upload')->name('uploadPic');
    public function upload(Request $request)
    {
        Log::info('image received');
        $image = $request->image->store('images', 'public');
        return 'ok';
    }
 $table->string('avatar')->nullable();
php artisan migrate:refresh
php artisan storage:link
php artisan make:component Alert //Optional
php artisan make:model 
php artisan make:migration 
php artisan make:controller

php artisan make:model Todo -m -c
php artisan migrate
 php artisan migrate:refresh