Jump to content

Lavarel: Passar duas tabelas pela Controller Index


Recommended Posts

Olá a todos, 

Preciso de uma informação relativamente a passar duas tabelas pelo index. 
Tenho o seguinte código no controller: 

public function index(){

        $tabela = capitulo::orderby('id', 'desc')->paginate();
        $tabela1 = documentacao::orderby('id', 'desc')->paginate();

        return view('gestao-documental.index', ['itens' => $tabela, 'itens1' => $tabela1]);


E quero passar os dados das duas tabelas :: Capitulo (ID, capitulo) :: Documentacao(ID, ID_capitulo, Documento, versao)
para a seguinte dataTable 


<!-- Data table -->
<div class="card shadow mb-4">

<div class="card-body">
  <div class="table-responsive">
    <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
               @foreach($itens as $item)
                        <th> {{$item->capitulo}} </th>

                @foreach($itens1 as $item1)
                    <td> {{$item1->documentacao}} </td>



Consigo ver os dados inserido no Capitulo e no campo onde deveria aparecer o documentacao aparece em branco. 


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.