定制 lartie/attach-social-account 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lartie/attach-social-account

Composer 安装命令:

composer require lartie/attach-social-account

包简介

Пакет для подключения аккаунтов социальный сетей к пользователю для Laravel 5.2

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

Installation

Composer

composer require lartie/attach-social-account

Service Provider

Add the package to your application service providers in config/app.php file.

'providers' => [
    
    /*
     * Application Service Providers..
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,
    ...
    
    /*
     * Extensions
     */
    LArtie\AttachSocialAccount\ServiceProvider::class,

],

Config File And Migrations

Publish the package config file and migrations to your application. Run these commands inside your terminal.

php artisan vendor:publish

And also run migrations.

php artisan migrate

This uses the default users table which is in Laravel. You should already have the migration file for the users table available and migrated.

HasSocialAccount Trait And Contract

Include HasSocialAccount trait and also implement HasSocialAccount contract inside your User model.

use LArtie\AttachSocialAccount\Core\Traits\HasSocialAccount;
use LArtie\AttachSocialAccount\Core\Contracts\HasSocialAccount as HasSocialAccountContract;

class User extends Authenticatable implements HasSocialAccountContract
{
    use HasSocialAccount;

And that's it!

Usage

 $user = User::first();
 
 $vkData = [
     'token' => 'token',
     'uid' => 'user_id',
     'nickname' => 'username',
     'name' => 'first name and last name',
     'email' => 'example@gmail.com',
     'avatar' => 'link_to',
 ];

Creating Social Network

$socialNetwork = SocialNetworks::create([
    'provider' => 'vkontakte', 
    'short_name' => 'vk'
]);

Attach Social Account

$user->attachSocialAccountById($socialNetwork->id, $vkData);

or

$user->attachSocialAccountByShortName('vk', $vkData);

or

$user->attachSocialAccountByProvider('vkontakte', $vkData);

Detach Social Account

$user->detachSocialAccountById($socialNetwork->id);

or

$user->detachSocialAccountByShortName('vk');

or

$user->detachSocialAccountByProvider('vkontakte');

Checking

$user->hasSocialAccountById($socialNetwork->id);

or

$user->hasSocialAccountByShortName('vk');

or

$user->hasSocialAccountByProvider('vkontakte');

Blade Extensions

@providerExists('vkontakte') {
// see detach button, etc..
}

@providerNotExists('vkontakte') {
// see attach button, etc.. 
}

For more information visit trait HasSocialAccount or contract HasSocialAccount

License

This package is free software distributed under the terms of the MIT license.

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固