pastethingy/app/Paste.php

39 lines
599 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;
}
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;
}
2016-05-28 19:05:54 +02:00
}