Jim
Jim

Reputation: 622

Laravel 5.2 - Output to a view

I have a simple method that passes info to a view:

Route::get('/', function () {
    $thissite = DB::table('this_site')->where('id',1)->get();
    $slider1 = DB::table('front_sliders')->where('active',1)->take(10)->get();
   return view('index')->with('slider1',$slider1)->with('site', $thissite );
});

All the data is passed OK and the $thissite is just one record, with one of the fields being called headline.

My problem is outputting this single variable along the lines of:

 <h1><strong>{{ headline }}</strong></h1>

I have tried many variations on this but I am not getting anywhere!

Upvotes: 0

Views: 23

Answers (2)

Jim
Jim

Reputation: 622

This worked:

 <h1><strong>{{ $site[0]->headline }}</strong></h1>

Upvotes: 0

Pawel Bieszczad
Pawel Bieszczad

Reputation: 13325

So headline is a column in this_site? If so then the this should work:

<h1><strong>{{ $site->headline }}</strong></h1>

Upvotes: 1

Related Questions