Reputation: 918
From the documentation the way we pass data from controller to view in laravel is like
return view('someview')->with('key', $data);
So I try to pass my query results to view by
$data = DB::table('user')->where('confirmation_status',1)->get();
return view('admin.presidentConfirmed')->with('data',$data);
But at the presidentConfirmed view, there's no data in it.
So I tried to use {{ Session::all() }}
to see if there's anything in the session.
Nothing...
So I tried passing just plain text through with
return view('admin.presidentConfirmed')->with('test','value');
Still nothing...
It's seems to only happen to only this specific view. Since I use ->with()
with many other views without any problem.
presidentConfirmed
@extends('layout.main')
@section('content')
@stop
layout.main
@include('layout/component.menu')
<div class="container" id="main_container">
<div class="well">
@yield('content')
</div>
@if(Config::get('app.debug') == true)
<div class="well">
{{ var_dump(Session::all()) }}
</div>
@endif
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
@yield('script')
@if(Config::get('applicationConfig.release') == 'release' && Config::get('applicationConfig.mode') != 'close' && Config::get('applicationConfig.mode') != 'technical_difficulties')
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-73122311-1', 'auto');
ga('send', 'pageview');
</script>
@endif
Upvotes: 2
Views: 448
Reputation: 918
I figured that out, it's actually me that confused ->with()
that use with Redirect::
and ->with()
that use with view()
Redirect::to('/somepage')->with('key','value)
is the one that stores its data in a session and use Session::get('key')
to retrieve the data.
view('someview')->with('key','value')
doesn't store its data in a session and retrieve the data with {{ $key }}
Upvotes: 0
Reputation: 7985
From laravel docs :
Of course, views may also be nested within sub-directories of the
resources/views
directory. For example, if your view is stored atresources/views/admin/profile.php
, it should be returned like so:
return view('admin.profile', $data);
So,in your case it should be :
return view('admin.presidentConfirmed',$data);
Upvotes: 1