Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

laravel many to many get related posts by category

$post = Post::where('slug', '=', $slug)->first();

$related = Post::whereHas('tags', function ($q) use ($post) {
    return $q->whereIn('name', $post->tags->pluck('name')); 
})
->where('id', '!=', $post->id) // So you won't fetch same post
->get();
Comment

PREVIOUS NEXT
Code Example
Typescript :: state in react typescript 
Typescript :: click within click 
Typescript :: typescript loop through dictionary 
Typescript :: how to check events of a pod 
Typescript :: td elements in same line 
Typescript :: tsconfig paths not working react native 
Typescript :: export interface typescript 
Typescript :: typescript component props 
Typescript :: select constraints in sql 
Typescript :: nestjs mongoose schema nested 
Typescript :: typescript variables 
Typescript :: calling contract in ether.js 
Typescript :: typescript err type 
Typescript :: html table to csv 
Typescript :: python discord action when someone reacts to message 
Typescript :: typescript array of string array 
Typescript :: How to check if all elements are equal C# 
Typescript :: beziere curve function 
Typescript :: react inherit html input props 
Typescript :: angular validator email 
Typescript :: get top elements from a list python 
Typescript :: print all alphabets from a to z in java 
Typescript :: gettime is not a function typescript 
Typescript :: key with variable name in typescript 
Typescript :: git merge all previous commits on a branch 
Typescript :: kotlin get first n elements from list 
Typescript :: paths typescript 
Typescript :: what project management tool you use 
Typescript :: google sheets k format 
Typescript :: how to permit only a few values in dbms 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =