diff --git a/app/Http/Controllers/Console/Link.php b/app/Http/Controllers/Console/Link.php index e5d066e..4dd1149 100644 --- a/app/Http/Controllers/Console/Link.php +++ b/app/Http/Controllers/Console/Link.php @@ -27,8 +27,30 @@ public function __construct() $this->data = $data->data; } + public function ViewEdit(Request $request, $userId): Application|Factory|View|RedirectResponse + { + // 查找友链 + $resultBlog = DB::table('blog_link') + ->find($userId); + $this->data['blog'] = [ + $resultBlog, + ]; + $this->data['blogSort'] = DB::table('blog_sort') + ->orderBy('sort') + ->get() + ->toArray(); + $this->data['blogColor'] = DB::table('blog_color') + ->orderBy('id') + ->get() + ->toArray(); + // 没有查询到执行删除 + if ($this->data['blog'][0] == null) return Response::redirectTo(route('console.friends-link.list')); + return view('console.friends-link.edit', $this->data); + } + protected function ViewList(Request $request): Factory|View|Application|RedirectResponse { + $this->data['request'] = $request; $dataMarge = [ 'blogFriendsTotal' => DB::table('blog_link') ->whereNotIn('blog_link.blogLocation', [0]) @@ -44,40 +66,46 @@ protected function ViewList(Request $request): Factory|View|Application|Redirect // 获取数据库信息 if (empty($request->page)) $request->page = 0; $this->data['blog'] = DB::table('blog_link') - ->whereNotIn('blogLocation',[0]) + ->whereNotIn('blogLocation', [0]) ->orderBy('id') - ->offset($request->page*10) + ->offset($request->page * 10) ->limit(10) ->get() ->toArray(); $this->data['blogCount'] = DB::table('blog_link') - ->whereNotIn('blogLocation',[0]) + ->whereNotIn('blogLocation', [0]) ->orderBy('id') ->count(); $this->data['webClass'] = [ 'active' => 'px-3 py-2 text-blue-600 border border-gray-300 bg-blue-50 hover:bg-blue-100 hover:text-blue-700 dark:border-gray-700 dark:bg-gray-700 dark:text-white', 'unactive' => 'px-3 py-2 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white', ]; - $this->data['blogCount'] = ceil($this->data['blogCount']/10); + $this->data['blogCount'] = ceil($this->data['blogCount'] / 10); + if ($this->data['request']->page > $this->data['blogCount'] - 1) return Response::redirectTo(route('console.friends-link.list')); } else { $this->data['blog'] = DB::select("SELECT * FROM xf_index.blog_link WHERE blogName LIKE '%$request->search%' OR blogUrl LIKE '%$request->search%' ORDER BY id"); } - $this->data['request'] = $request; - if ($this->data['request']->page > $this->data['blogCount']-1) return Response::redirectTo(route('console.friends-link.list')); $this->data = array_merge($this->data, $dataMarge); return view('console.friends-link.list', $this->data); } - protected function ViewCheck(Request $request): Factory|View|Application - { - return view('console.friends-link.check', $this->data); - } + protected function ViewCheck(Request $request): Factory|View|Application + { + return view('console.friends-link.check', $this->data); + } - protected function ViewEdit(Request $request) { - return view('console.friends-link.edit',$this->data); - } + protected function ViewAdd(Request $request): Factory|View|Application + { + return view('console.friends-link.add', $this->data); + } - protected function ViewAdd(Request $request) { - return view('console.friends-link.add',$this->data); - } + protected function ViewSort(): Factory|View|Application + { + return view('console.friends-link.sort',$this->data); + } + + protected function ViewColor(): Factory|View|Application + { + return view('concole.friends-link.color',$this->data); + } } diff --git a/database/migrations/2023_06_16_075646_create_blog_color_table.php b/database/migrations/2023_06_16_075646_create_blog_color_table.php new file mode 100644 index 0000000..ee730e8 --- /dev/null +++ b/database/migrations/2023_06_16_075646_create_blog_color_table.php @@ -0,0 +1,39 @@ +id(); + $table->boolean('onlyAdminUse')->default(0)->comment('只允许管理员使用'); + $table->string('colorLightType')->default('text-gray-500')->comment('颜色ID'); + $table->string('colorDarkType')->default('dark:text-gray-800')->comment('暗色颜色ID'); + $table->string('comment')->nullable()->comment('备注'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('blog_color'); + } +} diff --git a/database/migrations/2023_06_16_075950_update_blog_color_table.php b/database/migrations/2023_06_16_075950_update_blog_color_table.php new file mode 100644 index 0000000..0607c20 --- /dev/null +++ b/database/migrations/2023_06_16_075950_update_blog_color_table.php @@ -0,0 +1,77 @@ +insert([ + 'colorLightType' => 'text-gray-500', + 'colorDarkType' => 'dark:text-gray-800', + 'comment' => '灰色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-blue-500', + 'colorDarkType' => 'dark:text-blue-800', + 'comment' => '蓝色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-indigo-500', + 'colorDarkType' => 'dark:text-indigo-800', + 'comment' => '靛青色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-purple-500', + 'colorDarkType' => 'dark:text-purple-800', + 'comment' => '紫色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-pink-500', + 'colorDarkType' => 'dark:text-pink-800', + 'comment' => '粉色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-green-500', + 'colorDarkType' => 'dark:text-green-800', + 'comment' => '绿色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-yellow-500', + 'colorDarkType' => 'dark:text-yellow-800', + 'comment' => '蓝色' + ]); + DB::table('blog_color')->insert([ + 'colorLightType' => 'text-red-500', + 'colorDarkType' => 'dark:text-red-800', + 'comment' => '红色' + ]); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('blog_color', function (Blueprint $table) { + // + }); + } +} diff --git a/resources/views/console/friends-link/edit.blade.php b/resources/views/console/friends-link/edit.blade.php new file mode 100644 index 0000000..071f348 --- /dev/null +++ b/resources/views/console/friends-link/edit.blade.php @@ -0,0 +1,253 @@ + + + + + + + + + @include('modules.head') + {!! $webHeader !!} + + + + + +@include('console.modules.aside') + +
+
+ @include('console.modules.personal') +
+
友链修改
+
+
+
+
+

当前友链

+

超级友链

+

待审友链

+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+ + +
+
+ +
+ +
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+ + +
+
+ +
+ +
+
+
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+ +
+ +
+
+
+
+ +
+
+ + +
+
+ +
+ +
+
+
+
+
+
+ + +
+
+ + + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+ + 参考样式 +
+
+
+ Bordered avatar +
+

{{ $blog[0]->blogName }}

+

{{ $blog[0]->blogDescription }}

+
+
+
+
+
+ Bordered avatar +
+

{{ $blog[0]->blogName }}

+

{{ $blog[0]->blogDescription }}

+
+
+
+
+
+
+
+
+
+ + + + + diff --git a/resources/views/function/link.blade.php b/resources/views/function/link.blade.php index 44076e1..5031dca 100644 --- a/resources/views/function/link.blade.php +++ b/resources/views/function/link.blade.php @@ -30,7 +30,7 @@ class="relative left-[calc(50%-11rem)] aspect-[1155/678] w-[36.125rem] -translat @if($valueLink->blogLocation == $valueSort->id)
+ class="flex p-2 hover:bg-gray-100 bg-white border border-grey-200 rounded-lg shadow-lg sm:p-4 dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700 grid-cols-2 m-1"> 博主邮箱 *
- +
diff --git a/routes/web.php b/routes/web.php index 45165d2..b65ee3c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,6 +9,7 @@ use App\Http\Controllers\Console\Link as ConsoleLink; use App\Http\Controllers\Function\Link as UserLink; use App\Http\Controllers\Index; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Route; @@ -44,8 +45,14 @@ Route::redirect('list','list/1'); Route::get('list',[ConsoleLink::class,'ViewList'])->name('console.friends-link.list'); Route::get('check',[ConsoleLink::class,'ViewCheck'])->name('console.friends-link.check'); - Route::get('edit/{page}',[ConsoleLink::class,'ViewEdit'])->name('console.friends-link.edit'); + Route::get('edit/{userId}',function ($userId) { + $ConsoleLink = new ConsoleLink(); + $request = new Request(); + return $ConsoleLink->ViewEdit($request,$userId); + })->name('console.friends-link.edit'); Route::get('add',[ConsoleLink::class,'ViewAdd'])->name('console.friends-link.add'); + Route::get('sort',[ConsoleLink::class,'ViewSort'])->name('console.friends-link.sort'); + Route::get('color',[ConsoleLink::class,'ViewColor'])->name('console.friends-link.color'); }); });