Browse Source

Add Paste and Deletion models

master
Les De Ridder 6 years ago
parent
commit
30eff3455e
  1. 7
      app/Deletion.php
  2. 30
      app/Paste.php

7
app/Deletion.php

@ -6,5 +6,10 @@ use Illuminate\Database\Eloquent\Model;
class Deletion extends Model
{
//
public $timestamps = false;
public function paste()
{
return $this->belongsTo(Paste::class);
}
}

30
app/Paste.php

@ -6,5 +6,33 @@ use Illuminate\Database\Eloquent\Model;
class Paste extends Model
{
//
public $incrementing = false;
public $timestamps = false;
public function deletion()
{
return $this->hasOne(Deletion::class);
}
public function isDeleted()
{
return $this->deletion !== null;
}
public function delete($reason, $deleted_by)
{
if($this->isDeleted())
{
return false;
}
$deletion = new Deletion;
$deletion->reason = $reason;
$deletion->deleted_by = $deleted_by;
$deletion->deleted_at = Carbon::now();
$this->deletion()->save($deletion);
return true;
}
}
Loading…
Cancel
Save