LaravelPackages.net
Acme Inc.
Toggle sidebar
miladimos/laravel-social

a simple toolkit for social networks

1.277
9
0.7.1
About miladimos/laravel-social

miladimos/laravel-social is a Laravel package for a simple toolkit for social networks. It currently has 9 GitHub stars and 1.277 downloads on Packagist (latest version 0.7.1). Install it with composer require miladimos/laravel-social. Discover more Laravel packages by miladimos or browse all Laravel packages to compare alternatives.

Last updated

Starts Forks

Laravel social package

A toolkit package for social networks

Installation

  1. Run the command below to add this package:
composer require miladimos/laravel-social
  1. Open your config/socials.php and add the following to the providers array:
Miladimos\Social\Providers\SocialServiceProvider::class,
  1. Run the command below to install package:
php artisan social:install
  1. Run the command below to migrate database:
php artisan migrate

Features

Follow/UnFollow

First add Followable trait to user model


namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Miladimos\Social\Traits\Follows\Followable;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use HasFactory,
        Followable;
}

and enable to you follow/unfollow feature:

namespace App\Http\Controller;

use App\Models\User;

class YourController extends Controller
{
    public function index()
    {   
        $firstUser = User::first();
        $secondUser = User::find(2);

        $firstUser->follow($secondUser);
        $firstUser->unfollow($secondUser);
        $firstUser->toggleFollow($secondUser);

        $firstUser->followers;
        $firstUser->followings;
    }
}

Like

Comments