策略创建表单

This commit is contained in:
Wisp X 2022-01-24 17:00:05 +08:00
parent 035e1d140b
commit 746eaa8a92
10 changed files with 87 additions and 26 deletions

View File

@ -15,4 +15,7 @@ final class KodoOption
/** @var string Bucket */
const Bucket = 'bucket';
/** @var string 根目录 */
const Root = 'root';
}

View File

@ -14,6 +14,21 @@ class StrategyRequest extends FormRequest
*/
public function rules()
{
return [];
return [
'name' => 'required|max:60',
'intro' => 'max:2000',
'configs.root' => 'max:1000',
'configs.domain' => 'required|url',
];
}
public function attributes()
{
return [
'name' => '名称',
'intro' => '简介',
'configs.root' => '储存路径',
'configs.domain' => '访问域名',
];
}
}

View File

@ -8,7 +8,6 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
@ -56,10 +55,8 @@ class Strategy extends Model
protected static function booted()
{
static::creating(function (self $strategy) {
$strategy->configs = collect([
LocalOption::Domain => rtrim(env('APP_URL'), '/').'/uploads',
]);
static::saving(function (self $strategy) {
$strategy->configs['domain'] = rtrim($strategy->configs['domain'], '/').'/uploads';
});
}

26
composer.lock generated
View File

@ -6038,16 +6038,16 @@
},
{
"name": "fakerphp/faker",
"version": "v1.17.0",
"version": "v1.18.0",
"source": {
"type": "git",
"url": "https://github.com/FakerPHP/Faker.git",
"reference": "b85e9d44eae8c52cca7aa0939483611f7232b669"
"reference": "2e77a868f6540695cf5ebf21e5ab472c65f47567"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/b85e9d44eae8c52cca7aa0939483611f7232b669",
"reference": "b85e9d44eae8c52cca7aa0939483611f7232b669",
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/2e77a868f6540695cf5ebf21e5ab472c65f47567",
"reference": "2e77a868f6540695cf5ebf21e5ab472c65f47567",
"shasum": "",
"mirrors": [
{
@ -6078,7 +6078,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "v1.17-dev"
"dev-main": "v1.18-dev"
}
},
"autoload": {
@ -6103,9 +6103,9 @@
],
"support": {
"issues": "https://github.com/FakerPHP/Faker/issues",
"source": "https://github.com/FakerPHP/Faker/tree/v1.17.0"
"source": "https://github.com/FakerPHP/Faker/tree/v1.18.0"
},
"time": "2021-12-05T17:14:47+00:00"
"time": "2022-01-23T17:56:23+00:00"
},
{
"name": "filp/whoops",
@ -7339,16 +7339,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.12",
"version": "9.5.13",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "93d4bf4c37aec6384bb9e5d390d9049a463a7256"
"reference": "597cb647654ede35e43b137926dfdfef0fb11743"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/93d4bf4c37aec6384bb9e5d390d9049a463a7256",
"reference": "93d4bf4c37aec6384bb9e5d390d9049a463a7256",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743",
"reference": "597cb647654ede35e43b137926dfdfef0fb11743",
"shasum": "",
"mirrors": [
{
@ -7432,7 +7432,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.12"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13"
},
"funding": [
{
@ -7444,7 +7444,7 @@
"type": "github"
}
],
"time": "2022-01-21T05:54:47+00:00"
"time": "2022-01-24T07:33:35+00:00"
},
{
"name": "sebastian/cli-parser",

16
public/css/app.css vendored
View File

@ -712,6 +712,9 @@ select {
.col-span-6 {
grid-column: span 6 / span 6;
}
.col-span-3 {
grid-column: span 3 / span 3;
}
.m-2 {
margin: 0.5rem;
}
@ -1169,6 +1172,9 @@ select {
.rounded {
border-radius: 0.25rem;
}
.rounded-none {
border-radius: 0px;
}
.rounded-l-md {
border-top-left-radius: 0.375rem;
border-bottom-left-radius: 0.375rem;
@ -1206,6 +1212,12 @@ select {
.border-b {
border-bottom-width: 1px;
}
.border-r-0 {
border-right-width: 0px;
}
.border-l-0 {
border-left-width: 0px;
}
.border-solid {
border-style: solid;
}
@ -1869,6 +1881,10 @@ select {
grid-column: span 3 / span 3;
}
.sm\:col-span-2 {
grid-column: span 2 / span 2;
}
.sm\:-mx-6 {
margin-left: -1.5rem;
margin-right: -1.5rem;

View File

@ -1,3 +1,5 @@
@section('title', '创建角色组')
<x-app-layout>
<div class="my-6 md:my-10">
@include('admin.group.tips')

View File

@ -1,3 +1,5 @@
@section('title', '编辑角色组')
<x-app-layout>
<div class="my-6 md:my-10">
@include('admin.group.tips')

View File

@ -1,10 +1,25 @@
@section('title', '创建储存策略')
<x-app-layout>
<div class="my-6 md:my-10">
<div class="md:mt-0 md:col-span-2">
<form action="{{ route('admin.group.create') }}" method="POST">
<form action="{{ route('admin.strategy.create') }}" method="POST">
<div class="overflow-hidden rounded-md">
<div class="px-4 py-5 bg-white sm:p-6 space-y-4">
<div class="col-span-6">
<label class="block">
<span class="text-gray-700">选择角色组</span>
<select class="block w-full mt-1 form-multiselect" multiple>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>
</select>
</label>
</div>
<div class="col-span-6">
<label for="name" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>名称</label>
<input type="text" name="name" id="name" placeholder="请输入策略名称" autocomplete="name" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@ -16,7 +31,7 @@
</div>
<div class="col-span-6 sm:col-span-3">
<label for="key" class="block text-sm font-medium text-gray-700">储存策略</label>
<label for="key" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>储存策略</label>
<select id="key" name="key" autocomplete="key" class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@foreach(\App\Models\Strategy::DRIVERS as $key => $driver)
<option value="{{ $key }}" {{ $loop->first ? 'selected' : '' }}>{{ $driver }}</option>
@ -25,10 +40,19 @@
</div>
<div class="col-span-6">
<div class="mb-4 hidden" data-driver="{{ \App\Enums\StrategyKey::Local }}">
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[domain]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>访问域名</label>
<input type="text" name="configs[domain]" id="configs[domain]" autocomplete="text" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入图片访问域名">
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[root]" class="block text-sm font-medium text-gray-700">储存路径</label>
<input type="text" name="configs[root]" id="configs[root]" autocomplete="text" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="图片保存位置,可为空">
<small class="text-yellow-500"><i class="fas fa-exclamation"></i> 储存路径设置错误或没有读写权限可能会导致图片保存失败</small>
</div>
</div>
<div class="col-span-6 mb-4 hidden" data-driver="{{ \App\Enums\StrategyKey::Local }}">
<div class="col-span-3 sm:col-span-2">
<label for="configs[domain]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>访问域名</label>
<div class="mt-1 flex rounded-md shadow-sm">
<input type="text" name="configs[domain]" id="configs[domain]" class="focus:ring-indigo-500 focus:border-indigo-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300" placeholder="请输入图片访问域名,需要加 http(s)://">
<span class="inline-flex items-center px-3 rounded-r-md border border-l-0 border-gray-300 bg-gray-50 text-gray-500 text-sm">/uploads</span>
</div>
</div>
</div>

View File

@ -1,3 +1,5 @@
@section('title', '编辑储存策略')
<x-app-layout>
edit
</x-app-layout>

View File

@ -1,4 +1,4 @@
@section('title', '角色组管理')
@section('title', '储存策略管理')
<x-app-layout>
<div class="my-6 md:my-10">