Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel follow and unfollow relationship

// users that are followed by this user
public function following() {
    return $this->belongsToMany(User::class, 'followers', 'follower_id', 'following_id');
}

// users that follow this user
public function followers() {
    return $this->belongsToMany(User::class, 'followers', 'following_id', 'follower_id');
}
Comment

PREVIOUS NEXT
Code Example
Php :: artisan new view 
Php :: laravel best practices 
Php :: add javascript to wordpress functions php 
Php :: jquery get data from php 
Php :: laravel crud example 
Php :: strcmp php 
Php :: laravel link to css or image 
Php :: wordpress add query string to url 
Php :: polymorphism in php 
Php :: how to get private images in s3 laravel 
Php :: Call to undefined method IlluminateDatabaseEloquentRelationsHasMany::attach() 
Php :: how to hide submenu admin wordpress 
Php :: cakephp 3 make migration 
Php :: parameter to laravel seeder 
Php :: php loopthrough object 
Php :: dynamic variable in php 
Php :: Best testing tools for php 
Php :: crypt password php 
Php :: merge pdf php fpdf 
Php :: php get constant value 
Php :: notification in laravel 8 
Php :: Get the Last Character of a String in PHP 
Php :: wordpress website redirecting to install page after migration 
Php :: laravel scheduler every 10 minutes 
Php :: php gd coordinate 
Php :: PHP Dependency Resolver 
Php :: Add a watermark to a new PDF document 
Php :: woocommerce status change date 
Php :: custom morph relation laravel 
Php :: how to select specific id in laravel using isset 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =