forked from aslan/applicant-site
add methods edit, delete, update for reception screen
This commit is contained in:
parent
7d0c12a086
commit
a7b2fd58d5
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue