Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $tile = TilesTile::find($tile_id);
- $tile->tags()->attach($tag_array);
- <?php namespace Tiles;
- use IlluminateDatabaseEloquentModel;
- class Tile extends Model {
- /**
- * The Tile table
- * @var string
- */
- protected $table = 'tiles';
- /**
- * Pivot table for tags
- * @var string
- */
- protected $pivot = 'tag_tile';
- /**
- * Get the tags associated with the given tile
- *
- * @return IlluminateDatabaseEloquentRelationsBelongsToMany
- */
- public function tags() {
- return $this->belongsToMany('TilesTag', $this->pivot, 'tile_id', 'tag_id')->withTimestamps();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement