I am using latest Laravel. I have a model Car
- id | name | * timestamp columns
:
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Car extends Model{
protected $fillable = [
'name'
];
}
Cars migration:
public function up()
{
Schema::create('cars', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('name')->nullable();
$table->timestamps();
});
I am trying to save new row in cars
table in the controller:
$car = new Car();
$car->name = 'example';
$car->save();
, but for $car->save()
, I am getting this error:
Call to undefined method App\Models\Car::setCreatedAt()
Even, If I create new migration/model create_table_test
(table with the same columns), I am getting the same error.
EDIT with stacktrace:
65 BadMethodCallException in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50
64 Illuminate\Database\Eloquent\Model:throwBadMethodCallException in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:36
63 Illuminate\Database\Eloquent\Model:forwardCallTo in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1614
62 Illuminate\Database\Eloquent\Model:__call in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php:47
61 Illuminate\Database\Eloquent\Model:updateTimestamps in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:791
60 Illuminate\Database\Eloquent\Model:performInsert in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:663
59 Illuminate\Database\Eloquent\Model:save in /mnt/e/xampp/htdocs/room2/project/app/Http/Controllers/Admin/CarsController.php:33
58 App\Http\Controllers\Admin\CarsController:importCars/mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
57 call_user_func_array in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
56 Illuminate\Routing\Controller:callAction in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
55 Illuminate\Routing\ControllerDispatcher:dispatch in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219
54 Illuminate\Routing\Route:runController in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176
53 Illuminate\Routing\Route:run in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Router.php:680
52 Illuminate\Routing\Router:Illuminate\Routing{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
51 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/barryvdh/laravel-stack-middleware/src/ClosureHttpKernel.php:30
50 Barryvdh\StackMiddleware\ClosureHttpKernel:handle in /mnt/e/xampp/htdocs/room2/project/vendor/helthe/turbolinks/StackTurbolinks.php:51
49 Helthe\Component\Turbolinks\StackTurbolinks:handle in /mnt/e/xampp/htdocs/room2/project/vendor/barryvdh/laravel-stack-middleware/src/ClosureMiddleware.php:36
48 Barryvdh\StackMiddleware\ClosureMiddleware:handle in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
47 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
46 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
45 Illuminate\Routing\Middleware\SubstituteBindings:handle in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
44 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
43 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:43
42 Illuminate\Auth\Middleware\Authenticate:handle in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
41 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
40 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:75
39 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
38 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /mnt/e/xampp/htdocs/room2/project/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53 ......
Car
model? – Jonas StaudenmeirCar
. – gdfgdfglaravel-5.2
tag. – Jonas Staudenmeir5.8.16
– gdfgdfgvendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php
: Is there nosetCreatedAt()
method? – Jonas Staudenmeir