0

I have query:

$query = Task::query()->select(['tasks.*', 'rootTask.is_public as rootPublic']);
        $query->leftJoin('tasks as rootTask', function ($join) {
        $join->on('tasks._lft', '>=', 'rootTask._lft')
            ->whereNull('rootTask.deleted_at')
            ->where('tasks._lft', '<=', 'rootTask._rgt')
            ->whereNull('rootTask.parent_id');
        });

when I try to get $task->rootPublic it returns NULL But if I do $query->toSql(); and run that SQL it returns 1.

What can be an issue?

2
  • rootPublic is in the fillable array? Commented Nov 16, 2023 at 12:10
  • @KhayamKhan why it should? In Laravel, the $fillable property within an Eloquent model is used to specify which model attributes are mass-assignable. This property helps to protect against mass assignment vulnerabilities, ensuring that only specified fields can be updated en masse through Eloquent's create or update methods. It's virtual property at all But I tried, nothing changed Commented Nov 17, 2023 at 5:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.