-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…sateurs, leur modele, leur vues, corrrection du bug des parametres dans le header et les routes
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
use App\Http\Requests\UserUpdateRequest; | ||
|
||
use Illuminate\Pagination\Paginator; | ||
use Illuminate\Support\Facades\View; | ||
use View; | ||
|
||
use App; | ||
use App\User; | ||
|
@@ -53,13 +53,7 @@ public function create() | |
*/ | ||
public function store(UserCreateRequest $request) | ||
{ | ||
$user = new User; | ||
$user->userName = $request->userName; | ||
$user->firstName = $request->firstName; | ||
$user->lastName = $request->lastName; | ||
$user->email = $request->email; | ||
$user->password = $request->password; | ||
$user->save(); | ||
$user = User::create($request->only('userName', 'firstName', 'lastName', 'email', 'password')); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fabioman
Collaborator
|
||
return redirect()->route('users.index', App::getLocale()); | ||
} | ||
|
||
|
@@ -71,15 +65,8 @@ public function store(UserCreateRequest $request) | |
*/ | ||
public function show($locale, $id) | ||
{ | ||
$user = User::find($id); | ||
if (!is_null($user)) | ||
{ | ||
return View::make('users.show')->with('user', $user); | ||
} | ||
else | ||
{ | ||
App::abort(404); | ||
} | ||
$user = User::findOrFail($id); | ||
return View::make('users.show')->with('user', $user); | ||
} | ||
|
||
/** | ||
|
@@ -88,17 +75,10 @@ public function show($locale, $id) | |
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit($id) | ||
public function edit($locale, $id) | ||
{ | ||
$user = User::find($id); | ||
if (!is_null($user)) | ||
{ | ||
return View::make('users.edit')->with('user', $user); | ||
} | ||
else | ||
{ | ||
App::abort(404); | ||
} | ||
$user = User::findOrFail($id); | ||
return View::make('users.edit')->with('user', $user); | ||
} | ||
|
||
/** | ||
|
@@ -126,17 +106,10 @@ public function update(UserUpdateRequest $request, $id) | |
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy($id) | ||
public function destroy($locale, $id) | ||
{ | ||
$user = User::find($id); | ||
if (!is_null($user)) | ||
{ | ||
$user->delete(); | ||
} | ||
else | ||
{ | ||
App::abort(404); | ||
} | ||
return redirect()->back(); | ||
$user = User::findOrFail($id); | ||
$user->delete(); | ||
return redirect()->route('users.index', App::getLocale()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,17 +88,29 @@ | |
</a> | ||
<ul class="submenu menu vertical is-dropdown-submenu first-sub" > | ||
<li> | ||
@if( isset($user) ) | ||
<a tabindex="0" href="{{ route( Route::currentRouteName(), ['lang' => 'fr', 'user' => $user->id]) }}"> | ||
@else | ||
<a tabindex="0" href="{{ route( Route::currentRouteName(), ['lang' => 'fr']) }}"> | ||
@endif | ||
{{ trans('menus.fr') }} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="{{ route( Route::currentRouteName(), ['lang' => 'de']) }}"> | ||
@if( isset($user) ) | ||
<a tabindex="0" href="{{ route( Route::currentRouteName(), ['lang' => 'de', 'user' => $user->id]) }}"> | ||
@else | ||
<a tabindex="0" href="{{ route( Route::currentRouteName(), ['lang' => 'de']) }}"> | ||
@endif | ||
{{ trans('menus.de') }} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="{{ route( Route::currentRouteName(), ['lang' => 'en']) }}"> | ||
@if( isset($user) ) | ||
<a tabindex="0" href="{{ route( Route::currentRouteName(), ['lang' => 'en', 'user' => $user->id]) }}"> | ||
@else | ||
<a tabindex="0" href="{{ route( Route::currentRouteName(), ['lang' => 'en']) }}"> | ||
@endif | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
matbandeli
Member
|
||
{{ trans('menus.en') }} | ||
</a> | ||
</li> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
|
||
<div class="row"> | ||
<div class="large-6 large-centered medium-8 medium-centered small-10 small-centered columns"> | ||
|
||
<h1>@lang('forms_buttons_common.edit') @lang('forms_buttons_common.user') : {{ $user->userName }}</h1> | ||
|
||
|
||
{{ Form::open( ['method' => 'PUT', 'route' => ['users.update', 'lang' => App::getLocale(), 'user' => $user->id]] ) }} | ||
This comment has been minimized.
Sorry, something went wrong.
greut
Member
|
||
<div class="row"> | ||
<label for="userName">@lang('users.userName')</label> | ||
<input type="text" id="userName" name="userName" value="{{ $user->userName }}" required autofocus/> | ||
@if ($errors->has('userName')) | ||
<small class="error">{{ $errors->first('userName') }}</small> | ||
@endif | ||
</div> | ||
|
||
<div class="row"> | ||
<label for="firstName">@lang('users.firstName')</label> | ||
<input type="text" id="firstName" name="firstName" value="{{ $user->firstName }}" required/> | ||
@if ($errors->has('firstName')) | ||
<small class="error">{{ $errors->first('firstName') }}</small> | ||
@endif | ||
</div> | ||
|
||
<div class="row"> | ||
<label for="lastName">@lang('users.lastName')</label> | ||
<input type="text" id="lastName" name="lastName" value="{{ $user->lastName }}" required/> | ||
@if ($errors->has('lastName')) | ||
<small class="error">{{ $errors->first('lastName') }}</small> | ||
@endif | ||
</div> | ||
|
||
<div class="row"> | ||
<label for="email">@lang('users.email')</label> | ||
<input type="email" id="email" name="email" value="{{ $user->email }}" required/> | ||
@if ($errors->has('email')) | ||
<small class="error">{{ $errors->first('email') }}</small> | ||
@endif | ||
</div> | ||
|
||
<div class="row"> | ||
<label for="password">@lang('users.password')</label> | ||
<input type="password" id="password" name="password" required/> | ||
@if ($errors->has('password')) | ||
<small class="error">{{ $errors->first('password') }}</small> | ||
@endif | ||
</div> | ||
|
||
<div class="row"> | ||
<label for="passwordConfirmation">@lang('users.passwordConfirmation')</label> | ||
<input type="password" id="passwordConfirmation" name="passwordConfirmation" required /> | ||
@if ($errors->has('passwordConfirmation')) | ||
<small class="error">{{ $errors->first('passwordConfirmation') }}</small> | ||
@endif | ||
</div> | ||
|
||
<div class="row"> | ||
<button type="submit" class="button"> | ||
@lang('forms_buttons_common.create') | ||
</button> | ||
</div> | ||
|
||
{{ Form::close() }} | ||
</div> | ||
</div> | ||
|
||
@endsection |
Mieux, non? Un peu de validation par dessus et c'est utlisable.
https://laravel.com/docs/5.3/validation