mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Adds checkout events
This commit is contained in:
parent
f0acf47101
commit
ea64abc607
31
app/Events/AccessoryCheckedOut.php
Normal file
31
app/Events/AccessoryCheckedOut.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Accessory;
|
||||||
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class AccessoryCheckedOut
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
public $accessory;
|
||||||
|
public $checkedOutTo;
|
||||||
|
public $logEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Accessory $accessory, $checkedOutTo, Actionlog $logEntry)
|
||||||
|
{
|
||||||
|
$this->accessory = $accessory;
|
||||||
|
$this->checkedOutTo = $checkedOutTo;
|
||||||
|
$this->logEntry = $logEntry;
|
||||||
|
}
|
||||||
|
}
|
31
app/Events/AssetCheckedOut.php
Normal file
31
app/Events/AssetCheckedOut.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class AssetCheckedOut
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
public $asset;
|
||||||
|
public $checkedOutTo;
|
||||||
|
public $logEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Asset $asset, $checkedOutTo, Actionlog $logEntry)
|
||||||
|
{
|
||||||
|
$this->asset = $asset;
|
||||||
|
$this->checkedOutTo = $checkedOutTo;
|
||||||
|
$this->logEntry = $logEntry;
|
||||||
|
}
|
||||||
|
}
|
31
app/Events/ComponentCheckedOut.php
Normal file
31
app/Events/ComponentCheckedOut.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\Component;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ComponentCheckedOut
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
public $component;
|
||||||
|
public $checkedOutTo;
|
||||||
|
public $logEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Component $component, $checkedOutTo, Actionlog $logEntry)
|
||||||
|
{
|
||||||
|
$this->component = $component;
|
||||||
|
$this->checkedOutTo = $checkedOutTo;
|
||||||
|
$this->logEntry = $logEntry;
|
||||||
|
}
|
||||||
|
}
|
31
app/Events/ConsumableCheckedOut.php
Normal file
31
app/Events/ConsumableCheckedOut.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\Consumable;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ConsumableCheckedOut
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
public $consumable;
|
||||||
|
public $checkedOutTo;
|
||||||
|
public $logEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Consumable $consumable, $checkedOutTo, Actionlog $logEntry)
|
||||||
|
{
|
||||||
|
$this->consumable = $consumable;
|
||||||
|
$this->checkedOutTo = $checkedOutTo;
|
||||||
|
$this->logEntry = $logEntry;
|
||||||
|
}
|
||||||
|
}
|
31
app/Events/LicenseCheckedOut.php
Normal file
31
app/Events/LicenseCheckedOut.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\License;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class LicenseCheckedOut
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
public $license;
|
||||||
|
public $checkedOutTo;
|
||||||
|
public $logEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(License $license, $checkedOutTo, Actionlog $logEntry)
|
||||||
|
{
|
||||||
|
$this->license = $license;
|
||||||
|
$this->checkedOutTo = $checkedOutTo;
|
||||||
|
$this->logEntry = $logEntry;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Events\AssetCheckedOut;
|
||||||
use App\Exceptions\CheckoutNotAllowed;
|
use App\Exceptions\CheckoutNotAllowed;
|
||||||
use App\Http\Traits\UniqueSerialTrait;
|
use App\Http\Traits\UniqueSerialTrait;
|
||||||
use App\Http\Traits\UniqueUndeletedTrait;
|
use App\Http\Traits\UniqueUndeletedTrait;
|
||||||
|
@ -266,7 +267,10 @@ class Asset extends Depreciable
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->save()) {
|
if ($this->save()) {
|
||||||
$this->logCheckout($note, $target);
|
$loggedAction = $this->logCheckout($note, $target);
|
||||||
|
|
||||||
|
event(new AssetCheckedOut($this, $target, $loggedAction));
|
||||||
|
|
||||||
$this->increment('checkout_counter', 1);
|
$this->increment('checkout_counter', 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue