laravel 5.6 # create read update delete (crud) authentication pagination in laravel 5.6

Описание к видео laravel 5.6 # create read update delete (crud) authentication pagination in laravel 5.6

In this video, I have shown you how to make create read update delete (crud) application using Laravel 5.6. I have added authentication and pagination functionality to this crud.

source code and text tutorial will be available by the following the link
https://polodev.github.io/create-read...


create read update delete, authentication and pagination in laravel 5.6
basic mvc structure
route
||
controller ==== model
||
view
installing laravel using composer
composer create-project laravel/laravel YourProjectName

command for making model, controller, factory and migration file
php artisan make:model YourModel
php artisan make:controller YourController
php artisan make:migration create_your_table_name
php artisan make:factory YourModel -m "app\yourmodelname"
php artisan make:controller YourController -r
php artisan make:model YourModel -a

connecting with dabase inside .env file . Whenever we change .env file we have to restart our artisan server
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD

Remember to always import class name on top of the file when necessary

defining default string maximum 191 chracter length inside AppServiceProvider boot method
Schema::defaultStringLength(191);

migrating table to database
php artisan migrate

writing dummy data inside PostFactory.php using faker instance

seeding database with dummy data
php artisan db:seed

resource route in laravel
Route::resource('posts', 'PostController');

passing variable in a view
$posts = Post::all();
return view ('posts.index', compact('posts'));

cross site request forgery
@csrf
for update
@method('put')
for delete
@method('delete')

yielding in master view for content section
inside master.blade.php
@yield('content')


extends master in view file and write content inside content section
inside index.balde.php
@extends('master')
@section('content')
@endsection

iterating variable using blade directives
@foreach($posts as $post)
@endforeach

pagination in laravel
inside controller
$posts = Post::paginate(10);

redirect in laravel
redirect('/posts');
redirect(route('login'));

some model (eloquent) query we are use today
for fetching posts from db
$posts = Post::all();
$posts = Post::paginate(10);

built in authentication in laravel
php artisan make:auth

adding middleware in controller inside construct function
adding login logout inside master.blade.php file
access authenticate user data
how to redirect to certain routes after login or register
protected $redirectTo = '/posts';

Комментарии

Информация по комментариям в разработке