PHP code example of zaghadon / laravel-social

1. Go to this page and download the library: Download zaghadon/laravel-social library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zaghadon / laravel-social example snippets


    Zaghadon\Social\Providers\SocialServiceProvider::class,
    

    php artisan migrate
    


namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Zaghadon\Social\Traits\Like\Likeable;

class Post extends Model
{
    use HasFactory,
        Likeable;
}



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zaghadon\Social\Traits\Like\CanLike;

class User extends Authenticatable
{
    use HasFactory,
        CanLike;
}



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Zaghadon\Social\Traits\Comment\Commentable;

class Post extends Model
{
    use HasFactory,
        Commentable;
}



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zaghadon\Social\Traits\Comment\Commentor;

class User extends Authenticatable
{
    use HasFactory,
        Commentor;
}



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Zaghadon\Social\Traits\Bookmark\Bookmarkable;

class Post extends Model
{
    use HasFactory,
        Bookmarkable;
}



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zaghadon\Social\Traits\Bookmark\CanBookmark;

class User extends Authenticatable
{
    use HasFactory,
        CanBookmark;
}



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zaghadon\Social\Traits\Follow\Followable;

class User extends Authenticatable
{
    use HasFactory,
        Followable;
}



namespace App\Http\Controllers;

use App\Models\Post;

class PostController extends Controller
{
    public function index()
    {
        $post = Post::find(1);

        $post->likes // return all likes

        
    }
}

shell
    php artisan social:install