Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to pass value in app.blade

//create a service provider
php artisan make:provider ComposerServiceProvider
  
//register the app service provider in providers array of config/app.php
AppProvidersComposerServiceProvider::class,

//pass the data you want to share in views 
<?php 
namespace AppProviders;
use IlluminateSupportFacadesView;
use IlluminateSupportServiceProvider;

class ComposerServiceProvider extends ServiceProvider {

    public function boot()
    {
        View::composer('*', function($view){
            $data = Some logic here ; //eg User::all();
            $view->with('data', $data); // 'data' is value to be used in views 'data' = $data
        });
    }

    public function register()
    {
        //
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php get sql update from session 
Php :: wordpress set category front end 
Php :: cake php 2.x sql dump 
Php :: echo two variables same line php 
Php :: if order has product id in array 
Php :: Éviter le spam de commentaires 
Php :: redirect www to non-www wordpress multisite 
Php :: php replace all text from string with associate array values 
Php :: get git branch with php 
Php :: slideshow php 
Php :: featured image tab not displayed on post 
Php :: laravel restore deleted 
Php :: call stored procedure in laravel 
Php :: PHP number_format — Format a number with grouped thousands 
Php :: how to cut middle part of text php 
Php :: Nginx + Laravel - Moving blog from subdomain to /blog 
Php :: The app function returns the service container instancel 
Php :: whats is typecasting in php 
Php :: laravel join with count 
Php :: requires ext-pcntl 
Php :: laravel validate form data unique array 
Php :: buddy group hide notice join 
Php :: PHP strtr — Translate characters or replace substrings 
Php :: wp wc php sort products archive cheapest price 
Php :: import csv in laravel 8 
Php :: HP officejet pro 8720 default password 
Php :: php vender 403 forbidden 
Php :: ubuntu add phpstorm to launcher 
Php :: php years 
Php :: php check how long a function took to exexute 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =