troubleshooting Question

I'm trying to pass two sets of variables into my View and failing miserably...

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
LaravelPHP
4 Comments1 Solution43 ViewsLast Modified:
I need to pass two entities into my view. Both of which work fine when I retrieve them one at at time, but I'm blowing it somewhere when I try to do both.

Here's the function I'm wrestling with in my Controller and my attempt to pass both sets of data into my route simultaneously:

	public function professionals($id) {
		$pages = Page::findOrFail($id);
		$pros = Professional::sortable()->orderBy('lname', 'asc')->paginate(25);
		return view('pros', compact('pros'))->with('pages', compact('pages'));
	}

Here's my view:

@extends('layouts.satellite')
@section('content')
<!-- Section: intro -->
<section id="intro" class="intro">
	<div class="satellite-content">
		<div class="container">
			<div class="row">
				<div class="col-xs-12 satellite_row">
					<?php echo $pages->body; ?>
					<table class="table table-bordered">
						<tr>
						<td style=" background-color:#ea7fea; color:#fff; text-align:center; font-weight:bold;">#</td>
							<td style=" background-color:#ea7fea; color:#fff; text-align:center; font-weight:bold;">@sortablelink('lname', 'Name') </td>
							<td style=" background-color:#ea7fea; color:#fff; text-align:center; font-weight:bold;">@sortablelink('discipline', 'Discipline')</td>
							<td style=" background-color:#ea7fea; color:#fff; text-align:center; font-weight:bold;">@sortablelink('country', 'Country')</td>
							<td style=" background-color:#ea7fea; color:#fff; text-align:center; font-weight:bold;">@sortablelink('cert_year', 'Certified')</td>
						</tr>
						<?php $count=1;?>
						@foreach($pros as $pro)
							<tr>
								<td>{{ $count }}</td>
								<td>{{ $pro->lname }}, {{ $pro->fname }}</td>
								<td>{{ $pro->discipline }}</td>
								<td>{{ $pro->country }}</td>
								<td>{{ $pro->cert_year }}</td>
							</tr>
						<?php $count=$count+1;?>
						@endforeach		
						<tr>
							<td colspan="5" style="text-align:center;">{{ $pros->links() }}</td>
						</tr>
					</table>	
				</div>
			</div>
		</div>
	</div>
</section>
@endsection

This is the error I'm getting:

Trying to get property 'body' of non-object (View: C:\wamp64\www\new_nomas\resources\views\pros.blade.php)

What am I missing?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros