samedi 5 août 2017

Error when use SoftDeletes

I got this error when I use SoftDeletes in some Model.

(1/1) FatalThrowableError

Type error: Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in /Users/ThunderBirdsX3/Desktop/Workspace/myproject/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 519 and exactly 2 expected

With Sell::destroy($id); and Sell::find($id)->delete();.

Sell Model

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Sell extends Model
{
  use SoftDeletes;

  /* The attributes that are mass assignable.
  *
  * @var array
  */
  protected $fillable = [
    'employee_id', 'product_id',
  ];

  const UPDATED_AT = null;

  public function Employee()
  {
    return $this->belongsTo(Employee::class)->withTrashed();
  }

  public function Product()
  {
    return $this->belongsTo(Product::class)->withTrashed();
  }

  public function Install()
  {
    return $this->hasOne(Install::class);
  }
}

If I remove use SoftDeletes; out it didn't get any error. And my sells table, Already has deleted_at column.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ud4JWW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire