Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $tile = TilesTile::find($tile_id);
  2. $tile->tags()->attach($tag_array);
  3.  
  4. <?php namespace Tiles;
  5.  
  6. use IlluminateDatabaseEloquentModel;
  7.  
  8. class Tile extends Model {
  9.  
  10. /**
  11. * The Tile table
  12. * @var string
  13. */
  14. protected $table = 'tiles';
  15.  
  16. /**
  17. * Pivot table for tags
  18. * @var string
  19. */
  20. protected $pivot = 'tag_tile';
  21.  
  22.  
  23. /**
  24. * Get the tags associated with the given tile
  25. *
  26. * @return IlluminateDatabaseEloquentRelationsBelongsToMany
  27. */
  28. public function tags() {
  29.  
  30. return $this->belongsToMany('TilesTag', $this->pivot, 'tile_id', 'tag_id')->withTimestamps();
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement