Answers for "Pass all data to all pages laravel"

PHP
0

Pass all data to all pages laravel

use Illuminate\Support\Facades\View;

class BaseController extends Controller
{
  public function __construct()
  {
    //its just a dummy data object.
    $user = User::all();

    // Sharing is caring
    View::share('user', $user);
  }
}
Posted by: Guest on October-22-2020
0

Pass all data to all pages laravel

namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

use Illuminate\Support\Facades\Auth;
use DB;


class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
         View::share('key', 'value');
         Schema::defaultStringLength(191);

        $categories=DB::table('categories')->get();
        View::share('categories',$categories);  

    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
Posted by: Guest on October-22-2020
0

Pass all data to all pages laravel

this work :)
use Illuminate\Support\Facades\View;
Posted by: Guest on October-22-2020
0

use varable on all site pages laravel

# app/Providers/AppServiceProvider.php

public function boot()
{
   // add this
    view()->share('someKey', 'This is shared data');
}
Posted by: Guest on October-18-2020
0

use varable on all site pages laravel

{{Session::get('website_name', 'Value Goes Here')}}
Posted by: Guest on October-18-2020
0

use varable on all site pages laravel

php artisan make:middleware SomeMiddleware
Posted by: Guest on October-18-2020

Code answers related to "Pass all data to all pages laravel"

Browse Popular Code Answers by Language