Jump to content

Laravel :: Mostar dados de 2 tabelas @foreach

Go to solution Solved by tiago.f,

Recommended Posts

Estou com dificuldade em mostrar dados de duas tabelas na view.

as tabelas são : 
aniversarios: id, id_funcionario, title, start, end
funcionarios: if, foto, nome, email, estado,.....

No controller fiz o seguinte: 


$tabela = aniversario::join ('funcionarios','funcionarios.id','=', 'aniversarios.id')
        ->get(['aniversarios.id', 'aniversarios.title', 'aniversarios.start', 'aniversarios.end', 'funcionarios.nome', 'funcionarios.estado'])
        ->where('funcionarios.estado', '=', 'Ativo');

return view('calendariogeral',compact('tabela'));

Na view apenas o foreach com os campos que quero mostrar: 


      @foreach($tabela as $item)
      title: '{{$item->title}}.',
	    start: '{{$item->start}}',
	    end: '{{$item->end}}'


Os dados não me aparecem . Caso entretanto consiga perceber de onde vem o problema coloco aqui a resolução. 
Agradeço a quem me possa dar umas dicas . 

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.