But why error is coming?

|
Akashdeep Singh 2022-08-25 15:10:09
Vineet Malhotra 2022-08-25 14:58:31
Use proper namespace

laravel_discuss-135213.jpg
Namespace ok?

nanribet 2022-08-25 15:10:25
Yeah bro
nanribet 2022-08-25 15:10:49
I think it has something to do with my firstorfail
nanribet 2022-08-25 15:11:20
right…..bro
Vineet Malhotra 2022-08-25 15:11:36
Akashdeep Singh 2022-08-25 15:10:09
Namespace ok?

Have u mentioned in ur controller

Vineet Malhotra 2022-08-25 15:12:09
Neophyte_01 2022-08-25 15:05:18
still not working same error

Can I know the flow of ur code

Neophyte_01 2022-08-25 15:12:26
Vineet Malhotra 2022-08-25 15:12:09
Can I know the flow of ur code

yes

Vineet Malhotra 2022-08-25 15:12:30
How u r using or accessing that function
Akashdeep Singh 2022-08-25 15:12:38
Vineet Malhotra 2022-08-25 15:11:36
Have u mentioned in ur controller

laravel_discuss-135224.jpg
Yes mentioned

nanribet 2022-08-25 15:12:59
Yesss….but let me do that again
Neophyte_01 2022-08-25 15:13:05
Vineet Malhotra 2022-08-25 15:12:30
How u r using or accessing that function

let me share website llink which is i am following

Vineet Malhotra 2022-08-25 15:13:15
Akashdeep Singh 2022-08-25 15:12:38
Yes mentioned

Use App instead of app

Vineet Malhotra 2022-08-25 15:13:26
Neophyte_01 2022-08-25 15:13:05
let me share website llink which is i am following

Ohkk

Akashdeep Singh 2022-08-25 15:13:49
Vineet Malhotra 2022-08-25 15:13:15
Use App instead of app

Ok

Neophyte_01 2022-08-25 15:14:14
Vineet Malhotra 2022-08-25 15:13:26
Ohkk

https://www.itsolutionstuff.com/post/laravel-9-user-roles-and-permissions-tutorialexample.html

Laravel 9 User Roles and Permissions TutorialItsolutionstuff
laravel 9 roles and permissions tutorial, laravel 9 spatie user roles and permissions tutorial, laravel 9 spatie/laravel-permission, laravel 9 acl tutorial, laravel 9 user roles and permissions tutorial step by step
Neophyte_01 2022-08-25 15:14:28
can you tell me where i did wrong?
Akashdeep Singh 2022-08-25 15:14:43
Vineet Malhotra 2022-08-25 15:13:15
Use App instead of app

Thank you its working 🙂

Vineet Malhotra 2022-08-25 15:17:19
Neophyte_01 2022-08-25 15:14:14
https://www.itsolutionstuff.com/post/laravel-9-user-roles-and-permissions-tutorialexample.html

They r using third party library
But u can built ur own in user model

Neophyte_01 2022-08-25 15:17:43
Vineet Malhotra 2022-08-25 15:17:19
They r using third party library
But u can built ur own in user model

which one?

Vineet Malhotra 2022-08-25 15:18:05
Akashdeep Singh 2022-08-25 15:14:43
Thank you its working 🙂

Always welcome and keep coding 😊

Vineet Malhotra 2022-08-25 15:18:48
Neophyte_01 2022-08-25 15:17:43
which one?

Spatie

Neophyte_01 2022-08-25 15:19:26
Vineet Malhotra 2022-08-25 15:18:48
Spatie

but i have done that command composer reuire spatie

Neophyte_01 2022-08-25 15:19:39
Vineet Malhotra 2022-08-25 15:18:48
Spatie

is it giving issue because of it?

nanribet 2022-08-25 15:20:08
Bro….You are right that particular id did not exist thats why it failed
nanribet 2022-08-25 15:20:23
I used joins to pick the id so i was picking the wrong id
Vineet Malhotra 2022-08-25 15:20:41
Neophyte_01 2022-08-25 15:19:26
but i have done that command composer reuire spatie

Y ur using this library else u can make ur own

Dhruv Trivedi 2022-08-25 15:21:13
laravel_discuss-135242.jpg

Neophyte_01 2022-08-25 15:21:52
Vineet Malhotra 2022-08-25 15:20:41
Y ur using this library else u can make ur own

using spatie only i want to do it.but why error is coming?

Neophyte_01 2022-08-25 15:22:09
i followed all steps
Vineet Malhotra 2022-08-25 15:23:43
Neophyte_01 2022-08-25 15:21:52
using spatie only i want to do it.but why error is coming?

Ur laravel version???

Neophyte_01 2022-08-25 15:24:08
laravel 9
Vineet Malhotra 2022-08-25 15:28:29
Neophyte_01 2022-08-25 15:24:08
laravel 9

public function hasRole(… $roles )
{
foreach ($roles as $role) {
if ($this->roles->contains(‘slug’, $role)) {
return true;
}
}
return false;
}

public function hasPermission(… $permissions)
{
foreach ($permissions as $permission) {
if ($this->permissions->contains(‘slug’, $permission)) {
return true;
}
}
return false;
}

public function permissions()
{
return $this->belongsToMany(Permission::class,’users_permissions’);
}

Vineet Malhotra 2022-08-25 15:29:40
Create model and migration of rols , permission and pivot table users_roles and permissions_roles
Vineet Malhotra 2022-08-25 15:30:34
Call them by
Auth::User()->hasRole(‘client’)
Neophyte_01 2022-08-25 15:30:55
ok
|