How to display two different tables in the same view?

Asked

Viewed 123 times

0

Using the Laravel 5.6 I am trying to display two different tables in the same view, but it is giving error

this is my controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\NossaCasa;
use App\NossacasaTitulo;

class NossaCasaController extends Controller
{
    public function index(){
        $nossacasa = NossaCasa::all();
        return view('nossacasa.nossacasa', array('nossacasa' => $nossacasa)); 
        $nossacasatitulo = NossacasaTitulo::find(1);
        return view('nossacasa.nossacasa', array('nossacasa' => $nossacasatitulo));       
    }   

}

The error is returning on the page is as follows

"Undefined variable: nossacasatitulo (View: /home/centroculturalvastimilla/www/admin/Resources/views/nossacasa/nossacasa.blade.php)"

1 answer

1


You need to include in the view all values you want to use, see;

return view('nossacasa.nossacassa', [
    'nossacasatitulo' => $nossacasatitulo,
    'nossacassa' => $nossacasa
])

Browser other questions tagged

You are not signed in. Login or sign up in order to post.