Skip to content
  • Home
  • Blog
    • yttags
    • Youtube
  • Categories
  • Tools
  • Server-Side
    • php
    • Node.js
    • ASP.NET
    • Magento
    • Codeigniter
    • Laravel
    • Yii
  • JS
    • AngularJS
    • Ajax
    • VueJs
    • jQuery
    • ReactJS
    • JavaScript
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us
Pakainfo

Pakainfo

Web Development & Good Online education

Laravel 5.6 Share Variable With Display Data in View

September 8, 2018 Pakainfo Technology, Laravel, Mysql, Mysqli, Programming Leave a comment
Rate this post

Today, We want to share with you Laravel 5.6 Share Variable With Display Data in View.In this post we will show you Laravel 5.6 Passing Variables from the Controller to View, hear for Laravel 5.6 share a variable to all views we will give you demo and example for implement.In this post, we will learn about Laravel 5.6 – Sharing $user variable in all views with an example.

Laravel 5.6 Share Variable With Display Data in View

There are the Following The simple About Laravel 5.6 Share Variable With Display Data in View Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to share Variable with all Views in Laravel?, so the some major files How to share Variables to all views and pages for this example is following below.

  • View Files Laravel 5.6
  • services AppServiceProvider
Read Also:  How to create model object in controller in laravel?

Step 1 : Laravel View Files

resources/views/home.blade.php

@extends(‘layouts.layout’)

@section(‘content’)
   <h1>share a variable to all views using Laravel 5.6 Example</h1>
<b>Dashboard</b>
{{ Auth::user()->name }}, You are logged in! {{$activetickets}}
@endsection

Step 2 : Include Providers

app/Providers/AppServiceProvider.php

get()->count();
View::share(‘activetickets’, $tickets);
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

Free Live Chat for Any Issue

Laravel 5.6 – Sharing variable in all views

Simple Example of the Laravel 5.6 Share Variable With Display Data in View

Step 1: Create Route

routes/web.php

Route::get(‘member’, function () {
return view(‘member’);
});

Route::get(‘user’, function () {
return view(‘user’);
});

Step 2 : Create Blade View

resources/views/member.blade.php

Read Also:  laravel 6 Delete Multiple Records Eloquent

Simple create a two Laravel blade file Like as.

# resources/views/member.blade.php

<html>
  <body>
    <h1>Member Page</h1>
    <p><?= $companyname ?></p>
  </body>
</html>

resources/views/user.blade.php

# resources/views/user.blade.php

<html>
  <body>
    <h1>User Page</h1>
    <p><?= $companyname ?></p>
  </body>
</html>

Step 3: Share Variables

app/Providers/AppServiceProvider.php

# app/Providers/AppServiceProvider.php

public function boot()
{
// laravel 5.6 pass data to view from controller
view()->share(‘companyname’, ‘This is Pakainfo share data’);
}

Angular 6 CRUD Operations Application Tutorials

Read :

  • Technology
  • Google Adsense
  • Programming

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

Download

I hope you get an idea about Sharing data between views in Laravel 5.6 Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  add remove input fields dynamically with jquery and submit to database

Related posts:

  1. laravel Views share Variable multiple to controller
  2. Laravel Global variable Sharing Data with all views
  3. Laravel 5.8 Global Blade view variable
  4. Laravel Display Decoded JSON From Database in Blade View
  5. How to pass data to all views in Laravel 5.8?
  6. Laravel 6 display flash message on view
  7. Laravel Passing Multiple Variables from Controller to View
  8. global variable for all controller and views in Laravel
  9. Global variable in laravel controller Example
  10. How to Check Whether a Variable is Set or Not in laravel blade?
create view in laravel 5 commandHow to share Variable with all Views in Laravel?Laravel 5.6 – Sharing variable in all viewslaravel display data in viewlaravel global variablelaravel pass data to view from controllerlaravel share data to some viewslaravel share variablelaravel view composer tutoriallaravel view share undefined variableSharing Data Between Views Using Laravel View ComposersView Composer to pass variable to all views

Post navigation

Previous Post:Password Protecting Website running on NGinx serve PHP-FPM
Next Post:PHP Laravel 5.7 Image Upload with Validation Tutorial Example

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (49) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (93) Codeigniter (174) CSS (96) Earn Money (61) Education (53) Entertainment (109) fullform (78) Google Adsense (62) Highcharts (77) Hollywood (94) JavaScript (1354) Jobs (39) jQuery (1421) Laravel (1083) LifeStyle (50) movierulz4 (48) Mysql (1029) Mysqli (890) Node.js (38) php (2110) Programming (2321) Python (96) ReactJS (37) Software (105) Software (78) Stories (78) tamilrockers (89) Tamilrockers kannada (49) Tamilrockers telugu (48) Tech (104) Technology (2361) Tips and Tricks (107) Tools (115) Top10 (303) Trading (51) Trending (46) VueJs (250) Web Technology (83) webtools (130) wordpress (165) World (128)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

Web Development & Good Online education : Pakainfo by Pakainfo.
Top
Subscribe On YouTube : Download Source Code & New itsolutionstuck
We accept paid guest Posting on our Site : Guest Post Chat with Us On WhatsApp