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 // refresh page with information about successfull registration
return redirect() return redirect()
->route('users.new') ->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 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. * 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 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 <?php
return [ return [
'addNewUser' => 'Add new user',
'name' => 'Full name', 'name' => 'Full name',
'email' => 'Email', 'email' => 'Email',
'password' => 'Password', 'password' => 'Password',
@@ -1,6 +1,21 @@
@extends('admin.layout') @extends('admin.layout')
@section('pageName', @trans('admin/userManagement.addNewUser'))
@section('content') @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')}}"> <form method="POST" action="{{route('users.newPost')}}">
{!! csrf_field() !!} {!! csrf_field() !!}
@@ -15,9 +30,9 @@
<input type="text" name="email" placeholder="somebody@example.com"> <input type="text" name="email" placeholder="somebody@example.com">
@if (isset($errors) && $errors->has('email')) @if (isset($errors) && $errors->has('email'))
<span class="help-block"> <div class="callout alert">
<strong>{{ $errors->first('email') }}</strong> {{ $errors->first('email') }}
</span> </div>
@endif @endif
</label> </label>
@@ -27,35 +42,32 @@
<input type="text" name="password"> <input type="text" name="password">
@if (isset($errors) && $errors->has('password')) @if (isset($errors) && $errors->has('password'))
<span class="help-block"> <div class="callout alert">
<strong>{{ $errors->first('password') }}</strong> {{ $errors->first('password') }}
</span> </div>
@endif @endif
</label> </label>
<div>
<label>
@lang('admin/userManagement.roles') @lang('admin/userManagement.roles')
<select name="role">
@foreach($roles as $role => $translation) @foreach($roles as $role => $translation)
<label> <option value="{{$role}}">@lang($translation)</option>
@lang($translation)
<input type="radio" name="role" value="{{$role}}">
</label>
@endforeach @endforeach
</select>
</label>
@if (isset($errors) && $errors->has('role')) @if (isset($errors) && $errors->has('role'))
<span class="help-block"> <div class="callout alert">
<strong>{{ $errors->first('role') }}</strong> {{ $errors->first('role') }}
</span>
@endif
</div> </div>
@endif
<label> <label>
<input type="submit" value="@lang('admin/userManagement.register')"> <button type="submit" class="button success">@lang('admin/userManagement.register')</button>
</label> </label>
</form> </form>
@stop @stop