This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Laravel 3 vs 4

By: a guest on Aug 11th, 2013  |  syntax: PHP  |  size: 0.61 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Laravel 3 Site Model i can do somethink like that:
  2. public function adformats()  {
  3.         return $this->has_many_and_belongs_to('Adformat','sites_adformats')->with('zone_id');
  4. }
  5.  
  6. In my Laravel 3 Controller i can do somethink like that:
  7. $site->adformats()->pivot()->where('site_id','=',$site->id)->where('adformat_id','=',$adformatid)->update(array('zone_id' => $zoneid));
  8.  
  9. What do I need to do in Laravel 4?
  10. In My Model i do this:
  11. public function adformats()  {
  12.         return $this->belongsToMany('Adformat','sites_adformats')->withPivot('zone_id');
  13. }
  14. Is that right?
  15.  
  16. How can access it now in Controller in Laravel 4?
clone this paste RAW Paste Data