Jump to content

Lavarel: Passar duas tabelas pela Controller Index


Recommended Posts

klasss

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">
      <thead>
               @foreach($itens as $item)
                    <tr>
                        <th> {{$item->capitulo}} </th>
                        
                        

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

                </tbody>
                @endforeach  
            </table>
        </div>    
    </div>
</div>

</div>


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

Obrigado!

Link to post
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.