mercredi 28 février 2018

Select items by data from pivot table

I have a summary table created in this way:

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('article_tag', function (Blueprint $table) {
        $table->integer('article_id')->unsigned();
        $table->foreign('article_id')->references('id')->on('articles');
        $table->integer('tag_id')->unsigned();
        $table->foreign('tag_id')->references('id')->on('tags');

    });
}

Result:

article_id tag_id
1            3
1            4
2            4

How select article_id by tag_id?

My attempts: $article = Article::select(['id', 'title', 'text', 'image_file'])->where('tags', $request);



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2HU5XtF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire