Updates checkout events to not depend on log

This commit is contained in:
Till Deeke 2018-07-28 00:05:45 +02:00
parent 17fc59f989
commit e24f292a1a
9 changed files with 27 additions and 16 deletions

View file

@ -22,10 +22,11 @@ class AccessoryCheckedOut
* *
* @return void * @return void
*/ */
public function __construct(Accessory $accessory, $checkedOutTo, Actionlog $logEntry) public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy, $note)
{ {
$this->accessory = $accessory; $this->accessory = $accessory;
$this->checkedOutTo = $checkedOutTo; $this->checkedOutTo = $checkedOutTo;
$this->logEntry = $logEntry; $this->checkedOutBy = $checkedOutBy;
$this->note = $note;
} }
} }

View file

@ -22,10 +22,11 @@ class AssetCheckedOut
* *
* @return void * @return void
*/ */
public function __construct(Asset $asset, $checkedOutTo, Actionlog $logEntry) public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $note)
{ {
$this->asset = $asset; $this->asset = $asset;
$this->checkedOutTo = $checkedOutTo; $this->checkedOutTo = $checkedOutTo;
$this->logEntry = $logEntry; $this->checkedOutBy = $checkedOutBy;
$this->note = $note;
} }
} }

View file

@ -2,7 +2,6 @@
namespace App\Events; namespace App\Events;
use App\Models\Actionlog;
use App\Models\Component; use App\Models\Component;
use App\Models\User; use App\Models\User;
use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\Channel;
@ -15,17 +14,18 @@ class ComponentCheckedOut
public $component; public $component;
public $checkedOutTo; public $checkedOutTo;
public $logEntry; public $checkedOutBy;
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @return void * @return void
*/ */
public function __construct(Component $component, $checkedOutTo, Actionlog $logEntry) public function __construct(Component $component, $checkedOutTo, $quantity, User $checkedOutBy)
{ {
$this->component = $component; $this->component = $component;
$this->checkedOutTo = $checkedOutTo; $this->checkedOutTo = $checkedOutTo;
$this->logEntry = $logEntry; $this->quantity = $quantity;
$this->checkedOutBy = $checkedOutBy;
} }
} }

View file

@ -22,10 +22,11 @@ class ConsumableCheckedOut
* *
* @return void * @return void
*/ */
public function __construct(Consumable $consumable, $checkedOutTo, Actionlog $logEntry) public function __construct(Consumable $consumable, $checkedOutTo, User $checkedOutBy, $note)
{ {
$this->consumable = $consumable; $this->consumable = $consumable;
$this->checkedOutTo = $checkedOutTo; $this->checkedOutTo = $checkedOutTo;
$this->logEntry = $logEntry; $this->checkedOutBy = $checkedOutBy;
$this->note = $note;
} }
} }

View file

@ -22,10 +22,11 @@ class LicenseCheckedOut
* *
* @return void * @return void
*/ */
public function __construct(License $license, $checkedOutTo, Actionlog $logEntry) public function __construct(License $license, $checkedOutTo, User $checkedOutBy, $note)
{ {
$this->license = $license; $this->license = $license;
$this->checkedOutTo = $checkedOutTo; $this->checkedOutTo = $checkedOutTo;
$this->logEntry = $logEntry; $this->checkedOutBy = $checkedOutBy;
$this->note = $note;
} }
} }

View file

@ -82,7 +82,7 @@ class AccessoryCheckoutController extends Controller
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();
event(new AccessoryCheckedOut($accessory, $user, $logaction)); event(new AccessoryCheckedOut($accessory, $user, Auth::user(), $request->input('note'));
// Redirect to the new accessory page // Redirect to the new accessory page
return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.checkout.success')); return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.checkout.success'));

View file

@ -89,7 +89,7 @@ class ComponentCheckoutController extends Controller
$logaction = $component->logCheckout(e(Input::get('note')), $asset); $logaction = $component->logCheckout(e(Input::get('note')), $asset);
event(new ComponentCheckedOut($component, $asset, $logaction)); event(new ComponentCheckedOut($component, $asset, $request->input('assigned_qty'), Auth::user()));
return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success')); return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success'));
} }

View file

@ -42,7 +42,7 @@ class ConsumableCheckoutController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store($consumableId) public function store(Request $request, $consumableId)
{ {
if (is_null($consumable = Consumable::find($consumableId))) { if (is_null($consumable = Consumable::find($consumableId))) {
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.not_found')); return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.not_found'));
@ -70,7 +70,7 @@ class ConsumableCheckoutController extends Controller
$logaction = $consumable->logCheckout(e(Input::get('note')), $user); $logaction = $consumable->logCheckout(e(Input::get('note')), $user);
event(new ConsumableCheckedOut($consumable, $user, $logaction)); event(new ConsumableCheckedOut($consumable, $user, Auth::user(), $request->input('note')));
// Redirect to the new consumable page // Redirect to the new consumable page
return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.checkout.success')); return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.checkout.success'));

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Licenses; namespace App\Http\Controllers\Licenses;
use App\Events\LicenseCheckedOut;
use App\Http\Requests\LicenseCheckoutRequest; use App\Http\Requests\LicenseCheckoutRequest;
use App\Models\Asset; use App\Models\Asset;
use App\Models\License; use App\Models\License;
@ -104,6 +105,9 @@ class LicenseCheckoutController extends Controller
} }
if ($licenseSeat->save()) { if ($licenseSeat->save()) {
$licenseSeat->logCheckout(request('note'), $target); $licenseSeat->logCheckout(request('note'), $target);
event(new LicenseCheckedOut($licenseSeat->license, $target, Auth::user(), request('note')));
return true; return true;
} }
return false; return false;
@ -119,6 +123,9 @@ class LicenseCheckoutController extends Controller
if ($licenseSeat->save()) { if ($licenseSeat->save()) {
$licenseSeat->logCheckout(request('note'), $target); $licenseSeat->logCheckout(request('note'), $target);
event(new LicenseCheckedOut($licenseSeat->license, $target, Auth::user(), request('note')));
return true; return true;
} }
return false; return false;