pastethingy/app/Paste.php

39 lines
604 B
PHP
Raw Normal View History

2016-05-28 19:05:54 +02:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Paste extends Model
{
2016-05-28 22:43:44 +02:00
public $incrementing = false;
public $timestamps = false;
public function deletion()
{
return $this->hasOne(Deletion::class);
}
public function isDeleted()
{
return $this->deletion !== null;
}
2016-05-29 01:34:24 +02:00
public function soft_delete($reason, $deleted_by)
2016-05-28 22:43:44 +02:00
{
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;
}
2016-05-28 19:05:54 +02:00
}