Commit 21655760 authored by Vipul Basapati's avatar Vipul Basapati

Merge branch 'master' of https://github.com/viralsolani/laravel-adminpanel into develop

parents 056e545f b0495043
...@@ -28,6 +28,7 @@ class StoreRoleRequest extends Request ...@@ -28,6 +28,7 @@ class StoreRoleRequest extends Request
{ {
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => 'required',
]; ];
} }
} }
...@@ -28,6 +28,7 @@ class UpdateRoleRequest extends Request ...@@ -28,6 +28,7 @@ class UpdateRoleRequest extends Request
{ {
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => 'required',
]; ];
} }
} }
...@@ -32,6 +32,8 @@ class StoreUserRequest extends Request ...@@ -32,6 +32,8 @@ class StoreUserRequest extends Request
'last_name' => 'required|max:255', 'last_name' => 'required|max:255',
'email' => ['required', 'email', 'max:255', Rule::unique('users')], 'email' => ['required', 'email', 'max:255', Rule::unique('users')],
'password' => 'required|min:6|confirmed', 'password' => 'required|min:6|confirmed',
'assignees_roles' => 'required',
'permissions' => 'required',
]; ];
} }
...@@ -43,6 +45,7 @@ class StoreUserRequest extends Request ...@@ -43,6 +45,7 @@ class StoreUserRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'assignees_roles' => 'Please Select Role',
]; ];
} }
} }
...@@ -30,6 +30,8 @@ class UpdateUserRequest extends Request ...@@ -30,6 +30,8 @@ class UpdateUserRequest extends Request
'email' => 'required|email', 'email' => 'required|email',
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'permissions' => 'required',
'assignees_roles' => 'required',
]; ];
} }
...@@ -41,6 +43,7 @@ class UpdateUserRequest extends Request ...@@ -41,6 +43,7 @@ class UpdateUserRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'assignees_roles' => 'Please Select Role',
]; ];
} }
} }
...@@ -74,7 +74,7 @@ class PermissionRepository extends BaseRepository ...@@ -74,7 +74,7 @@ class PermissionRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function update(Model $permission, array $input) public function update($permission, array $input)
{ {
if ($this->query()->where('name', $input['name'])->where('id', '!=', $permission->id)->first()) { if ($this->query()->where('name', $input['name'])->where('id', '!=', $permission->id)->first()) {
throw new GeneralException(trans('exceptions.backend.access.permissions.already_exists')); throw new GeneralException(trans('exceptions.backend.access.permissions.already_exists'));
...@@ -104,7 +104,7 @@ class PermissionRepository extends BaseRepository ...@@ -104,7 +104,7 @@ class PermissionRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function delete(Model $permission) public function delete($permission)
{ {
DB::transaction(function () use ($permission) { DB::transaction(function () use ($permission) {
if ($permission->delete()) { if ($permission->delete()) {
......
...@@ -127,7 +127,7 @@ class RoleRepository extends BaseRepository ...@@ -127,7 +127,7 @@ class RoleRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function update(Model $role, array $input) public function update($role, array $input)
{ {
//See if the role has all access, administrator always has all access //See if the role has all access, administrator always has all access
if ($role->id == 1) { if ($role->id == 1) {
......
...@@ -12,6 +12,7 @@ use App\Events\Backend\Access\User\UserRestored; ...@@ -12,6 +12,7 @@ use App\Events\Backend\Access\User\UserRestored;
use App\Events\Backend\Access\User\UserUpdated; use App\Events\Backend\Access\User\UserUpdated;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use App\Repositories\Backend\Access\Role\RoleRepository; use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -119,6 +120,18 @@ class UserRepository extends BaseRepository ...@@ -119,6 +120,18 @@ class UserRepository extends BaseRepository
event(new UserCreated($user)); event(new UserCreated($user));
/*if (isset($data['confirmation_email']) && $user->confirmed == 0) {
$email_type = 1;
}*/
// Send email to the user
/* $options = [
'data' => $user->toArray(),
'email_template_type' => $email_type,
];*/
//createNotification('', 1, 2, $options);
return true; return true;
} }
...@@ -339,8 +352,8 @@ class UserRepository extends BaseRepository ...@@ -339,8 +352,8 @@ class UserRepository extends BaseRepository
*/ */
protected function flushPermissions($permissions, $user) protected function flushPermissions($permissions, $user)
{ {
//Flush roles out, then add array of new ones //Flush permission out, then add array of new ones
$user->detachPermissions($user->roles); $user->detachPermissions($user->permissions);
$user->attachPermissions($permissions); $user->attachPermissions($permissions);
} }
......
...@@ -102,9 +102,9 @@ ...@@ -102,9 +102,9 @@
{{ trans('labels.backend.access.users.all_permissions') }} {{ trans('labels.backend.access.users.all_permissions') }}
@else @else
@if (count($role->permissions) > 0) @if (count($role->permissions) > 0)
<blockquote class="small">{{-- <blockquote class="small">
--}}@foreach ($role->permissions as $perm){{-- @foreach ($role->permissions as $perm)
--}}{{$perm->display_name}} {{$perm->display_name}}
@endforeach @endforeach
</blockquote> </blockquote>
@else @else
...@@ -127,10 +127,11 @@ ...@@ -127,10 +127,11 @@
<div class="row"> <div class="row">
<div class="col-xs-12 get-available-permissions"> <div class="col-xs-12 get-available-permissions">
@if ($permissions) @if ($permissions)
@foreach ($permissions as $id => $display_name) @foreach ($permissions as $id => $display_name)
<div class="control-group"> <div class="control-group">
<label class="control control--checkbox" for="perm_{{ $id }}"> <label class="control control--checkbox" for="perm_{{ $id }}">
<input type="checkbox" name="permissions[{{ $id }}]" value="{{ $id }}" id="perm_{{ $id }}" {{ isset($userPermissions[$id]) && in_array($id, $userPermissions) ? 'checked' : '' }} /> <label for="perm_{{ $id }}">{{ $display_name }}</label> <input type="checkbox" name="permissions[{{ $id }}]" value="{{ $id }}" id="perm_{{ $id }}" {{ isset($userPermissions) && in_array($id, $userPermissions) ? 'checked' : '' }} /> <label for="perm_{{ $id }}">{{ $display_name }}</label>
<div class="control__indicator"></div> <div class="control__indicator"></div>
</label> </label>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment