Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSOC-23: Roles and User Modules #43

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6f27b3b
Roles interface with add role
chaitak-gorai Jun 9, 2023
6bc448a
🐛 Minor fixes: used ziggy
chaitak-gorai Jun 16, 2023
e4281e4
Added Laratrust Seeder for Roles
chaitak-gorai Jun 16, 2023
a819002
Minor updates
chaitak-gorai Jun 20, 2023
51ec886
Role UI update and Permission Data fetched in form
chaitak-gorai Jun 24, 2023
f2c8e85
Seeder Temporary bug fix & Scrollable Dropdown UI
chaitak-gorai Jun 25, 2023
4fb9808
🐛 Seeder updated & Bug solved
chaitak-gorai Jun 27, 2023
1e7fcb4
Seeder updated with sub modules
chaitak-gorai Jul 1, 2023
499cc6e
Customized Role Creation
chaitak-gorai Jul 1, 2023
66d9cf3
Users in Roles UI
chaitak-gorai Jul 1, 2023
9124937
Roles Details Page
chaitak-gorai Jul 1, 2023
a8cf553
Minor updates
chaitak-gorai Jul 2, 2023
c4c3f83
Add User Form UI
chaitak-gorai Jul 8, 2023
1b24983
Add User Form UI
chaitak-gorai Jul 8, 2023
5ddf478
➕ Add User via Invitation
chaitak-gorai Jul 21, 2023
4621bfa
Added a default value for token expiry
chaitak-gorai Jul 21, 2023
3e3a4dd
User Invitation Updated
chaitak-gorai Jul 26, 2023
037543c
Table Updates
chaitak-gorai Jul 26, 2023
97f0a33
Minor Updates
chaitak-gorai Aug 1, 2023
7e18c00
Minor updates on reviews
chaitak-gorai Aug 2, 2023
d796678
Invitations List UI
chaitak-gorai Aug 4, 2023
c24064e
Updates with Pagination.
chaitak-gorai Aug 8, 2023
811dd08
Proper Folder Structure Update
chaitak-gorai Aug 9, 2023
c8420ae
User Profile Page
chaitak-gorai Aug 13, 2023
9b4261f
Edit Profile Functionality
chaitak-gorai Aug 14, 2023
c6033fd
Minor update
chaitak-gorai Aug 14, 2023
d4de977
Routes Update, Clean file names
chaitak-gorai Aug 15, 2023
a75e3de
Removed redundant file
chaitak-gorai Aug 15, 2023
1e66f61
multiselect component for permissions select
chaitak-gorai Aug 23, 2023
066983c
Revert last changes and used MultiSelect
chaitak-gorai Aug 23, 2023
e02194a
fixed head for mobile devices
chaitak-gorai Apr 1, 2023
3ecdb06
Added icon template for svg icons
chaitak-gorai Apr 2, 2023
1eb7661
✨ Drawer Navigation Menu
chaitak-gorai Apr 18, 2023
5679a23
Fixed chevron icon color
chaitak-gorai Apr 21, 2023
a4b7c1a
🐛 fixed the backdrop bug
chaitak-gorai Apr 21, 2023
e877ac6
added all nav menu
chaitak-gorai May 26, 2023
2a621a6
Added L2 submenus
chaitak-gorai Jun 2, 2023
047b2dc
Added L2 submenus for small devices
chaitak-gorai Jun 2, 2023
15cbf9f
Merge branch 'develop' into roles
chaitak-gorai Aug 26, 2023
5ace6ba
access controlled routes
chaitak-gorai Aug 26, 2023
378fe5b
Merge branch 'roles' of https://github.com/chaitak-gorai/lh-ehr-larav…
chaitak-gorai Aug 26, 2023
4374361
Users datatable
chaitak-gorai Aug 26, 2023
2b6b772
Validations for Add User
chaitak-gorai Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/Http/Controllers/Dashboard/PermissionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Controllers\Dashboard;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Permission;

class PermissionController extends Controller
{
//
public function getPermissions()
{

$permissions = Permission::all();

return response()->json($permissions);
}
}
85 changes: 85 additions & 0 deletions app/Http/Controllers/Dashboard/RolesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace App\Http\Controllers\Dashboard;

use App\Models\Role;
use App\Models\Permission;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreateRoleRequest;
use Inertia\Inertia;
use Inertia\Response;
class RolesController extends Controller
{
public function index(): Response
{
/**
* Shows the role page
* @return Response
*/

return Inertia::render('Roles',
[
'roles' => []
]
);
}
public function details($roleId): Response
chaitak-gorai marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* Shows the role page
* @return Response
*/
//get role with id = $roleId
$role = Role::with('permissions')->where('id', $roleId)->first();
$users = $role->users()->get();
$temp = [
'id' => $role->id,
'name' => $role->name,
'display_name' => $role->display_name,
'description' => $role->description,
'permissions' => $role->permissions,
'users' => $users,
];
return Inertia::render('RolesDetails',
[
'roleDetails' => $temp
]
);

}
public function store(CreateRoleRequest $request)
{

$role = new Role();
$role->name = $request->name;
$role->display_name = $request->display_name;
$role->description = $request->description;
$role->save();
foreach ($request->permissions as $permission) {
$role->permissions()->attach([$permission['id']]);
}
$role->save();
return response()->json($role, 201);
}
public function getRoles()
{
$result=[];
$roles = Role::with('permissions')->get();
foreach ($roles as $role) {
$users = $role->users()->get();
$temp = [
'id' => $role->id,
'name' => $role->name,
chaitak-gorai marked this conversation as resolved.
Show resolved Hide resolved
'display_name' => $role->display_name,
'description' => $role->description,
'permissions' => $role->permissions,
'users' => $users,
];
array_push($result, $temp);
}

return response()->json($result, 200);
}
}
33 changes: 33 additions & 0 deletions app/Http/Requests/CreateRoleRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CreateRoleRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'name' => 'required|string',
'display_name' => 'required|string',
'description' => 'required|string',
'permissions' => 'required|array',
];
}
}
152 changes: 152 additions & 0 deletions config/laratrust_seeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?php

return [
/**
* Control if the seeder should create a user per role while seeding the data.
*/
'create_users' => false,

/**
* Control if all the laratrust tables should be truncated before running the seeder.
*/
'truncate_tables' => true,

'roles_structure' => [
'super_admin' => [
'calendar' => 'c,r,u,d',
'flow-board' => 'c,r,u,d',
'patient' => 'c,r,u,d',
'payments' => 'c,r,u,d',
'inventory' => 'c,r,u,d',
'procedures' => 'c,r,u,d',
'users' => 'c,r,u,d',
'facilities' => 'c,r,u,d',
'roles' => 'c,r,u,d',
'reports' => 'c,r,u,d',
'misc' => 'c,r,u,d',
'popups' => 'c,r,u,d',
'qa-measures' => 'c,r,u,d',
'help' => 'c,r,u,d',
],
'admin' => [
'calendar' => 'c,r,u,d',
'flow-board' => 'c,r,u,d',
'patient' => 'c,r,u,d',
'payments' => 'c,r,u,d',
'inventory' => 'c,r,u,d',
'procedures' => 'c,r,u,d',
'users' => 'c,r',
'facilities' => 'c,r',
'roles' => 'c,r',
'reports' => 'c,r,u,d',
'misc' => 'c,r,u,d',
'popups' => 'c,r,u,d',
'qa-measures' => 'c,r,u,d',
'help' => 'r',
],
'users' => [
'calendar' => 'r',
'patient' => 'r',
'payments' => 'r',
'inventory' => 'r',
'procedures' => 'r',
'users' => 'r',
'facilities' => 'r',
'reports' => 'r',
'misc' => 'r',
'popups' => 'r',
'qa-measures' => 'r',
'help' => 'r',
],
'accounting' => [
'Calendar' => 'r',
'patient' => 'r',
'payments' => 'c,r,u,d',
'inventory' => 'r',
'procedures' => 'r',
'users' => 'r,u',
'facilities' => 'r,u',
'reports' => 'c,r,u,d',
'misc' => 'r,u',
'popups' => 'r,u',
'qa-measures' => 'r,u',
'help' => 'r',
],
'clinicians' => [
'calendar' => 'c,r,u,d',
'patient' => 'c,r,u,d',
'payments' => 'c,r,u,d',
'inventory' => 'r,u',
'procedures' => 'r,u',
'users' => 'r,u',
'facilities' => 'r,u',
'reports' => 'r,u',
'misc' => 'r,u',
'popups' => 'r,u',
'qa-measures' => 'r,u',
'help' => 'r',
],
'emergency_login' => [
'calendar' => 'r',
'patient' => 'c,r,u,d',
'payments' => 'r',
'inventory' => 'r',
'procedures' => 'r',
'users' => 'r',
'facilities' => 'r',
'reports' => 'r',
'misc' => 'r',
'popups' => 'r',
'qa-measures' => 'r',
'help' => 'r',
],
'front_office' => [
'calendar' => 'r,u',
'patient' => 'r,u',
'payments' => 'r,u',
'inventory' => 'r',
'procedures' => 'r',
'users' => 'r',
'facilities' => 'r',
'reports' => 'r',
'misc' => 'r',
'popups' => 'r',
'qa-measures' => 'r',
'help' => 'r',
],
'physicians' => [
'calendar' => 'c,r,u,d',
'patient' => 'c,r,u,d',
'payments' => 'r,u',
'inventory' => 'r',
'procedures' => 'c,r,u,d',
'users' => 'r',
'facilities' => 'r',
'reports' => 'c,r,u,d',
'misc' => 'c,r,u,d',
'popups' => 'c,r,u,d',
'qa-measures' => 'c,r,u,d',
'help' => 'r',
],
'super_student' => [
'calendar' => 'r,u',
'patient' => 'r,u',
'payments' => 'r',
'inventory' => 'r',
'procedures' => 'r,u',
'users' => 'r',
'facilities' => 'r',
'reports' => 'r,u',
'misc' => 'r,u',
'popups' => 'r,u',
'qa-measures' => 'r,u',
'help' => 'r',
],
],
'permissions_map' => [
'c' => 'create',
'r' => 'read',
'u' => 'update',
'd' => 'delete'
]
];
3 changes: 3 additions & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function truncateAndSeedData()
DB::table($name)->truncate();
}
Schema::enableForeignKeyConstraints();

$this->seedData();
$this->complete();
}
Expand All @@ -58,7 +59,9 @@ public function seedData()
if (count($continents) < 1) {
Artisan::call('world:init');
}

$this->call(CurrencySeeder::class);
$this->call(LaratrustSeeder::class);
$this->call(UserTableSeeder::class);
$this->call(AddressTableSeeder::class);
$this->call(ContactTableSeeder::class);
Expand Down
Loading