wilded
11/1/2018 - 7:32 AM

Model Functions in Laravel

Model Functions in Laravel Files located under app/ModelName

protected $fillable = ['title', 'body']; //Allowed Fields
protected $guarded = ['id']; //Not Allowed Fields

public function scopeCompleted($query)
    {
        return $query->where('completedField', 1);
    }

    public function scopeIncomplete ($query)
    {
        return $query->where('completedField', 0);
    }

    public function scopeAll($query)
    {
        return $query->all();
    }