some work on models

This commit is contained in:
2018-07-14 14:34:17 +02:00
parent 6fd1d7eb89
commit 7493d3e176
7 changed files with 138 additions and 0 deletions
+20
View File
@@ -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()
{