How to get flexibility in laravel sql query
<p>I want to add a sql filter <code>where('comment_id', '=', 1)</code> to php code</p>

<pre><code>$datas = $this-&gt;model-&gt;ADD HERE-&gt;orderBy('created_at', 'DESC')-&gt;paginate(15);
</code></pre>

<p>Trying to add the string to code take me hours. How to make it?</p>

<hr>

<p>Here is my code:</p>

<p>CommentResource.php passing the sql filter as string parameter.</p>

<pre><code>&lt;?php
class CommentResource extends BaseResource
{    
    public function index()
    {
        $filter = "where('comment_id', '=', 1)";
        return parent::index_filter($filter);
    }
</code></pre>

<p>CommentResource.php</p>

<pre><code>&lt;?php
class BaseResource extends Controller
{
    protected function index_filter($filter)
    {
        $datas = $this-&gt;model-&gt;ADD HERE-&gt;orderBy('created_at', 'DESC')-&gt;paginate(15);
        return view($this-&gt;resourceView.'.index')-&gt;with('datas', $datas);
    }
}
</code></pre>