PushView package support append javascript to view in Laravel
lchhieu/push_view is a Laravel package for pushview package support append javascript to view in laravel.
It currently has 2 GitHub stars and 13 downloads on Packagist.
Install it with composer require lchhieu/push_view.
Discover more Laravel packages by lchhieu
or browse all Laravel packages to compare alternatives.
Last updated
class BaseController extends Controller
{
public function index()
{
\PushViewJS::put([
'translate' => ['confirmation' => trans('labels.confirmation')]
]);
return view('welcome');
}
}
<script>
window.Core = window.Core || {};
Core.translate = {"confirmation":{"title":"Are you sure?","confirm_dirty_form":"Do you want to save the changes made before switching?","yes":"Yes","skip_continue":"Skip & Continue","cancel":"Cancel","delete":{"yes":"Yes delete it!","text":"You won't be able to revert this!"}}};
</script>
composer require lchhieu/push_view
If you're using Laravel 5.5 or later you can start using the package at this point. PushView is auto-discovered by the Laravel framework.
config/app.php. 'Lchhieu\PushView\Providers\ViewServiceProvider::class',
config/app.php 'PushViewJS' => Lchhieu\PushView\Facades\JavaScriptFacade::class
Finaly Pulish the package configuration by running this CMD
php artisan vendor:publish --provider="Lchhieu\PushView\Providers\ViewServiceProvider"