How to display two different tables in the same view?

0

Using Laravel 5.6 I'm trying to display two different tables in the same view, but it's 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 that is returning on the page is as follows

  

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

    
asked by anonymous 25.05.2018 / 03:59

1 answer

1

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

return view('nossacasa.nossacassa', [
    'nossacasatitulo' => $nossacasatitulo,
    'nossacassa' => $nossacasa
])
    
25.05.2018 / 07:12