Add/edit the award class in Admin #155

This commit is contained in:
Nabeel Shahzad
2018-03-17 12:17:38 -05:00
parent a21e2dd412
commit e9baf4acb5
14 changed files with 195 additions and 86 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Services;
use App\Support\ClassLoader;
use Module;
class AwardService
{
/**
* Find any of the award classes
* @return \App\Interfaces\AwardInterface[]
*/
public function findAllAwardClasses()
{
$awards = [];
$formatted_awards = [];
# Find the awards in the app/Awards directory
$classes = ClassLoader::getClassesInPath(app_path('/Awards'));
$awards = array_merge($awards, $classes);
# Look throughout all the other modules, in the module/{MODULE}/Awards directory
foreach (Module::all() as $module) {
$path = $module->getExtraPath('Awards');
$classes = ClassLoader::getClassesInPath($path);
$awards = array_merge($awards, $classes);
}
foreach ($awards as $award) {
$formatted_awards[\get_class($award)] = $award;
}
return $formatted_awards;
}
}