lchhieu / push_view
PushView package support append javascript to view in Laravel
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.6.4
- illuminate/support: >=5.3
Requires (Dev)
- phpunit/phpunit: >=5.0
This package is auto-updated.
Last update: 2024-04-13 16:18:18 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"