mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Standardized component API output
This commit is contained in:
parent
b3186ba5ea
commit
5d18937e94
|
@ -58,12 +58,22 @@ class ComponentsTransformer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function transformCheckedoutComponents(Collection $components_users, $total)
|
public function transformCheckedoutComponents(Collection $components_assets, $total)
|
||||||
{
|
{
|
||||||
$array = array();
|
$array = array();
|
||||||
foreach ($components_users as $user) {
|
foreach ($components_assets as $asset) {
|
||||||
$array[] = (new UsersTransformer)->transformUser($user);
|
$array[] = [
|
||||||
|
'assigned_pivot_id' => $asset->pivot->id,
|
||||||
|
'id' => (int) $asset->id,
|
||||||
|
'name' => e($asset->model->present()->name) .' '.e($asset->present()->name),
|
||||||
|
'qty' => $asset->pivot->assigned_qty,
|
||||||
|
'type' => 'asset',
|
||||||
|
'created_at' => Helper::getFormattedDateObject($asset->pivot->created_at, 'datetime'),
|
||||||
|
'available_actions' => ['checkin' => true]
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Component extends SnipeModel
|
||||||
|
|
||||||
public function assets()
|
public function assets()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('\App\Models\Asset', 'components_assets')->withPivot('assigned_qty', 'created_at', 'user_id');
|
return $this->belongsToMany('\App\Models\Asset', 'components_assets')->withPivot('id', 'assigned_qty', 'created_at', 'user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function admin()
|
public function admin()
|
||||||
|
|
|
@ -120,5 +120,14 @@ class ComponentPresenter extends Presenter
|
||||||
return (string) link_to_route('consumables.show', e($this->name), $this->id);
|
return (string) link_to_route('consumables.show', e($this->name), $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Url to view this item.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function viewUrl()
|
||||||
|
{
|
||||||
|
return route('accessories.show', $this->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue