'what is view and how to view in laravel 8 project
How to add data in array global in appServiceProvider of Laravel which could be used globally for select option field in blade.php
Solution 1:[1]
You can use View::share to share data within all views. Here is an example from the doc
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
View::share('key', 'value');
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ml59 |
