Ad

Can't Feed To Database Table Via Eloquent

- 1 answer

i am new to laravel.I have a project table in my database and i created a eloquent model using php artisan make:model project;

it created the following codes in project.php page

namespace App;

use Illuminate\Database\Eloquent\Model;

class project extends Model
{
    //
}

when i attempt to feed data in my projects table laravel is giving me the error like

Route::get('/', function () 
 {
        $project = new project;  
    $project->name = 'Leonardo Da Vinci';

    $project->save();   
    return View::make('welcome');
 });

class project not found

Ad

Answer

Note that your project model has a namespace. Either you import your model class on top of your routes.php:

use App\project

or use the full qualified name directly in code:

$project = new App\project;

I recommend to use upper camel case syntax for your class name like the whole framework do App\Project

Ad
source: stackoverflow.com
Ad