public function testDelete()
 {
     $this->model->title = "Hello, world!";
     $this->assertTrue($this->model->save());
     $this->model = CompatibleBlameableModel::find(1);
     $this->assertTrue($this->model->delete());
     // Reload the model
     $this->model = CompatibleBlameableModel::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);
 }
Exemple #2
0
<?php

namespace Culpa;

use Illuminate\Database\Eloquent\Model;
/**
 * A model with custom names for fields
 */
class CompatibleBlameableModel extends Model
{
    protected $table = 'posts';
    protected $softDelete = true;
    protected $blameable = array('created', 'updated', 'deleted');
    public function createdBy()
    {
        return $this->belongsTo('User');
    }
    public function updatedBy()
    {
        return $this->belongsTo('User');
    }
    public function deletedBy()
    {
        return $this->belongsTo('User');
    }
}
CompatibleBlameableModel::observe(new BlameableObserver());