Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mdk999's avatar

PHP Error: Call to undefined method stdClass::save()

I have a model that throws the above error. I created a seeder for this model that doesn't seem to run (other seeders in the folder run). The model is below..

<?php
namespace App;

use Illuminate\Database\Eloquent\Model;

class Perms extends Model
{

    protected $fillable = ['name'];


    public function roles() {
        return $this->belongsToMany(Role::class,'roles_permissions');
     }
}

in tinker I do..

$p = new \App\Perms();
$p->name = 'test';
$p->save();

PHP Error:  Call to undefined method stdClass::save()
0 likes
5 replies
Snapey's avatar

please include your code and put three backticks ``` on a line before and after

Snapey's avatar

did you quit tinker and restart between code changes?

I cant see anything obviously wrong.

is $p an instance of Eloquent model?

mdk999's avatar

Yes it is. Turned out to be an issue with vagrant :|

j_dev's avatar

I'm having this issue and cannot find a solution online.

Please or to participate in this conversation.