{"action":"opened","issue":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/852","repository_url":"https://api.github.com/repos/yajra/laravel-datatables","labels_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/852/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/852/comments","events_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/852/events","html_url":"https://github.com/yajra/laravel-datatables/issues/852","id":191194023,"number":852,"title":"yajra datatable error when search a term in search filter input","user":{"login":"ahmadbadpey","id":747216,"avatar_url":"https://avatars.githubusercontent.com/u/747216?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmadbadpey","html_url":"https://github.com/ahmadbadpey","followers_url":"https://api.github.com/users/ahmadbadpey/followers","following_url":"https://api.github.com/users/ahmadbadpey/following{/other_user}","gists_url":"https://api.github.com/users/ahmadbadpey/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmadbadpey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmadbadpey/subscriptions","organizations_url":"https://api.github.com/users/ahmadbadpey/orgs","repos_url":"https://api.github.com/users/ahmadbadpey/repos","events_url":"https://api.github.com/users/ahmadbadpey/events{/privacy}","received_events_url":"https://api.github.com/users/ahmadbadpey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-23T05:57:12Z","updated_at":"2016-11-23T05:57:12Z","closed_at":null,"body":"I have a `Question` model like this :\r\n```\r\n    class Question extends Model\r\n    \t{\r\n    \t\tuse SoftDeletes;\r\n    \r\n    \t\tprotected $primaryKey = 'question_id';\r\n    \r\n    \t\tprotected $fillable   = ['text', 'code', 'cat', 'answer', 'confirmed', 'is_private', 'email', 'parent', 'expert', 'expert_read_at', 'expert_updated_at', 'expert_admin_last_seen', 'confirmed_expert_admin', 'confirmed_expert_admin_at'];\r\n    \r\n            public function latest_sub_question ()\r\n    \t\t{\r\n    \t\t\treturn $this->hasOne(Question::class, 'parent', 'question_id')->latest();\r\n    \t\t}\r\n    }\r\n```\r\n\r\nAs you can see there is a **one to many** self-relationship in this model named  `latest_sub_question`.\r\n\r\nNow I want to create a datatable via [yajra datatable][1] laravel package. \r\n\r\nFor that I used these codes:\r\n```\r\n    $questions = Question::with('latest_sub_question')->whereNull('parent');\r\n        \r\n        $datatable = app('datatables')->of($questions)\r\n                        ->orderBy('created_at', 'desc')\r\n                        ->addColumn('checkbox', '<input type=\"checkbox\" name=\"item_id[]\" value=\"{{$question_id}}\" id=\"Check_{{$question_id}}\" class=\"minimal dtItemCheckbox\">')\r\n                        \r\n                        ->editColumn('text', function ($question) {\r\n                            \r\n                            $res = '<span data-toggle=\"tooltip\" data-placement=\"top\" title=\"' . str_limit(strip_tags($question->text), 200) . '\">' . str_limit(strip_tags($question->text), 40) . '</span>';\r\n        \r\n                            \r\n                            return $res;\r\n                        })\r\n                        ->editColumn('answer', function ($question) {\r\n        \r\n                            $res = '<span data-toggle=\"tooltip\" data-placement=\"top\" title=\"' . str_limit(strip_tags($question->answer), 200) . '\">' . str_limit(strip_tags($question->answer), 40) . '</span>';\r\n                            return $res;\r\n                        });\r\n        return $datatable->make(true);\r\n```\r\nAll things worked fine but when I enter a word (`hello` for example) on global filter search box an error like this occurred :\r\n```\r\n    QueryException in Connection.php line 761:\r\n    SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (SQL: select count(*) as aggregate from (select '1' as `row_count` from `questions` where `parent` is null and (LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello% or LOWER(``) LIKE %hello%) and `questions`.`deleted_at` is null order by `created_at` desc) count_row_table)\r\n```\r\nWhat is this error and why that is occurred?\r\n\r\n  [1]: https://github.com/yajra/laravel-datatables"}}
{"actor":{"display_login":"ahmadbadpey"}}