mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Adding device's field in get_alert_rule and list-alert-rules API function (new) (#14481)
* Adding device's field in get_alert_rule and lis-alert-rules API function * Converting SQL request for list/get_alert_rules to Eloquent (thanks a lot to Murrant) * Manually added #14500 to pass pipeline * Fixing StyleCI error + trying to fix PHPStan errors * Trying to fix PHPStan errors (part 2)
This commit is contained in:
29
app/Http/Resources/AlertRule.php
Normal file
29
app/Http/Resources/AlertRule.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @property \App\Models\Device $devices
|
||||
* @property \App\Models\DeviceGroup $groups
|
||||
* @property \App\Models\Location $locations
|
||||
*/
|
||||
class AlertRule extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$rule = parent::toArray($request);
|
||||
$rule['devices'] = $this->devices->pluck('device_id')->all();
|
||||
$rule['groups'] = $this->groups->pluck('id')->all();
|
||||
$rule['locations'] = $this->locations->pluck('id')->all();
|
||||
|
||||
return $rule;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user