如何在 Laravel 中构建基于条件的查询?
我可以在Code Igniter中执行此操作:
$this->db->select();
$this->from->('node');
if ($published == true)
{
$this->db->where('published', 'true');
}
if (isset($year))
{
$this->db->where('year >', $year);
}
$this->db->get();
如何翻译此代码以使其在Laravel中工作?