Пример #1
0
 public function testDelete()
 {
     $this->model->title = "Hello, world!";
     $this->assertTrue($this->model->save());
     $this->model = FullyBlameableModel::find(1);
     $this->assertTrue($this->model->delete());
     // Reload the model
     $this->model = FullyBlameableModel::withTrashed()->find(1);
     // Check datetimes are being set properly for sanity's sake
     $this->assertNotNull($this->model->created_at);
     $this->assertGreaterThan($this->model->created_at, $this->model->updated_at);
     $this->assertNotNull($this->model->deleted_at);
     $this->assertEquals(1, $this->model->created_by_id);
     $this->assertEquals(1, $this->model->updated_by_id);
     $this->assertEquals(1, $this->model->deleted_by_id);
     $this->assertEquals(Auth::user()->id, $this->model->deleted_by->id);
 }
Пример #2
0
<?php

namespace Culpa;

use Illuminate\Database\Eloquent\Model;
/**
 * A model with all 3 fields, with the default values
 */
class FullyBlameableModel extends Model
{
    use CreatedBy, UpdatedBy, DeletedBy, Blameable;
    protected $table = 'posts';
    protected $softDelete = true;
    protected $blameable = array('created', 'updated', 'deleted');
}
FullyBlameableModel::observe(new BlameableObserver());