Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
bigrocs committed Sep 11, 2017
0 parents commit db7fc3c
Show file tree
Hide file tree
Showing 18 changed files with 848 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# corecmf

## Structure

```
src/
```

## Install

Via Composer

```bash
$ composer require corecmf/storage
```

## Usage
安装完成后需要在config/app.php中注册服务提供者到providers数组:
```
CoreCMF\Storage\StorageServiceProvider::class,
```
##install
```
php artisan corecmf:storage:install
```
52 changes: 52 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "corecmf/storage",
"type": "Library",
"description": "corecmf storage package",
"keywords": [
"CoreCMF",
"storage"
],
"homepage": "https://github.com/CoreCMF/storage",
"license": "laravel vue corecmf storage",
"authors": [
{
"name": "bigrocs",
"email": "[email protected]",
"homepage": "http://www.bigrocs.vip",
"role": "Developer"
}
],
"require": {
"php": "~5.6|~7.0",
"CoreCMF/admin": "1.1.*",
"CoreCMF/core": "1.1.*",
"illuminate/support": "~5.1"
},
"require-dev": {
"phpunit/phpunit" : "~4.0||~5.0||~6.0",
"squizlabs/php_codesniffer": "^2.3"
},
"autoload": {
"psr-4": {
"CoreCMF\\Storage\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"CoreCMF\\Storage\\": "tests"
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
}
}
16 changes: 16 additions & 0 deletions src/Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return [
'name' => 'Storage',
'title' => '社会第三方登录插件',
'description' => '第三方文件存储工具包括阿里云oss、七牛云存储、等等',
'author' => 'BigRocs',
'version' => 'v1.1.6',
'serviceProvider' => CoreCMF\Storage\StorageServiceProvider::class,
'install' => 'corecmf:storage:install',//安装artisan命令
'providers' => [
Jacobcyl\AliOSS\AliOssServiceProvider::class,//阿里云Oss 第三方驱动
CoreCMF\Storage\Providers\EventServiceProvider::class,//事件服务
CoreCMF\Storage\Providers\DriverServiceProvider::class,//驱动服务
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class SocialiteConfigsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('socialite_configs', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->string('name',30) ->comment('驱动名称');
$table->string('service',30) ->comment('驱动标识')->unique() ;
$table->string('client_id',60) ->comment('客户ID') ->nullable();
$table->string('client_secret',80) ->comment('客户密钥')->nullable();
$table->string('redirect',180) ->comment('回调地址')->nullable();
$table->boolean('status') ->comment('开关状态')->default(false);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('socialite_configs');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class SocialiteUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('socialite_users', function (Blueprint $table) {
$table->increments('user_id')->unsigned();
$table->string('github',64)->comment('GitHub') ->nullable();
$table->string('facebook',64)->comment('Facebook') ->nullable();
$table->string('google',64)->comment('Google') ->nullable();
$table->string('linkedin',64)->comment('LinkedIn') ->nullable();
$table->string('twitter',64)->comment('Twitter') ->nullable();
$table->string('qq',64)->comment('QQ') ->nullable();
$table->string('wechat',64)->comment('微信') ->nullable();
$table->string('wechatweb',64)->comment('微信WEB') ->nullable();
$table->string('weibo',64)->comment('微博') ->nullable();
$table->string('renren',64)->comment('人人') ->nullable();
$table->string('douban',64)->comment('豆瓣') ->nullable();
$table->string('baidu',64)->comment('百度') ->nullable();
$table->string('taobao',64)->comment('淘宝') ->nullable();
$table->string('alipay',64)->comment('支付宝') ->nullable();
$table->foreign('user_id')->references('id')->on('core_users')
->onUpdate('cascade')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('socialite_users');
}
}
87 changes: 87 additions & 0 deletions src/Databases/seeds/ConfigTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
namespace CoreCMF\Socialite\Databases\seeds;

use DB;
use Illuminate\Database\Seeder;

class ConfigTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('socialite_configs')->insert([
'name' => '微信',
'service' => 'wechat',
'redirect'=> 'http://corecmf.dev/OAuth/wechat/callback',
]);
DB::table('socialite_configs')->insert([
'name' => 'QQ',
'service' => 'qq',
'redirect'=> 'http://corecmf.dev/OAuth/qq/callback',
]);
DB::table('socialite_configs')->insert([
'name' => '微信WEB',
'service' => 'wechatweb',
'redirect'=> 'http://corecmf.dev/OAuth/wechatweb/callback',
]);
DB::table('socialite_configs')->insert([
'name' => '微博',
'service' => 'weibo',
'redirect'=> 'http://corecmf.dev/OAuth/weibo/callback',
]);
// DB::table('socialite_configs')->insert([
// 'name' => '人人',
// 'service' => 'renren',
// 'redirect'=> 'http://corecmf.dev/OAuth/renren/callback',
// ]);
DB::table('socialite_configs')->insert([
'name' => '豆瓣',
'service' => 'douban',
'redirect'=> 'http://corecmf.dev/OAuth/douban/callback',
]);
// DB::table('socialite_configs')->insert([
// 'name' => '百度',
// 'service' => 'baidu',
// 'redirect'=> 'http://corecmf.dev/OAuth/baidu/callback',
// ]);
// DB::table('socialite_configs')->insert([
// 'name' => '支付宝',
// 'service' => 'alipay',
// 'redirect'=> 'http://corecmf.dev/OAuth/alipay/callback',
// ]);
// DB::table('socialite_configs')->insert([
// 'name' => '淘宝',
// 'service' => 'taobao',
// 'redirect'=> 'http://corecmf.dev/OAuth/taobao/callback',
// ]);
DB::table('socialite_configs')->insert([
'name' => 'GitHub',
'service' => 'github',
'redirect'=> 'http://corecmf.dev/OAuth/github/callback',
]);
DB::table('socialite_configs')->insert([
'name' => 'FaceBook',
'service' => 'facebook',
'redirect'=> 'http://corecmf.dev/OAuth/facebook/callback',
]);
DB::table('socialite_configs')->insert([
'name' => 'Google',
'service' => 'google',
'redirect'=> 'http://corecmf.dev/OAuth/google/callback',
]);
DB::table('socialite_configs')->insert([
'name' => 'Linkedin',
'service' => 'linkedin',
'redirect'=> 'http://corecmf.dev/OAuth/linkedin/callback',
]);
DB::table('socialite_configs')->insert([
'name' => 'Twitter',
'service' => 'twitter',
'redirect'=> 'http://corecmf.dev/OAuth/twitter/callback',
]);
}
}
47 changes: 47 additions & 0 deletions src/Http/Console/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace CoreCMF\Storage\Http\Console;

use Illuminate\Console\Command;

use CoreCMF\Core\Support\Commands\Install;

class InstallCommand extends Command
{
/**
* install class.
* @var object
*/
protected $install;
/**
* The name and signature of the console command.
*
* @var string
* @translator laravelacademy.org
*/
protected $signature = 'corecmf:storage:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'storage packages install';

public function __construct(Install $install)
{
parent::__construct();
$this->install = $install;
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info($this->install->migrate());
$this->info($this->install->seed(\CoreCMF\Storage\Databases\seeds\ConfigTableSeeder::class));
}
}
43 changes: 43 additions & 0 deletions src/Http/Console/UninstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace CoreCMF\Storage\Http\Console;

use Illuminate\Console\Command;

use CoreCMF\Core\Support\Commands\Uninstall;
class UninstallCommand extends Command
{
protected $uninstall;
/**
* The name and signature of the console command.
*
* @var string
* @translator laravelacademy.org
*/
protected $signature = 'corecmf:storage:uninstall';

/**
* The console command description.
*
* @var string
*/
protected $description = 'storage packages uninstall';

public function __construct(Uninstall $uninstall)
{
parent::__construct();
$this->uninstall = $uninstall;
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//删除对应数据库数据
$this->info($this->uninstall->dropTable('storage_users'));
$this->info($this->uninstall->dropTable('storage_configs'));
}
}
Loading

0 comments on commit db7fc3c

Please sign in to comment.