1. Go to this page and download the library: Download tafadzwa/socialbeings 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/ */
tafadzwa / socialbeings example snippets
return [
'use_uuids' => false, // Default to false, can be set to true by the user
'user_table' => env('USER_TABLE', 'users'), // Default to 'users'
];
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TafadzwaLawrence\SocialBeings\Traits\CanFollow;
class User extends Authenticatable
{
use CanFollow;
// Other model properties and methods...
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use TafadzwaLawrence\SocialBeings\Traits\Followable;
class Post extends Model
{
use Followable;
// Other model properties and methods...
}
$user = User::find(1);
$post = Post::find(1);
$user->follow($post);
$user->unfollow($post);
$user->isFollowedBy($post);
$post->followers(); //Retrieve all the followers
$post->getFollowersCountAttribute(); // Count the number of followers
$post->getFormattedFollowersCountAttribute(); // Formats using 10K if count is > 1000
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TafadzwaLawrence\SocialBeings\Traits\CanLike;
class User extends Authenticatable
{
use CanLike;
// Other model properties and methods...
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use TafadzwaLawrence\SocialBeings\Traits\Likeable;
class Post extends Model
{
use Likeable;
// Other model properties and methods...
}
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TafadzwaLawrence\SocialBeings\Traits\CanFavor;
class User extends Authenticatable
{
use CanFavor;
// Other model properties and methods...
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use TafadzwaLawrence\SocialBeings\Traits\Favourable;
class Post extends Model
{
use Favourable;
// Other model properties and methods...
}
$user = User::find(1);
$post = Post::find(1);
$user->favour($post);
$post->unfavour($user->id);
$post->isFavouredBy($user->id)
$post->favorites;
$post->favorites_count; // K format for > 1000 favourites
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TafadzwaLawrence\SocialBeings\Traits\CanSubscribe;
class User extends Authenticatable
{
use CanSubscribe;
// Other model properties and methods...
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use TafadzwaLawrence\SocialBeings\Traits\Subscribable;
class Post extends Model
{
use Subscribable;
// Other model properties and methods...
}
$user = User::find(1);
$post = Post::find(1);
$user->subscribe($post);
$post->unsubscribe($user->id);
$post->isSubscribedBy($user->id)
$post->subscriptions;
$post->subscribers_count; // K format for > 1000 favourites