FEATURE: tweak form for creating new user

Added Foundation classes etc.
This commit is contained in:
Michal Kváček
2016-01-22 17:51:34 +01:00
parent 47aa9b15cb
commit 9517ff43d5
5 changed files with 51 additions and 40 deletions
@@ -66,6 +66,6 @@ class UserManagement extends Controller
// refresh page with information about successfull registration
return redirect()
->route('users.new')
->with('message', trans('admin/userManagement.registrationSuccessfull'));
->with('success', trans('admin/userManagement.registrationSuccessfull'));
}
}
@@ -7,17 +7,6 @@ use App\Models\User;
class CreateNewUserRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return \Auth::check() && \Auth::$user->role == User::ROLE_ADMIN;
}
/**
* Get the validation rules that apply to the request.
*
+10 -1
View File
@@ -6,5 +6,14 @@ use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest
{
//
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
@@ -1,6 +1,7 @@
<?php
return [
'addNewUser' => 'Add new user',
'name' => 'Full name',
'email' => 'Email',
'password' => 'Password',
@@ -1,6 +1,21 @@
@extends('admin.layout')
@section('pageName', @trans('admin/userManagement.addNewUser'))
@section('content')
@if (session('success'))
<div class="callout success">
{{ session('success') }}
</div>
@endif
@if (session('error'))
<div class="callout alert">
{{ session('error') }}
</div>
@endif
<form method="POST" action="{{route('users.newPost')}}">
{!! csrf_field() !!}
@@ -15,9 +30,9 @@
<input type="text" name="email" placeholder="somebody@example.com">
@if (isset($errors) && $errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
<div class="callout alert">
{{ $errors->first('email') }}
</div>
@endif
</label>
@@ -27,35 +42,32 @@
<input type="text" name="password">
@if (isset($errors) && $errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
<div class="callout alert">
{{ $errors->first('password') }}
</div>
@endif
</label>
<div>
@lang('admin/userManagement.roles')
@foreach($roles as $role => $translation)
<label>
@lang($translation)
<input type="radio" name="role" value="{{$role}}">
</label>
@endforeach
@if (isset($errors) && $errors->has('role'))
<span class="help-block">
<strong>{{ $errors->first('role') }}</strong>
</span>
@endif
</div>
<label>
<input type="submit" value="@lang('admin/userManagement.register')">
@lang('admin/userManagement.roles')
<select name="role">
@foreach($roles as $role => $translation)
<option value="{{$role}}">@lang($translation)</option>
@endforeach
</select>
</label>
@if (isset($errors) && $errors->has('role'))
<div class="callout alert">
{{ $errors->first('role') }}
</div>
@endif
<label>
<button type="submit" class="button success">@lang('admin/userManagement.register')</button>
</label>
</form>
@stop