-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update ddates * Improve Module seeder logic * Fix naming * Add state logic * Add modules to inertia share * Linting * Add random generaot backend * Generate components * Sort user by firstname * Proof of Concept up and download from s3 * Image to s3 nearly done (req to controller not working) * s3 Image Upload in user register and s3 show image funciton ready for use * Remove outdated docs * Add spatie permissions * Remove dev code * Migrate to rbac * Update routes * Fix drop col * All comments implemented * Add super admin role to prevent erros * Add edit view * Add link to old register/assigne page * Add special role * Add disabled flag * Fix namings * Add public api * Improve user view * Add missing if * Add missing dependencies * Improve S3 Implmentation * Improvee admin ui * Fix s3 logic * Fix S3 logic * Allow to edit super admins (except roles) --------- Co-authored-by: DontEdit <vitor.macedo@outlook.de> Co-authored-by: DontEdit <115659871+DontEdit@users.noreply.github.com>
- Loading branch information
1 parent
9406f39
commit fa63d92
Showing
123 changed files
with
2,573 additions
and
8,354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\User; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class PublicApiController extends Controller | ||
{ | ||
/** | ||
* Returns all users. | ||
*/ | ||
public function users(): JsonResponse | ||
{ | ||
// get all users and get execute avatarUrl | ||
$users = User::with('course', 'roles')->get()->map(function ($user) { | ||
$user->avatarUrl = $user->avatarUrl(); | ||
|
||
return $user; | ||
}); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'users' => $users, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
app/Http/Controllers/DashboardAdminRandomGeneratorController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Course; | ||
use App\Models\State; | ||
use App\Models\User; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Support\Facades\Request; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class DashboardAdminRandomGeneratorController extends Controller | ||
{ | ||
/** | ||
* Display the dashboard admin random generator page | ||
*/ | ||
public function index(): Response | ||
{ | ||
// get all users except tutors and admins | ||
$users = User::doesntHave('roles')->orderBy('firstname')->with('course')->get()->map(function ($user) { | ||
$user->avatarUrl = $user->avatarUrl(); | ||
|
||
return $user; | ||
}); | ||
|
||
// get all courses | ||
$courses = Course::all(); | ||
|
||
return Inertia::render('Dashboard/Admin/RandomGenerator/Index', [ | ||
'users' => $users, | ||
'courses' => $courses, | ||
]); | ||
} | ||
|
||
/** | ||
* Execute the dashboard admin random generator submit action | ||
*/ | ||
public function indexExecuteSubmit(): JsonResponse | ||
{ | ||
// validate the request | ||
$request = Request::validate([ | ||
'state' => ['required', 'string', 'in:setup,idle,running,stopped'], | ||
'user_id' => ['integer', 'exists:users,id'], | ||
]); | ||
|
||
// get the user | ||
$user = null; | ||
if ($request['state'] == 'stopped') { | ||
$user = User::find($request['user_id']); | ||
|
||
// check if no user was found | ||
if (! $user) { | ||
return response()->json([ | ||
'success' => false, | ||
'message' => 'User not found', | ||
]); | ||
} | ||
|
||
$user->avatarUrl = $user->avatarUrl(); | ||
} | ||
|
||
// check if a state exists or we need to create a new one | ||
$state = State::where('key', 'randomGenerator')->first(); | ||
if (! $state) { | ||
$state = new State(); | ||
$state->key = 'randomGenerator'; | ||
} | ||
|
||
// update the state | ||
$state->value = json_encode([ | ||
'state' => $request['state'], | ||
// return only id, firstname, lastname and avatarUrl | ||
'user' => $user ? $user->only(['id', 'firstname', 'lastname', 'avatarUrl']) : null, | ||
]); | ||
|
||
// save the state | ||
$state->save(); | ||
|
||
// return success | ||
return response()->json([ | ||
'success' => true, | ||
]); | ||
} | ||
} |
Oops, something went wrong.