From 7d0c12a0866db67b6be86421c369800b69b72a25 Mon Sep 17 00:00:00 2001 From: aslan Date: Thu, 25 Jan 2024 08:59:34 +0300 Subject: [PATCH] lint fix --- .../Controllers/ReceptionScreenController.php | 37 ++++++------ .../Requests/StoreReceptionScreenRequest.php | 5 +- .../Requests/UpdateReceptionScreenRequest.php | 5 +- app/Services/PageScrapper.php | 15 ++--- .../admin-reception-screen/create.blade.php | 59 +++++++++++++++++++ .../admin-reception-screen/edit.blade.php | 59 +++++++++++++++++++ 6 files changed, 148 insertions(+), 32 deletions(-) create mode 100644 resources/views/admin-reception-screen/create.blade.php create mode 100644 resources/views/admin-reception-screen/edit.blade.php diff --git a/app/Http/Controllers/ReceptionScreenController.php b/app/Http/Controllers/ReceptionScreenController.php index 4400e0d..31708a3 100644 --- a/app/Http/Controllers/ReceptionScreenController.php +++ b/app/Http/Controllers/ReceptionScreenController.php @@ -23,32 +23,33 @@ class ReceptionScreenController extends Controller if (Auth::guest()) { abort(403); } - return view('admin-reception-screen.create'); + $receptionScreens = ReceptionScreen::all()->sortBy('position'); + return view('admin-reception-screen.create', compact('receptionScreens')); } public function store(StoreReceptionScreenRequest $request) { - } + if (Auth::guest()) { + abort(403, 'Вы не авторизованы!'); + } - /** - * Display the specified resource. - */ - public function show(ReceptionScreen $doceumentsOnline) + $validated = $request->validated(); + $receptionScreen = new ReceptionScreen(); + $receptionScreen->name = $validated['name']; + $receptionScreen->position = $validated['position']; + $receptionScreen->save(); + + return redirect()->route('admin-reception-screen.index'); + } + public function edit(ReceptionScreen $currentOnlineDocument) { - // + if (Auth::guest()) { + abort(403, 'Вы не авторизованы!'); + } + $onlineDocuments = ReceptionScreen::all()->sortBy('position'); + return view('admin-reception-screen.edit', compact('currentOnlineDocument', 'onlineDocuments')); } - /** - * Show the form for editing the specified resource. - */ - public function edit(ReceptionScreen $doceumentsOnline) - { - // - } - - /** - * Update the specified resource in storage. - */ public function update(UpdateReceptionScreenRequest $request, ReceptionScreen $doceumentsOnline) { // diff --git a/app/Http/Requests/StoreReceptionScreenRequest.php b/app/Http/Requests/StoreReceptionScreenRequest.php index a88963b..b03e0aa 100644 --- a/app/Http/Requests/StoreReceptionScreenRequest.php +++ b/app/Http/Requests/StoreReceptionScreenRequest.php @@ -11,7 +11,7 @@ class StoreReceptionScreenRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** @@ -22,7 +22,8 @@ class StoreReceptionScreenRequest extends FormRequest public function rules(): array { return [ - // + 'name' => 'required|max:255', + 'position' => 'required||int|max:255', ]; } } diff --git a/app/Http/Requests/UpdateReceptionScreenRequest.php b/app/Http/Requests/UpdateReceptionScreenRequest.php index 1ba920d..dad4306 100644 --- a/app/Http/Requests/UpdateReceptionScreenRequest.php +++ b/app/Http/Requests/UpdateReceptionScreenRequest.php @@ -11,7 +11,7 @@ class UpdateReceptionScreenRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** @@ -22,7 +22,8 @@ class UpdateReceptionScreenRequest extends FormRequest public function rules(): array { return [ - // + 'name' => 'required|max:255', + 'position' => 'required||int|max:255', ]; } } diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index f52aabe..21fa781 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -23,34 +23,29 @@ class PageScrapper $rez = preg_match_all($strForPregMatch, $page, $arr); return $content = $arr[1][0]; - - } public function normalizeURLFile($content) { - $rez = preg_match_all('//isU',$content,$arr); + $rez = preg_match_all('//isU', $content, $arr); $arr[1] = array_unique($arr[1]); foreach ($arr[1] as $el) { - if (!str_starts_with($el, 'https')){ - $content = str_replace($el,'https://mkgtu.ru' . $el,$content); + if (!str_starts_with($el, 'https')) { + $content = str_replace($el, 'https://mkgtu.ru' . $el, $content); } } return $content; - } - public function cutHTML($content,$strForScissors) + public function cutHTML($content, $strForScissors) { $arr = []; $rez = preg_match_all($strForScissors, $content, $arr); - $content = str_replace($arr[1],'',$content); + $content = str_replace($arr[1], '', $content); return $content; - - } } diff --git a/resources/views/admin-reception-screen/create.blade.php b/resources/views/admin-reception-screen/create.blade.php new file mode 100644 index 0000000..bd76efc --- /dev/null +++ b/resources/views/admin-reception-screen/create.blade.php @@ -0,0 +1,59 @@ +@extends('layouts.admin-layout') +@section('content') + + @auth() +
+
+

Создать пункт Экрана приема

+ {{ Form::open(['url' => route('admin-reception-screen.store'), 'method' => 'POST', 'class' => '']) }} +
+
+ {{ Form::label('position', 'Позиция') }} +
+
+ {{ Form::text('position', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('position') }} + @endif +
+ +
+ {{ Form::label('name', 'Название') }} +
+
+ {{ Form::text('name', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('name') }} + @endif +
+ +
+ {{ Form::submit('создать', ['class' => 'btn btn-primary']) }} +
+
+ {{ Form::close() }} +
+
+ + + + + + + + + @foreach($onlineDocuments as $onlineDocument) + + + + @endforeach + +
ПозицияНазвание
{{ $onlineDocument->position }}{{ $onlineDocument->name }}
+
+
+ @endauth +@endsection diff --git a/resources/views/admin-reception-screen/edit.blade.php b/resources/views/admin-reception-screen/edit.blade.php new file mode 100644 index 0000000..7bff02e --- /dev/null +++ b/resources/views/admin-reception-screen/edit.blade.php @@ -0,0 +1,59 @@ +@extends('layouts.admin-layout') +@section('content') + + @auth() +
+
+

Изменить пункт Экрана приема

+ {{ Form::open(['url' => route('admin-reception-screen.update', $currentOnlineDocument), 'method' => 'PATCH', 'class' => '']) }} +
+
+ {{ Form::label('position', 'Позиция') }} +
+
+ {{ Form::text('position', $currentOnlineDocument->position, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('position') }} + @endif +
+ +
+ {{ Form::label('name', 'Название') }} +
+
+ {{ Form::text('name', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('name') }} + @endif +
+ +
+ {{ Form::submit('создать', ['class' => 'btn btn-primary']) }} +
+
+ {{ Form::close() }} +
+
+ + + + + + + + + @foreach($onlineDocuments as $onlineDocument) + + + + @endforeach + +
ПозицияНазвание
{{ $onlineDocument->position }}{{ $onlineDocument->name }}
+
+
+ @endauth +@endsection