Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
3e9560de
Commit
3e9560de
authored
Nov 25, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-create attach permission at user access level
-insert permission to newly created functions
parent
99fe1126
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
34 deletions
+64
-34
PushNotification.php
app/Http/Utilities/PushNotification.php
+0
-4
UserAccess.php
app/Models/Access/User/Traits/UserAccess.php
+54
-0
UserRepository.php
app/Repositories/Backend/Access/User/UserRepository.php
+10
-30
No files found.
app/Http/Utilities/PushNotification.php
View file @
3e9560de
...
...
@@ -49,8 +49,6 @@ class PushNotification
}
/**
* Created By : Umang Soni
* Created at : 26/05/2017
* PushNotification for android.
*
* @param array $devicetoken
...
...
@@ -88,8 +86,6 @@ class PushNotification
}
/**
* Created By : Umang Soni
* Created at : 26/05/2017
* PushNotification for IOS.
*
* @param array $devicetoken
...
...
app/Models/Access/User/Traits/UserAccess.php
View file @
3e9560de
...
...
@@ -269,4 +269,58 @@ trait UserAccess
$this
->
detachRole
(
$role
);
}
}
/**
* Attach multiple Permissions to a user.
*
* @param mixed $permissions
*
* @return void
*/
public
function
attachPermissions
(
$permissions
)
{
foreach
(
$permissions
as
$permission
)
{
$this
->
attachPermission
(
$permission
);
}
}
/**
* Alias to eloquent many-to-many relation's attach() method.
*
* @param mixed $permission
*
* @return void
*/
public
function
attachPermission
(
$permission
)
{
if
(
is_object
(
$permission
))
{
$permission
=
$permission
->
getKey
();
}
if
(
is_array
(
$permission
))
{
$permission
=
$permission
[
'id'
];
}
$this
->
permissions
()
->
attach
(
$permission
);
}
/**
* Alias to eloquent many-to-many relation's detach() method.
*
* @param mixed $permission
*
* @return void
*/
public
function
detachPermission
(
$permission
)
{
if
(
is_object
(
$permission
))
{
$permission
=
$permission
->
getKey
();
}
if
(
is_array
(
$permission
))
{
$permission
=
$permission
[
'id'
];
}
$this
->
permission
()
->
detach
(
$permission
);
}
}
app/Repositories/Backend/Access/User/UserRepository.php
View file @
3e9560de
...
...
@@ -124,22 +124,24 @@ class UserRepository extends BaseRepository
$permissions
=
$request
->
all
(
'permissions'
)
?
$request
->
all
(
'permissions'
)
:
[];
$user
=
$this
->
createUserStub
(
$data
);
DB
::
transaction
(
function
()
use
(
$user
,
$data
,
$roles
,
$permissions
)
{
DB
::
transaction
(
function
()
use
(
$user
,
$data
,
$request
)
{
// Set email type 2
$email_type
=
2
;
if
(
$user
->
save
())
{
//User Created, Validate Roles
if
(
!
count
(
$r
oles
[
'assignees_roles'
]
))
{
if
(
!
count
(
$r
equest
->
get
(
'assignees_roles'
)
))
{
throw
new
GeneralException
(
trans
(
'exceptions.backend.access.users.role_needed_create'
));
}
//Attach new roles
$user
->
attachRoles
(
$r
oles
[
'assignees_roles'
]
);
$user
->
attachRoles
(
$r
equest
->
get
(
'assignees_roles'
)
);
// Attach Permissions
$this
->
attachPermissions
(
$permissions
);
// Attach New Permissions
$user
->
attachPermissions
(
$request
->
get
(
'permissions'
));
//$this->attachPermissions($permissions);
//Send confirmation email if requested and account approval is off
if
(
isset
(
$data
[
'confirmation_email'
])
&&
$user
->
confirmed
==
0
)
{
...
...
@@ -148,6 +150,9 @@ class UserRepository extends BaseRepository
event
(
new
UserCreated
(
$user
));
//@todo if it is require it can go to event to send notfication
//or user laravel 5.5 notification
//Send confirmation email if requested
/*if (isset($data['confirmation_email']) && $user->confirmed == 0) {
// If user needs confirmation then set email type 1
...
...
@@ -423,29 +428,4 @@ class UserRepository extends BaseRepository
return
$user
;
}
/**
* Attach Permission.
*
* @param $permissions
*
* @todo attach permission like role
*
* @return mix
*/
public
function
attachPermissions
(
$value
=
''
)
{
$arrUserPermissions
=
[];
if
(
isset
(
$permissions
)
&&
count
(
$permissions
)
>
0
)
{
foreach
(
$permissions
as
$permission
)
{
$arrUserPermissions
[]
=
[
'permission_id'
=>
$permission
,
'user_id'
=>
$user
->
id
,
];
}
// Insert multiple rows at once
DB
::
table
(
'permission_user'
)
->
insert
(
$arrUserPermissions
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment