mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added last_checkout and notes from pivot for accessories
This commit is contained in:
parent
8827d33a43
commit
88f03e6b55
|
@ -75,7 +75,8 @@ class AccessoryCheckoutController extends Controller
|
||||||
'accessory_id' => $accessory->id,
|
'accessory_id' => $accessory->id,
|
||||||
'created_at' => Carbon::now(),
|
'created_at' => Carbon::now(),
|
||||||
'user_id' => Auth::id(),
|
'user_id' => Auth::id(),
|
||||||
'assigned_to' => $request->get('assigned_to')
|
'assigned_to' => $request->get('assigned_to'),
|
||||||
|
'note' => $request->input('note')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();
|
DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();
|
||||||
|
|
|
@ -68,8 +68,13 @@ class AccessoriesTransformer
|
||||||
|
|
||||||
|
|
||||||
$array = array();
|
$array = array();
|
||||||
|
|
||||||
|
|
||||||
foreach ($accessory_users as $user) {
|
foreach ($accessory_users as $user) {
|
||||||
|
\Log::debug(print_r($user->pivot, true));
|
||||||
|
\Log::debug(print_r($user->pivot, true));
|
||||||
$array[] = [
|
$array[] = [
|
||||||
|
|
||||||
'assigned_pivot_id' => $user->pivot->id,
|
'assigned_pivot_id' => $user->pivot->id,
|
||||||
'id' => (int) $user->id,
|
'id' => (int) $user->id,
|
||||||
'username' => e($user->username),
|
'username' => e($user->username),
|
||||||
|
@ -77,7 +82,8 @@ class AccessoriesTransformer
|
||||||
'first_name'=> e($user->first_name),
|
'first_name'=> e($user->first_name),
|
||||||
'last_name'=> e($user->last_name),
|
'last_name'=> e($user->last_name),
|
||||||
'employee_number' => e($user->employee_num),
|
'employee_number' => e($user->employee_num),
|
||||||
'checkout_notes' => $accessory->lastCheckoutArray[0]['note'],
|
'checkout_notes' => $user->pivot->note,
|
||||||
|
'last_checkout' => Helper::getFormattedDateObject($user->pivot->created_at, 'datetime'),
|
||||||
'type' => 'user',
|
'type' => 'user',
|
||||||
'available_actions' => ['checkin' => true]
|
'available_actions' => ['checkin' => true]
|
||||||
];
|
];
|
||||||
|
|
|
@ -234,7 +234,7 @@ class Accessory extends SnipeModel
|
||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->withPivot('id')->withTrashed();
|
return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->withPivot('id', 'created_at', 'note')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -295,7 +295,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
*/
|
*/
|
||||||
public function accessories()
|
public function accessories()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('\App\Models\Accessory', 'accessories_users', 'assigned_to', 'accessory_id')->withPivot('id')->withTrashed();
|
return $this->belongsToMany('\App\Models\Accessory', 'accessories_users', 'assigned_to', 'accessory_id')
|
||||||
|
->withPivot('id', 'created_at', 'note')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th data-searchable="false" data-formatter="usersLinkFormatter" data-sortable="false" data-field="name">{{ trans('general.user') }}</th>
|
<th data-searchable="false" data-formatter="usersLinkFormatter" data-sortable="false" data-field="name">{{ trans('general.user') }}</th>
|
||||||
<th data-searchable="false" data-sortable="false" data-field="checkout_notes">{{ trans('general.notes') }}</th>
|
<th data-searchable="false" data-sortable="false" data-field="checkout_notes">{{ trans('general.notes') }}</th>
|
||||||
|
<th data-searchable="false" data-formatter="dateDisplayFormatter" data-sortable="false" data-field="last_checkout">{{ trans('admin/hardware/table.checkout_date') }}</th>
|
||||||
<th data-searchable="false" data-sortable="false" data-field="actions" data-formatter="accessoriesInOutFormatter">{{ trans('table.actions') }}</th>
|
<th data-searchable="false" data-sortable="false" data-field="actions" data-formatter="accessoriesInOutFormatter">{{ trans('table.actions') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
Loading…
Reference in a new issue