lchhieu / push_view
PushView package support append javascript to view in Laravel
dev-master
2018-11-14 04:18 UTC
Requires
- php: >=5.6.4
- illuminate/support: >=5.3
Requires (Dev)
- phpunit/phpunit: >=5.0
This package is auto-updated.
Last update: 2026-03-13 20:23:10 UTC
README
- PushView package support append javascript to view in Laravel
- Package will be extremely useful when you want to automatically translate text from php and the client side will receive the translated text
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>
Installation
- Install using Composer
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.
- Add the service provider to the providers array in your
config/app.php.
'Lchhieu\PushView\Providers\ViewServiceProvider::class',
- Add the facade in
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"