namespace todoparrot;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Todolist extends Model
{
public function sample()
{
echo "sample function";
}
}
pc@pc:php artisan tinker
Psy Shell v0.7.2 (PHP 7.0.8-0ubuntu0.16.04.3 — cli) by Justin Hileman
>>> namespace todoparrot;
=> null
>>> $tl=Todolist::find(1);
=> null
>>> $tl->sample();
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function sample() on null
>>>
Açıklama yazmadım üstatlar kodu okuduğunda anlayacaklardır. Hatanın sebebi nedir ?