lundi 15 octobre 2018

How to get related rows of spatie/laravel-tags object?

I added spatie/laravel-tags plugin https://docs.spatie.be/laravel-tags/v2/basic-usage/using-tags to my Laravel 5.7 app and added it in one of my models:

<?php

namespace App;

use DB;
...
use \Spatie\Tags\HasTags;

class Vote extends MyAppModel
{
    use HasTags;


    protected $table = 'votes';
    protected $primaryKey = 'id';
    ...

I succesfully added some data in my init seeders, but I did not find how can I retrieve list of related tags of vote object:

$vote           = Vote::find($vote_id);
$relatedTags    = $vote::Tags([])->get(); // That fails

Which is the right way?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire