Ad

Three Different Table In One Views Laravel 5.2

- 1 answer

Hi I would like to display three different table in one views using laravel 5.2. but it seems i am having problem on it.

my HomeController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class HomeController extends Controller
{
    public function index()
    {
        $about = DB::select('select * from about');
        $teams = DB::select('select * from teams');
        $services = DB::select('select * from services');

        return view('master', ['about' => $about], ['teams' => $teams], ['services' => $services]);
    }
}

in my views:

@foreach ($about as $abt)
      <h4>{{$abt->title}}</h4>
      <span class="semi-separator center-block"></span>
      <p>{{$abt->description}}</p>
@endforeach

@foreach ($teams as $team)
     <div class="creative-symbol cs-creative">
        <img src="assets/images/new/{{$team->icon}}" alt="">
        <span class="semi-separator center-block"></span>
        <h4><b>{{$team->title}}</b></h4>
        <p>{{$team->description}}</p>
     </div>
@endforeach

i cant display the third one which is the $services. pls help me. when i add the third one it will display an error

Ad

Answer

Please change this:

        return view('master', ['about' => $about], ['teams' => $teams], ['services' => $services]);

to this:

        return view('master', ['about' => $about, 'teams' => $teams, 'services' => $services]);
Ad
source: stackoverflow.com
Ad