Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在控制器中使用laravel Auditor_Php_Laravel - Fatal编程技术网

Php 如何在控制器中使用laravel Auditor

Php 如何在控制器中使用laravel Auditor,php,laravel,Php,Laravel,我在一个模型中使用了laravel Auditor,它的工作原理如下: use Illuminate\Database\Eloquent\Model; use OwenIt\Auditing\Contracts\Auditable; class Contracts extends Model implements Auditable { use \OwenIt\Auditing\Auditable; protected $fillable=['condatereceived

我在一个模型中使用了laravel Auditor,它的工作原理如下:

use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Contracts\Auditable;

class Contracts extends Model implements Auditable
{
    use \OwenIt\Auditing\Auditable;

     protected $fillable=['condatereceived'];

    public function user()
        {
            return $this->belongsTo(User::class);
        } 
}
但我想在控制器中使用它作为:

public function updatecomplated(Request $request, $id,Contracts $contract ,Auditor $auditor)
{
     Contracts::where('id', $id)
     ->update(['complated' => 50, 'conuploadby' => Auth::id(),'constatus' =>'Need To Active' ]);

     if ($audit = $auditor->execute($contract)) {
        $auditor->prune($contract);
    }
    return redirect()->back();
}
控制器中的代码显示错误:

调用未定义的方法OwenIt\Auditing\Facades\Auditor::execute()

有没有在控制器中使用auditor的想法,请。

试试这个,很简单,有很好的文档

只需将其添加到您的表中即可

$table->auditable();
这是给你的模特的

namespace App;

use Yajra\Auditable\AuditableTrait;

class User extends Model
{
    use AuditableTrait;
}
现在就这样打电话给你的审计师

$user->creator // for who create 

有关检查特征的详细信息,请参见
希望这有帮助

谢谢你的回答,我会试试看
$user->updater //for who update data