<span class="pln"> </span><span class="pun">&lt;?</span><span class="pln">php </span><span class="kwd">namespace</span><span class="pln"> </span><span class="typ">App</span><span class="pln">\Models\Tutorial</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">use</span><span class="pln"> </span><span class="typ">CodeIgniter</span><span class="pln">\Model</span><span class="pun">;</span><span class="pln"> </span><span class="com">/** * Tutorial of NewsModel * * @author hoksi */</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">NewsModel</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">Model</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">protected</span><span class="pln"> $table </span><span class="pun">=</span><span class="pln"> </span><span class="str">'news'</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getNews</span><span class="pun">(</span><span class="pln">$slug </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$slug </span><span class="pun">===</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> $this</span><span class="pun">-&gt;</span><span class="pln">findAll</span><span class="pun">();</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> $this</span><span class="pun">-&gt;</span><span class="pln">asArray</span><span class="pun">()</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="kwd">where</span><span class="pun">([</span><span class="str">'slug'</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> $slug</span><span class="pun">])</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">first</span><span class="pun">();</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">}</span>