coderello/laravel-shared-data

Package for sharing data from Laravel to JavaScript.
77,960 313
Install
composer require coderello/laravel-shared-data
Latest Version:4.0.0
PHP:^8.0
License:MIT
Last Updated:Feb 1, 2023
Links: GitHub  ·  Packagist
Maintainer: coderello

Laravel Shared Data

✨ Introduction

Laravel Shared Data provides an easy way to share the data from your backend to the JavaScript.

🚀 Quick start

  • Install the package:

    composer require coderello/laravel-shared-data
    
  • Include the @shared directive into your blade layout before all scripts.

  • Share the data from within Laravel:

    share(['user' => $user, 'title' => $title]);
    
  • Access the data from the JavaScript directly:

    const user = window.sharedData.user;
    const title = window.sharedData.title;
    
  • Or using the built-it global helper:

    const user = shared('user');
    const title = shared('title');
    

📖 License

Laravel Shared Data is open-sourced software licensed under the MIT license.

Related Packages

erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

610,259,779 9,704
laravel/framework

The Laravel Framework.

551,557,428 34,802
laravel/tinker

Powerful REPL for the Laravel framework.

462,518,693 7,436