Skip to content

Commit

Permalink
Localization + small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienheyd committed Apr 12, 2017
1 parent df740d1 commit 2a76fd1
Show file tree
Hide file tree
Showing 27 changed files with 298 additions and 211 deletions.
8 changes: 4 additions & 4 deletions src/Controllers/Users/RolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function store(Request $request)
]);

$role = Role::create($input);
$role->permissions()->sync(array_keys($request->input('permission')));
$role->permissions()->sync(array_keys($request->input('permission', [])));

return redirect()->route('roles.edit', $role)->with('growl', "Le rôle a été correctement ajouté");
return redirect()->route('roles.edit', $role)->with('growl', [__('boilerplate::role.successadd'), 'success']);
}

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ public function update(Request $request, $id)
$role->update($request->all());
$role->permissions()->sync(array_keys($request->input('permission')));

return redirect()->route('roles.edit', $role)->with('growl', "Le role a été correctement modifié");
return redirect()->route('roles.edit', $role)->with('growl', [__('boilerplate::role.successmod'), 'success']);
}

/**
Expand All @@ -133,6 +133,6 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
abort(404);
Role::destroy($id);
}
}
50 changes: 6 additions & 44 deletions src/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function datatable()
})->editColumn('last_login', function ($user) {
return $user->getLastLogin(__('boilerplate::date.YmdHis'), '-');
})->editColumn('status', function ($user) {
if($user->active == 1) return '<span class="label label-success">Activé</span>';
return '<span class="label label-danger">Désactivé</span>';
if($user->active == 1) return '<span class="label label-success">'.__('boilerplate::users.active').'</span>';
return '<span class="label label-danger">'.__('boilerplate::users.inactive').'</span>';
})->editColumn('roles', function ($user) {
return $user->getRolesList();
})->editColumn('actions', function ($user) {
Expand Down Expand Up @@ -108,7 +108,7 @@ public function datatable()
*/
public function create()
{
// Filtres des rôles si pas admin
// Filter roles if not admin
if (!Auth::user()->hasRole('admin')) {
$roles = Role::whereNotIn('name', ['admin'])->get();
} else {
Expand Down Expand Up @@ -142,7 +142,7 @@ public function store(Request $request)

$user->sendNewUserNotification($input['remember_token'], Auth::user());

return redirect()->route('users.edit', $user)->with('growl', "L'utilisateur a été correctement ajouté");
return redirect()->route('users.edit', $user)->with('growl', [__('boilerplate::users.successadd'), 'success']);
}

/**
Expand Down Expand Up @@ -197,7 +197,7 @@ public function update(Request $request, $id)
// Mise à jour des rôles
$user->roles()->sync(array_keys($request->input('roles', [])));

return redirect(route('users.edit', $user))->with('growl', "L'utilisateur a été correctement modifié");
return redirect(route('users.edit', $user))->with('growl', [__('boilerplate::users.successadd'), 'success']);
}

/**
Expand Down Expand Up @@ -248,44 +248,6 @@ public function firstLoginPost(Request $request)

Auth::attempt(['email' => $user->email, 'password' => $request->input('password'), 'active' => 1]);

return redirect()->route('boilerplate.home')->with('growl', "Votre mot de passe a bien été enregistré.");
return redirect()->route('boilerplate.home')->with('growl', [__('boilerplate::users.newpassword'), 'success']);
}

public function avatar()
{
return view('users.avatar');
}

public function avatarPost(Request $request)
{
$this->validate($request, [
'avatar' => 'required|mimes:jpeg,png|max:10000'
]);

$avatar = $request->file('avatar');

if ($file = $avatar->isValid()) {
$destinationPath = public_path('images/avatars');
$extension = $avatar->getClientOriginalExtension();
$fileName = str_pad(Auth::user()->id, 6, '0', STR_PAD_LEFT) . '_tmp.' . $extension;
$avatar->move($destinationPath, $fileName);

Image::make($destinationPath . DIRECTORY_SEPARATOR . $fileName)
->fit(100, 100)
->save($destinationPath . DIRECTORY_SEPARATOR . str_pad(Auth::user()->id, 6, '0', STR_PAD_LEFT) . '.jpg');

unlink($destinationPath . DIRECTORY_SEPARATOR . $fileName);

return redirect()->route('users.avatar')->with('growl', "La photo a été téléchargée");
} else {
return redirect()->route('users.avatar')->with('growl', "Une erreur s'est produite !");
}
}

public function avatarDelete()
{
unlink(public_path('images/avatars/' . str_pad(Auth::user()->id, 6, '0', STR_PAD_LEFT) . '.jpg'));
return redirect()->route('users.avatar')->with('growl', "La photo a été supprimée");
}

}
5 changes: 5 additions & 0 deletions src/resources/lang/vendor/boilerplate/en/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@
'signin' => 'Sign in',
'forgotpassword' => "I forgot my password",
'register' => 'Register a new user'
],
'firstlogin' => [
'title' => 'First login',
'intro' => 'This is your first login, please enter a password to activate your account.',
'button' => 'Login'
]
];
28 changes: 24 additions & 4 deletions src/resources/lang/vendor/boilerplate/en/role.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
<?php

return [
'title' => 'Role management',
'parameters' => 'Parameters',
'label' => 'Label',
'description' => 'Description',
'permissions' => 'Permissions',
'savebutton' => 'Save',
'successadd' => 'The role has been correctly added',
'successmod' => 'The role has been correctly modified',
'admin' => [
'display_name' => 'Admin',
'description' => 'Admin (all permissions)',
'display_name' => 'Admin',
'description' => 'Admin (all permissions)',
],
'backend_user' => [
'display_name' => 'Backend user',
'description' => 'Users with backend access',
'display_name' => 'Backend user',
'description' => 'Users with backend access',
],
'create' => [
'title' => 'Add a role',
],
'edit' => [
'title' => "Edit a role",
],
'list' => [
'title' => 'Role list',
'nbusers' => 'Nb users',
'confirmdelete' => 'Do you confirm that you want to delete this role ?',
'deletesuccess' => 'The role has been correctly deleted'
]
];
38 changes: 38 additions & 0 deletions src/resources/lang/vendor/boilerplate/en/users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

return [
'title' => 'User management',
'returntolist' => 'User list',
'save' => 'Save',
'informations' => 'Informations',
'status' => 'Status',
'active' => 'Enabled',
'inactive' => 'Disabled',
'lastname' => 'Last name',
'firstname' => 'First name',
'email' => 'E-mail',
'roles' => 'Role',
'successadd' => "The user has been correctly added.",
'successmod' => "The user has been correctly modified.",
'newpassword' => "Your password has been saved.",
'create' => [
'title' => "Add a user",
'help' => "The user will receive an invitation by e-mail to login in which it will allow him to enter his new password",
],
'edit' => [
'title' => "Edit a user",
],
'list' => [
'title' => 'User list',
'id' => 'Id',
'state' => 'Status',
'lastname' => 'Last name',
'firstname' => 'First name',
'email' => 'E-mail',
'roles' => 'Role',
'creationdate' => 'Creation date',
'lastconnect' => 'Last log',
'confirmdelete' => "Do you confirm that you want to delete this user ?",
'deletesuccess' => "The user has been correctly deleted",
]
];
5 changes: 5 additions & 0 deletions src/resources/lang/vendor/boilerplate/fr/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@
'signin' => 'Connexion',
'forgotpassword' => "J'ai oublié mon mot de passe",
'register' => 'Créer un nouveau compte'
],
'firstlogin' => [
'title' => 'Première connexion',
'intro' => 'Ceci est votre première connexion, merci de saisir un mot de passe pour activer votre compte.',
'button' => 'Connexion'
]
];
28 changes: 24 additions & 4 deletions src/resources/lang/vendor/boilerplate/fr/role.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
<?php

return [
'title' => 'Gestion des rôles',
'parameters' => 'Paramètres',
'label' => 'Libellé',
'description' => 'Description',
'permissions' => 'Permissions',
'savebutton' => 'Enregistrer',
'successadd' => 'Le rôle a été correctement ajouté',
'successmod' => 'Le role a été correctement modifié',
'admin' => [
'display_name' => 'Administrateur',
'description' => 'Administrateur (toutes les permissions)',
'display_name' => 'Administrateur',
'description' => 'Administrateur (toutes les permissions)',
],
'backend_user' => [
'display_name' => 'Utilisateur du back-office',
'description' => 'Utilisateurs avec un accès au back-office',
'display_name' => 'Utilisateur du back-office',
'description' => 'Utilisateurs avec un accès au back-office',
],
'create' => [
'title' => 'Ajouter un rôle',
],
'edit' => [
'title' => "Édition d'un rôle",
],
'list' => [
'title' => 'Liste des rôles',
'nbusers' => 'Nb utilisateurs',
'confirmdelete' => 'Confirmez vous la suppression du rôle ?',
'deletesuccess' => 'Le rôle a été correctement supprimé'
]
];
38 changes: 38 additions & 0 deletions src/resources/lang/vendor/boilerplate/fr/users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

return [
'title' => 'Gestion des utilisateurs',
'returntolist' => 'Liste des utilisateurs',
'save' => 'Enregistrer',
'informations' => 'Informations',
'status' => 'Statut',
'active' => 'Activé',
'inactive' => 'Désactivé',
'lastname' => 'Nom',
'firstname' => 'Prénom',
'email' => 'E-mail',
'roles' => 'Rôle(s)',
'successadd' => "L'utilisateur a été correctement ajouté.",
'successmod' => "L'utilisateur a été correctement modifié.",
'newpassword' => "Votre mot de passe a bien été enregistré.",
'create' => [
'title' => "Ajout d'un utilisateur",
'help' => "L'utilisateur recevra un e-mail d'invitation à se connecter qui lui permettra de saisir son nouveau mot de passe.",
],
'edit' => [
'title' => "Édition d'un utilisateur",
],
'list' => [
'title' => 'Liste des utilisateurs',
'id' => 'Id',
'state' => 'État',
'lastname' => 'Nom',
'firstname' => 'Prénom',
'email' => 'E-mail',
'roles' => 'Rôle(s)',
'creationdate' => 'Date de création',
'lastconnect' => 'Dernière connexion',
'confirmdelete' => "Confirmez vous la suppression de l'utilisateur ?",
'deletesuccess' => "L'utilisateur à été correctement supprimé",
]
];
1 change: 0 additions & 1 deletion src/resources/views/errors/403.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();" class="btn btn-default">
{{ __('boilerplate::layout.logout') }}
</a>

{!! Form::open(['route' => 'logout', 'method' => 'post', 'id' => 'logout-form', 'style'=> 'display:none']) !!}
{!! Form::close() !!}
@endif
Expand Down
17 changes: 5 additions & 12 deletions src/resources/views/vendor/boilerplate/auth/firstlogin.blade.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
@extends('boilerplate::auth.layout', [
'title' => __('boilerplate::auth.login.title'),
'title' => __('boilerplate::auth.firstlogin.title'),
'bodyClass' => 'hold-transition login-page'
])

@section('content')
@component('boilerplate::auth.loginbox')
{{ Form::open(['route' => 'users.firstlogin', 'autocomplete' => 'off']) }}

<input type="hidden" name="token" value="{{ $token }}">

<div class="alert alert-info">
<p>
Ceci est votre première connexion, merci de saisir un mot de passe pour activer votre compte.
</p>
<p>{{ __('boilerplate::auth.firstlogin.intro') }}</p>
</div>

<div class="form-group {{ $errors->has('password') ? 'has-error' : '' }}">
{{ Form::label('password', 'Mot de passe') }}
{{ Form::label('password', __('boilerplate::auth.fields.password')) }}
{{ Form::input('password', 'password', Request::old('password'), ['class' => 'form-control', 'autofocus']) }}
{!! $errors->first('password','<p class="text-danger">:message</p>') !!}
</div>

<div class="form-group {{ $errors->has('password_confirmation') ? 'has-error' : '' }}">
{{ Form::label('password_confirmation', 'Confirmation du mot de passe') }}
{{ Form::label('password_confirmation', __('boilerplate::auth.fields.password_confirm')) }}
{{ Form::input('password', 'password_confirmation', Request::old('password_confirmation'), ['class' => 'form-control']) }}
{!! $errors->first('password_confirmation','<p class="text-danger">:message</p>') !!}
</div>

<div class="form-group text-center">
<button type="submit" class="btn btn-primary">
Connexion
{{ __('boilerplate::auth.firstlogin.button') }}
</button>
</div>
</form>
Expand Down
2 changes: 0 additions & 2 deletions src/resources/views/vendor/boilerplate/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@section('content')
@component('boilerplate::auth.loginbox')
<p class="login-box-msg">{{ __('boilerplate::auth.login.intro') }}</p>

{!! Form::open(['route' => 'login', 'method' => 'post', 'autocomplete'=> 'off']) !!}
<div class="form-group has-feedback">
<div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
Expand Down Expand Up @@ -37,7 +36,6 @@
</div>
</div>
{!! Form::close() !!}

<a href="{{ route('password.request') }}">{{ __('boilerplate::auth.login.forgotpassword') }}</a><br>
@if(config('boilerplate.auth.register'))
<a href="{{ route('register') }}" class="text-center">{{ __('boilerplate::auth.login.register') }}</a>
Expand Down
Loading

0 comments on commit 2a76fd1

Please sign in to comment.