李帅

1.新增setting表.

2.后台新增setting功能.
......@@ -38,6 +38,7 @@ class MembershipController extends AdminController
->expand(function (){
$th = ['id','price','line_price','limit_days','limit_unit'];
$data = MembershipGood::query()->where('membership_id',$this->id)->get($th)->toArray();
$th = ['id','价格','划线价格','有效期','单位'];
return Table::make($th, $data);
});
$grid->column('video_url');
......
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\LoginSetting;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Widgets\Card;
class SettingController extends AdminController
{
protected $title = 'App系统设置';
/**
* Index interface.
*
* @param Content $content
* @return Content
*/
public function index(Content $content)
{
return $content
->translation($this->translation())
->title($this->title())
->description($this->description()['index'] ?? trans('admin.list'))
->body(function ()use ($content){
// 一行多列
$content->row(function (Row $row) {
$row->column(4, $this->loginGrid());
// $row->column(6, $this->grid());
});
});
}
/**
* Make a grid builder.
*
* @return Card
*/
protected function loginGrid()
{
$grid = Grid::make(new LoginSetting(), function (Grid $grid) {
$grid->disablePagination();
$grid->disableActions();
$grid->tableCollapse(false);
$grid->disableCreateButton();
$grid->disableRefreshButton();
$grid->disableRowSelector();
$grid->column('icon')->display(function ($item){
return "<i class='$item'></i>";
});
$grid->column('name');
$grid->column('state')->switch();
});
$card = new Card();
$card->title('登录设置')->withHeaderBorder()->content($grid);
return $card;
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\Setting as Model;
use Dcat\Admin\Grid;
use Dcat\Admin\Repositories\EloquentRepository;
class LoginSetting extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
public function get(Grid\Model $model)
{
$setting = Model::query()->where('keyword', 'login_setting')->where('terminal', 1)->first();
return json_decode($setting->content,true);
}
}
......@@ -46,4 +46,10 @@ Route::group([
// $router->resource('/push', 'PushController');
});
$router->group(['prefix'=>'/setting'],function (Router $router){
/** App设置*/
$router->resource('/android', 'SettingController');
$router->resource('/ios', 'SettingController');
});
});
......
......@@ -84,4 +84,5 @@ class HomeController extends Controller
{
//
}
}
......
<?php
namespace App\Http\Controllers\V1;
use App\Http\Controllers\Controller;
use App\Models\Setting;
use Jiannei\Response\Laravel\Support\Facades\Response;
class SettingController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
if ($this->getClientTerminal() == 'ios'){
$terminal = 2;
}else{
$terminal = 1;
}
$array = [];
$settings = Setting::query()->where('terminal', $terminal)
->where('version', Setting::CURRENT_VERSION)
->get();
foreach ($settings as $setting){
$array[$setting->keyword] = $setting->content;
}
return Response::success($array);
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
const CURRENT_VERSION = 1;
use HasFactory;
public function getContentAttribute()
{
return json_decode($this->attributes['content'],true);
}
}
......@@ -8,9 +8,11 @@
namespace App\Payment;
use App\Models\Order;
class AliPayment implements PaymentInterface
{
public function prepare()
public function prepare(Order $order)
{
// TODO: Implement prepare() method.
}
......
......@@ -51,6 +51,17 @@ class WechatPayment implements PaymentInterface
public function prepare(Order $order)
{
// todo
return [
'appid' => env('WECHAT_APPID'),
'partnerid' => env('WECHAT_PAY_MCH_ID'),
'prepayid' => 'wx261153585405162d4d02642eabe7000000',
'package' => 'Sign=WXPay',
'noncestr' => '5K8264ILTKCH16CQ2502SI8ZNMTM67VS',
'timestamp' => '1647249156',
'sign' => 'oR9d8PuhnIc+YZ8cBHFCwfgpaK9gd7vaRvkYD7rthRAZ\/X+QBhcCYL21N7cHCTUxbQ+EAt6Uy+lwSN22f5YZvI45MLko8Pfso0jm46v5hqcVwrk6uddkGuT+Cdvu4WBqDzaDjnNa5UK3GfE1Wfl2gHxIIY5lLdUgWFts17D4WuolLLkiFZV+JSHMvH7eaLdT9N5GBovBwu5yYKUR7skR8Fu+LozcSqQixnlEZUfyE55feLOQTUYzLmR9pNtPbPsu6WVhbNHMS3Ss2+AehHvz+n64GDmXxbX++IOBvm2olHu3PsOUGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg=='
];
$body = [
'appid' => env('WECHAT_APPID'),
'mchid' => env('WECHAT_PAY_MCH_ID'),
......
......@@ -17,6 +17,9 @@
"laravel/socialite": "^5.2",
"laravel/tinker": "^2.5",
"socialiteproviders/apple": "^5.0",
"socialiteproviders/facebook": "^4.1",
"socialiteproviders/tiktok": "^4.0",
"socialiteproviders/twitter": "^4.1",
"socialiteproviders/weixin": "^4.1"
},
"require-dev": {
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2a26b7c5aa12ce822287c40356916250",
"content-hash": "aa46d9704a095f2da2d480e58e475235",
"packages": [
{
"name": "asm89/stack-cors",
......@@ -4312,6 +4312,53 @@
"time": "2021-08-04T07:43:47+00:00"
},
{
"name": "socialiteproviders/facebook",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/SocialiteProviders/Facebook.git",
"reference": "9b94a9334b5d0f61de8f5a20928d63d4d8f4e00d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SocialiteProviders/Facebook/zipball/9b94a9334b5d0f61de8f5a20928d63d4d8f4e00d",
"reference": "9b94a9334b5d0f61de8f5a20928d63d4d8f4e00d",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-json": "*",
"php": "^7.2 || ^8.0",
"socialiteproviders/manager": "~4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"SocialiteProviders\\Facebook\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oleksandr Prypkhan (Alex Wells)",
"email": "autaut03@googlemail.com"
}
],
"description": "Facebook (facebook.com) OAuth2 Provider for Laravel Socialite",
"support": {
"source": "https://github.com/SocialiteProviders/Facebook/tree/4.1.0"
},
"time": "2020-12-01T23:10:59+00:00"
},
{
"name": "socialiteproviders/manager",
"version": "v4.1.0",
"source": {
......@@ -4392,6 +4439,108 @@
"time": "2022-01-23T22:40:23+00:00"
},
{
"name": "socialiteproviders/tiktok",
"version": "4.0.1",
"source": {
"type": "git",
"url": "https://github.com/SocialiteProviders/TikTok.git",
"reference": "435bd93c2c91df1d34b85dcd19bb39c1ade56aad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SocialiteProviders/TikTok/zipball/435bd93c2c91df1d34b85dcd19bb39c1ade56aad",
"reference": "435bd93c2c91df1d34b85dcd19bb39c1ade56aad",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^7.2 || ^8.0",
"socialiteproviders/manager": "~4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"SocialiteProviders\\TikTok\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Thomas Banks",
"email": "thomas@tombanks.me"
}
],
"description": "TikTok (tiktok.com) OAuth2 Provider for Laravel Socialite",
"keywords": [
"TikTok ",
"laravel",
"oauth",
"provider",
"socialite"
],
"support": {
"docs": "https://socialiteproviders.com/tiktok",
"issues": "https://github.com/socialiteproviders/providers/issues",
"source": "https://github.com/socialiteproviders/providers"
},
"time": "2022-02-08T01:22:50+00:00"
},
{
"name": "socialiteproviders/twitter",
"version": "4.1.1",
"source": {
"type": "git",
"url": "https://github.com/SocialiteProviders/Twitter.git",
"reference": "e5edf2b6e3f37e64be6488111629ed5e41e645ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SocialiteProviders/Twitter/zipball/e5edf2b6e3f37e64be6488111629ed5e41e645ad",
"reference": "e5edf2b6e3f37e64be6488111629ed5e41e645ad",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-json": "*",
"php": "^7.2 || ^8.0",
"socialiteproviders/manager": "~4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"SocialiteProviders\\Twitter\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Faust",
"email": "hello@brianfaust.de"
}
],
"description": "Twitter OAuth1 Provider for Laravel Socialite",
"support": {
"source": "https://github.com/SocialiteProviders/Twitter/tree/4.1.1"
},
"time": "2021-01-29T05:41:11+00:00"
},
{
"name": "socialiteproviders/weixin",
"version": "4.1.0",
"source": {
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('标题');
$table->string('keyword')->comment('关键字');
$table->json('content')->comment('内容');
$table->unsignedTinyInteger('version')->default(1)->comment('版本');
$table->unsignedTinyInteger('terminal')->comment('1=安卓,2=IOS,3=全平台');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('settings');
}
}
......@@ -30,6 +30,8 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Route
/**首页*/
$api->apiResource('/home', 'HomeController');
$api->get('/setting', 'SettingController@index');
/** 临境 */
$api->apiResource('/immersive', 'ImmerseController');
......