我试图通过覆盖每个模型的delete()函数来实现级联软删除,我认为它应该从Project级联到Version再到Link,但问题是它似乎根本没有做到这一点。其想法是,删除项目也会删除所有版本,这将删除所有链接并清除其缓存的版本,但使用$this->versions()->delete();似乎并不实际调用Version模型中的delete()方法。
有什么办法让它像我期望的那样工作吗?
class Project extends Eloquent {
protected $softDelete = true;
public function versions()
我用的是拉拉4.2.8和雄辩的ORM。当我试图删除它不起作用的时候。它从我的数据库中删除数据。我想从逻辑上删除数据,而不是物理上的。在这里,我给出了我尝试过的代码
模型
use Illuminate\Auth\UserInterface;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
class User extends Eloquent implements UserInterface {
/**
* The database table used by the model.
*
* @var
我的模型是:
<?php namespace App\Http\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Province extends Model {
// use SoftDeletes;
public $timestamps = false;
protected $dates = ['deleted_at'];
public function country(){
return $thi
好的,我正在尝试在另一个雄辩的模型中使用雄辩的方法"firstOrCreate“。
FriendRequest口才
class FriendRequest extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
public $table = 'requests';
protected $guarded = array('id');
protected $softDelete = true;
public function friend
我在其中创建了一个ProductPolicy:
<?php
namespace App\Policies;
use App\Models\Product;
use App\Models\Vendor;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class ProductPolicy
{
use HandlesAuthorization;
public function before($user, $ability){
if($user->roles == 'admin