add methods edit, delete, update for reception screen
Tests & Lint & Deploy to Railway / build (20.x, 8.2) (push) Successful in 1m57s Details
Tests & Lint & Deploy to Railway / deploy (8.1) (push) Failing after 1m15s Details

This commit is contained in:
aslan 2024-01-25 10:22:23 +03:00
parent 7d0c12a086
commit a7b2fd58d5
4 changed files with 47 additions and 40 deletions

View File

@ -14,8 +14,8 @@ class ReceptionScreenController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.index', compact('onlineDocuments'));
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.index', compact('receptionScreens'));
}
public function create(): View
@ -29,10 +29,6 @@ class ReceptionScreenController extends Controller
public function store(StoreReceptionScreenRequest $request)
{
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$receptionScreen->name = $validated['name'];
@ -41,25 +37,35 @@ class ReceptionScreenController extends Controller
return redirect()->route('admin-reception-screen.index');
}
public function edit(ReceptionScreen $currentOnlineDocument)
public function edit($id)
{
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
$receptionScreens = $receptionScreen->all()->sortBy('position');
return view('admin-reception-screen.edit', compact('currentReceptionScreen', 'receptionScreens'));
}
public function update(UpdateReceptionScreenRequest $request, $id)
{
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
$currentReceptionScreen->name = $validated['name'];
$currentReceptionScreen->position = $validated['position'];
$currentReceptionScreen->save();
return redirect()->route('admin-reception-screen.index');
}
public function destroy($id)
{
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
if ($currentReceptionScreen->files()->exists()) {
return back();
}
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.edit', compact('currentOnlineDocument', 'onlineDocuments'));
}
$currentReceptionScreen->delete();
public function update(UpdateReceptionScreenRequest $request, ReceptionScreen $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(ReceptionScreen $doceumentsOnline)
{
//
return redirect()->route('admin-reception-screen.index');
}
}

View File

@ -46,10 +46,10 @@
</tr>
</thead>
<tbody>
@foreach($onlineDocuments as $onlineDocument)
@foreach($receptionScreens as $receptionScreen)
<tr>
<th scope="row">{{ $onlineDocument->position }}</th>
<td>{{ $onlineDocument->name }}</td>
<th scope="row">{{ $receptionScreen->position }}</th>
<td>{{ $receptionScreen->name }}</td>
@endforeach
</tbody>
</table>

View File

@ -5,13 +5,14 @@
<div class="row">
<div class="col">
<h1 class=""> Изменить пункт Экрана приема</h1>
{{ Form::open(['url' => route('admin-reception-screen.update', $currentOnlineDocument), 'method' => 'PATCH', 'class' => '']) }}
{{ Form::open(['url' => route('admin-reception-screen.update', $currentReceptionScreen), 'method' => 'PATCH', 'class' => '']) }}
<div class="col">
<div>
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2">
{{ Form::text('position', $currentOnlineDocument->position, ['class' => 'form-control']) }}
{{ Form::text('position', $currentReceptionScreen->position, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -23,7 +24,7 @@
{{ Form::label('name', 'Название') }}
</div>
<div class="mt-2">
{{ Form::text('name', '', ['class' => 'form-control']) }}
{{ Form::text('name', $currentReceptionScreen->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -32,7 +33,7 @@
</div>
<div class="mt-4">
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
{{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
@ -46,10 +47,10 @@
</tr>
</thead>
<tbody>
@foreach($onlineDocuments as $onlineDocument)
@foreach($receptionScreens as $receptionScreen)
<tr>
<th scope="row">{{ $onlineDocument->position }}</th>
<td>{{ $onlineDocument->name }}</td>
<th scope="row">{{ $receptionScreen->position }}</th>
<td>{{ $receptionScreen->name }}</td>
@endforeach
</tbody>
</table>

View File

@ -15,17 +15,17 @@
</tr>
</thead>
<tbody>
@foreach($onlineDocuments as $onlineDocument)
@foreach($receptionScreens as $receptionScreen)
<tr>
<th scope="row">{{ $onlineDocument->position }}</th>
<td>{{ $onlineDocument->name }}</td>
<td><a href="{{ route("admin-reception-screen.edit", $onlineDocument) }}" class="btn btn-secondary">редактировать</a>
<th scope="row">{{ $receptionScreen->position }}</th>
<td>{{ $receptionScreen->name }}</td>
<td><a href="{{ route("admin-reception-screen.edit", $receptionScreen) }}" class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('admin-reception-screen.destroy', $onlineDocument) }}" class="btn btn-danger">
href="{{ route('admin-reception-screen.destroy', $receptionScreen) }}" class="btn btn-danger">
удалить
</a>
</td>
@if(count($onlineDocument->files) !== 0)
@if(count($receptionScreen->files) !== 0)
</tr>
<tr>
<td colspan="3">
@ -39,7 +39,7 @@
</thead>
<tbody>
@foreach($onlineDocument->files->sortBy('position') as $file)
@foreach($receptionScreen->files->sortBy('position') as $file)
<tr>
<th scope="row">{{ $file->position }}</th>
<td>{{ $file->name }}</td>