GCTC-NTGC /
TalentCloud
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Http\Controllers; |
||||
| 4 | |||||
| 5 | use App\Http\Controllers\Controller; |
||||
| 6 | use App\Models\Resource; |
||||
| 7 | use Facades\App\Services\WhichPortal; |
||||
| 8 | use Illuminate\Support\Facades\Auth; |
||||
| 9 | use Illuminate\Support\Facades\Lang; |
||||
| 10 | use Illuminate\Support\Facades\Log; |
||||
| 11 | use Illuminate\Support\Facades\Storage; |
||||
| 12 | |||||
| 13 | class ResourcesController extends Controller |
||||
| 14 | { |
||||
| 15 | |||||
| 16 | /** |
||||
| 17 | * Display the resources template |
||||
| 18 | * |
||||
| 19 | * @return \Illuminate\Http\Response |
||||
| 20 | */ |
||||
| 21 | public function show() |
||||
| 22 | { |
||||
| 23 | $user = Auth::user(); |
||||
| 24 | $resources_template = Lang::get('common/resources'); |
||||
| 25 | $resources = []; |
||||
| 26 | |||||
| 27 | // Iterate through resource files, and push link type array into resources array. |
||||
| 28 | if ($user->isUpgradedManager() || $user->isHrAdvisor()) { |
||||
| 29 | $files = Resource::all(); |
||||
| 30 | foreach ($files as $file) { |
||||
| 31 | array_push($resources, [ |
||||
| 32 | 'link' => asset(Storage::url($file->file)), |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 33 | 'title' => '', |
||||
| 34 | 'text' => $file->name, |
||||
| 35 | ]); |
||||
| 36 | } |
||||
| 37 | |||||
| 38 | // Sort the list alphabetically. |
||||
| 39 | usort($resources, function ($filenameA, $filenameB) { |
||||
| 40 | return strcmp($filenameA['text'], $filenameB['text']); |
||||
| 41 | }); |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | $portal = WhichPortal::isHrPortal() ? 'hr' : 'manager'; |
||||
| 45 | |||||
| 46 | return view('common/resources', [ |
||||
|
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 47 | // Localized strings. |
||||
| 48 | 'resources_template' => $resources_template, |
||||
| 49 | 'portal' => $portal, |
||||
| 50 | // List of resource downloads. |
||||
| 51 | 'resources' => $resources, |
||||
| 52 | ]); |
||||
| 53 | } |
||||
| 54 | } |
||||
| 55 |