in Laravel 5, in the share method, how can I return indexes to the view if I pass an array?
Ad
I have this data
$data["isLoggedIn"] = true;
$data["isAdmin"] = true;
$data["isOrg"] = true;
and I share the data to the view this way.
view()->share('data', $this->data);
In my view (blade) I access the data like
{{ $data['isAdmin'] }}
I would like to be get the data with the key, something like:
{{ $isAdmin }}
Do I need to make a foreach array and pass each inner key?
thanks!
Ad
Answer
Ad
You can share an array directly with this syntax using the View facade:
View::share( $this->data );
Now you can access any key like this:
{{ $key }}
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad