Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Ficha
  2.  
  3. public function contenidos()
  4. {
  5. return $this->belongsToMany('Contenido', 'contenido_ficha')->withTimestamps();
  6. }
  7.  
  8. Contenido
  9.  
  10. public function fichas()
  11. {
  12. return $this->belongsToMany('Ficha', 'contenido_ficha')->withTimestamps();
  13. }
  14.  
  15. public function myShow($id, $slug)
  16. {
  17. $ficha = Ficha::where('id', $id)->first();
  18.  
  19. $date = $ficha->created_at;
  20. setlocale(LC_TIME, 'Europe/Madrid');
  21. $date = $date->formatlocalized('%A %d %B %Y');
  22.  
  23. return View::make('fichas.show')
  24. ->with('ficha', $ficha)
  25. ->with('date', $date);
  26. }
  27.  
  28. @foreach ($ficha->contenidos as $contenido)
  29. {{ $contenido->nombre }}
  30. @endforeach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement