Skip to content

Instantly share code, notes, and snippets.

@wertex
Last active May 1, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wertex/cb898d99018e630fa9a42b23501d7e86 to your computer and use it in GitHub Desktop.
Save wertex/cb898d99018e630fa9a42b23501d7e86 to your computer and use it in GitHub Desktop.
@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
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'
];
}
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"
}
<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