Laravel Data Sharing Pack

The API for this package is simple:

FacadeSharedData::p ut(['post' => Post::first(), 'app' => [ 'name' => config('app.name'), 'environment' => config('app.env'), ],]);Helpershare(['post' => Post::first(), 'app' => [ 'name' => config('app.name'), 'environment' => config('app.env'), ],]);

To output data to JavaScript:

window.sharedData = { Post: { content: "...", created_at: "...", // ... },app: { /* ... */ }}

To print out configured JavaScript, click @shared instructions to your view file Add :

<html><head> @sharedhead>html>

If you want to configure a JavaScript object, you can publish and modify the configuration:

<?phpreturn ['js_namespace' => 'myCustomObjectName'];

In this package, you can will help you get started Documents and the source code on GitHub coderello / laravel-shared-data at view .

  Quote

KARABAY A, 2020 . Laravel Data Sharing Package,

https://www.karabayyazilim.com/blog/php/framework/laravel/laravel-veri-paylasma-paketi-2020-01-19-142703

(Accessed January 19, 2020).


  Share this post

Comments (0)

Comment

Subscribe
Sign up for the email newsletter to be the first to know about my blog posts