Note Flashcards
Validation
$request->validate([
Array=>required)]
error recalling
@if($errors->any()){ @foreach($errors->all() as $error) {{ $error }} @endforeach @endif
At $request->validate([ 'title' => 'required|unique:posts|max:255', 'v1\.0' => 'required', ]);
@error(‘title’)
<div class="alert alert-danger">{{ $message }}</div>
@enderror
Password hash
First input -> use Illuminate/support/facades/hash
Hash::make(your password)
Authorization method
First input->use Illuminate/support/facades/Auth
Auth::attempt([
………
]);
Authorization Checking
Getting auth user
if( Auth::check( ) ){
$user = Auth::user( );
}
Image File Name & File save
$file = $request->file(‘image’)
$fileName = rand() . $file->getClientOriginalName();
$file->move(public_path(‘filepath’),
$fileName)
Pagination
E.g $products = Product:paginate(3)
In blade file
{{ $products->links()}}
providers/AppServiceProvider
use Illuminate\Pagination\Paginator;
public function boot()
{
Paginator::useBootstrap();
}
sending data with compact
$user = User::all) return view('index' , compact('user'));
error validation with custom message
number index in blade file
{{ $posts ->firstItem( ) + $loop ->index }}
image intervention
in terminal
composer require intervention/image
Go to config/app.php
$providers
Intervention\Image\ImageServiceProvider::class;
$aliases
‘Image’ => Intervention\Image\Facades\Image::class
$ php artisan vendor:publish –provider=”Intervention\Image\ImageServiceProviderLaravelRecent”
uploading multiple pics
multiple keyword should be used
foreach($image as $mult_img){
}