120 lines
5.1 KiB
PHP
120 lines
5.1 KiB
PHP
@extends('backend.layout')
|
|
@section('content')
|
|
@if(Session::has('success'))
|
|
<div class="alert alert-success">
|
|
{{ Session::get('success') }}
|
|
@php
|
|
Session::forget('success');
|
|
@endphp
|
|
</div>
|
|
@endif
|
|
@if(Session::has('errors'))
|
|
<div class="alert alert-danger">
|
|
{{ 'Có lỗi xảy ra (' . implode(', ', $errors->all(':message')) . ')'}}
|
|
@php
|
|
Session::forget('errors');
|
|
@endphp
|
|
</div>
|
|
@endif
|
|
<div class='card-header'>
|
|
<h1>{{$title ?? ''}}</h1>
|
|
</div>
|
|
<div class='card-body'>
|
|
<a class="btn btn-primary btn-custom right default" href="{{route('admin/users')}}">Trở về danh sách</a><br>
|
|
<form action="{{route('admin/users/update')}}" method="POST">
|
|
{{ csrf_field() }}
|
|
<input type="hidden" name="id" value="{{$data->id ?? 0}}" />
|
|
<div class="form-group">
|
|
<label for="name">Tên hiển thị</label>
|
|
@php
|
|
$name = $data->name ?? '';
|
|
if (old('name') != '') {
|
|
$name = old('name');
|
|
}
|
|
@endphp
|
|
<input class="form-control" id="name" name="name" value="{{$name ?? ''}}" />
|
|
@if ($errors->has('name'))
|
|
<span class="text-danger">{{ $errors->first('name') }}</span>
|
|
@endif
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Tên đăng nhập</label>
|
|
@php
|
|
$email = $data->email ?? '';
|
|
if (old('email') != '') {
|
|
$email = old('email');
|
|
}
|
|
@endphp
|
|
<input class="form-control" id="email" name="email" value="{{$email ?? ''}}" {{isset($data->id) && $data->id != '' ? 'readonly' : ''}} />
|
|
@if ($errors->has('email'))
|
|
<span class="text-danger">{{ $errors->first('email') }}</span>
|
|
@endif
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">Mật khẩu</label>
|
|
<input class="form-control" id="password" name="password" value="" />
|
|
@if ($errors->has('password'))
|
|
<span class="text-danger">{{ $errors->first('password') }}</span>
|
|
@endif
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="status">Trạng thái</label>
|
|
@php
|
|
$status = $data->status ?? '';
|
|
if (old('status') != '') {
|
|
$status = old('status');
|
|
}
|
|
@endphp
|
|
<select class="form-control" id="status" name="status">
|
|
<option value="">Chưa chọn</option>
|
|
<option value="1" {{isset($status) && $status == 1 ? 'selected' : ''}}>Đang hoạt động</option>
|
|
<option value="0" {{isset($status) && $status == 0 ? 'selected' : ''}}>Ngừng hoạt động</option>
|
|
</select>
|
|
@if ($errors->has('status'))
|
|
<span class="text-danger">{{ $errors->first('status') }}</span>
|
|
@endif
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="account_type">Loại tài khoản</label>
|
|
@php
|
|
$account_type = $data->account_type ?? '';
|
|
if (old('account_type') != '') {
|
|
$account_type = old('account_type');
|
|
}
|
|
@endphp
|
|
<select class="form-control" id="account_type" name="account_type">
|
|
<option value="">Chưa chọn</option>
|
|
<option value="1" {{isset($account_type) && $account_type == 1 ? 'selected' : ''}}>Tài khoản thông thường</option>
|
|
<option value="2" {{isset($account_type) && $account_type == 2 ? 'selected' : ''}}>Tài khoản VIP</option>
|
|
<option value="3" {{isset($account_type) && $account_type == 3 ? 'selected' : ''}}>Chờ xác nhận</option>
|
|
<option value="4" {{isset($account_type) && $account_type == 4 ? 'selected' : ''}}>Từ chối xác nhận</option>
|
|
</select>
|
|
@if ($errors->has('account_type'))
|
|
<span class="text-danger">{{ $errors->first('account_type') }}</span>
|
|
@endif
|
|
</div>
|
|
@if (isset($data->id) && $data->id != '')
|
|
<div class="form-group">
|
|
<label>Phân quyền:</label><br>
|
|
@foreach ($role_data as $role_item)
|
|
<div class="form-check form-check-inline">
|
|
<input name="user_role[]" value="{{$role_item->id ?? ''}}" class="form-check-input"
|
|
type="checkbox" id="chk_role_{{$role_item->id ?? ''}}"
|
|
{{in_array($role_item->id, $user_role) ? 'checked' : ''}} >
|
|
<label class="form-check-label" for="chk_role_{{$role_item->id ?? ''}}">{{$role_item->role_name ?? ''}}</label>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
<br>
|
|
<button class="btn btn-primary btn-custom" type="submit">
|
|
@if (isset($data->id) && $data->id != '')
|
|
Cập nhật
|
|
@else
|
|
Thêm mới
|
|
@endif
|
|
</button>
|
|
</form>
|
|
</div>
|
|
@endsection
|