1 year ago

Create method saving null values

Posted 1 year ago by bcharron

I have a save method in a repository in an application that I am working on. The method looks like this:

public function save($data)

            'title' => $data['title'],
            'min_length' => $data['min_length'],
            'max_length' => $data['max_length'],
            'prefix' => $data['prefix'],
            'one_way' => $data['one_way']


When I call this method, it returns the saved model, but all of the values in it are empty. I have confirmed that the values are present in $data by dd'ing them. I have the $fillable property set on the model, but still I am getting null values:

protected $fillable = [



I have changed this to use the save() method instead of create() and it works. Can anyone explain why the create method does not save the values?

Please sign in or create an account to participate in this conversation.