Easy AJAX with blade
Installation
First, pull in the package through Composer., (*1)
"require": {
"ghanem/ajaxblade": "0.2.*"
}
or use., (*2)
composer require ghanem/ajaxblade
if using Laravel 5, include the service provider within config/app.php., (*3)
'providers' => [
'Ghanem\Ajaxblade\AjaxbladeServiceProvider'
];
now run this comand:, (*4)
php artisan vendor:publish
Example
Within your controllers, before you perform a redirect..., (*5)
public function show()
{
$articles = Article::orderBy('id', 'DESC')->Paginate(20);
return view('home',compact('articles'));
}
this is home view :, (*6)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="//code.jquery.com/jquery.js"></script>
<script src="{{ public_path('vendor/ajaxblade/ajaxblade.js') }}"></script>
</head>
<body>
@foreach ($users as user)
$user->name
@endforeach
@ajaxblade($users)
</body>
</html>