Added /api/settings to retrieve all VA settings #120
This commit is contained in:
28
app/Http/Controllers/Api/SettingsController.php
Normal file
28
app/Http/Controllers/Api/SettingsController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Repositories\SettingRepository;
|
||||
use App\Http\Resources\Setting as SettingResource;
|
||||
|
||||
class SettingsController extends RestController
|
||||
{
|
||||
protected $settingRepo;
|
||||
|
||||
public function __construct(SettingRepository $settingRepo) {
|
||||
$this->settingRepo = $settingRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the airlines, paginated
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$settings = $this->settingRepo
|
||||
->orderBy('order', 'asc')->get();
|
||||
|
||||
return SettingResource::collection($settings);
|
||||
}
|
||||
}
|
||||
21
app/Http/Resources/Setting.php
Normal file
21
app/Http/Resources/Setting.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\Resource;
|
||||
|
||||
class Setting extends Resource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'name' => $this->name,
|
||||
'value' => $this->value,
|
||||
'group' => $this->group,
|
||||
'order' => $this->order,
|
||||
'description' => $this->description,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user