Last active
May 1, 2018 12:18
-
-
Save wertex/cb898d99018e630fa9a42b23501d7e86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('admin.layouts.app_admin') | |
@section('content') | |
<div class="container"> | |
@component('admin.components.breadcrumb') | |
@slot('title') Редактирование сотрудника @endslot | |
@slot('parent') Список сотрудников @endslot | |
@slot('active') Редактирование @endslot | |
@endcomponent | |
<form class="form-horizontal" action="{{route('admin.employee.update', $employee)}}" method="post"> | |
@method('PUT') | |
@csrf | |
{{-- Form include --}} | |
@include('admin.employee.partials.form') | |
</form> | |
</div> | |
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Employee extends Model | |
{ | |
// Mass assigned | |
protected $fillable = [ | |
'last_name', | |
'first_name', | |
'middle_name', | |
'gender', | |
'birthdate', | |
'telephone', | |
'mobile', | |
'ip_telephone', | |
'email', | |
'departament_id', | |
'position_id' | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function update(Request $request, Employee $employee) | |
{ | |
$employee->update($request->all()); | |
return redirect()->route('admin.employee.index'); | |
} | |
Состав $request следующий: | |
array(12) { | |
["_method"]=> | |
string(3) "PUT" | |
["_token"]=> | |
string(40) "GH19wQ7k98aKld1PUkx5jZVXO5v7lFbWHeKR5FwF" | |
["last_name"]=> | |
string(12) "Иванов" | |
["first_name"]=> | |
string(18) "Иван" | |
["middle_name"]=> | |
string(20) "Иванович" | |
["birthdate"]=> | |
string(10) "2018-12-31" | |
["telephone"]=> | |
NULL | |
["ip_telephone"]=> | |
NULL | |
["mobile"]=> | |
NULL | |
["email"]=> | |
NULL | |
["departamen_id"]=> | |
string(1) "1" | |
["position_id"]=> | |
string(1) "1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="row"> | |
<div class="col-sm"> | |
<div class="form-group"> | |
<label for="departamen_id">Отдел</label> | |
<select id="departamen_id" name="departamen_id" class="form-control form-control-sm"> | |
@if(isset($employee->departament_id)) | |
@include('admin.employee.partials.departament', ['departaments' => $departaments, 'departament_id' => $employee->departament_id]) | |
@else | |
<option value="" selected="selected"></option> | |
@include('admin.employee.partials.departament', ['departaments' => $departaments]) | |
@endif | |
</select> | |
</div> | |
</div> | |
<div class="col-sm"> | |
<div class="form-group"> | |
<label for="position_id">Должность</label> | |
<select id="position_id" name="position_id" class="form-control form-control-sm"> | |
@if(isset($employee->position_id)) | |
@include('admin.employee.partials.position', ['positions' => $positions, 'position_id' => $employee->position_id]) | |
@else | |
<option value="" selected="selected"></option> | |
@include('admin.employee.partials.position', ['positions' => $positions]) | |
@endif | |
</select> | |
</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment