This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
mkucuk.199113558
Hello,
I have successfuly added event handlers to models. But, when I tried to add event handlers to custom pivot class, they are not working.
I need to solve this before deadline of the project, please help me.
<?php namespace VideoAnalitik\Va\Models;
use October\Rain\Database\Pivot;
class AppSourcePivot extends Pivot
{
public function afterSave()
{
file_put_contents('/tmp/0_afterSave-pivot', var_export($this, true));
return true;
}
public function afterDelete()
{
file_put_contents('/tmp/0_afterDelete-pivot', var_export($this, true));
return true;
}
public function beforeDelete()
{
file_put_contents('/tmp/0_beforeDelete-pivot', var_export($this, true));
return true;
}
}
huseyinkozan
Adding laravel event filter works for saved. But not for deleting.
In Plugin.php:
public function boot()
{
AppSourcePivot::saved(function(AppSourcePivot $appsource)
{
return AppSourcePivot::myAfterSave($appsource);
})
AppSourcePivot::deleting(function(AppSourcePivot $appsource)
{
return AppSourcePivot::myBeforeDelete($appsource);
})
}
1-2 of 2