some work on models
This commit is contained in:
@@ -2,13 +2,33 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\NotificationContext;
|
||||
use App\Models\Concerns\Reportable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Change proposal
|
||||
*
|
||||
* @property Row[]|Collection $addedRows
|
||||
* @property Row[]|Collection $removedRows
|
||||
*/
|
||||
class Proposal extends Model
|
||||
{
|
||||
use Reportable;
|
||||
use NotificationContext;
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function(Proposal $self) {
|
||||
// update refcounts
|
||||
$self->addedRows()->decrement('refs');
|
||||
$self->removedRows()->decrement('refs');
|
||||
});
|
||||
}
|
||||
|
||||
/** Added rows */
|
||||
public function addedRows()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user