Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Guard raised against custom insert without factory in database seeder #2016

Open
wolfiton opened this issue Jun 21, 2020 · 0 comments
Open

Comments

@wolfiton
Copy link

Summary

Guard raised gainst custom insert without factory

Versions

Laravel 7

Version
PHP x.y.z
fzaninotto/faker x.y.z

Self-enclosed code snippet for reproduction

$categories = ['Hardware', 'Software', 'Planning', 'Tools'];
        foreach ($categories as $category) {
            App\Category::create([
                'name' => $category,
                'slug' => Str::slug($category),
            ]);
        }

Expected output

Inserting the category name and slug

Actual output

 Unable to locate factory for [App\Category].

  at vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:273
    269|      */
    270|     protected function getRawAttributes(array $attributes = [])
    271|     {
    272|         if (! isset($this->definitions[$this->class])) {
  > 273|             throw new InvalidArgumentException("Unable to locate factory for [{$this->class}].");
    274|         }
    275| 
    276|         $definition = call_user_func(
    277|             $this->definitions[$this->class],
@wolfiton wolfiton changed the title Guard raised gainst custom insert without factory in databse seeder Guard raised against custom insert without factory in database seeder Jun 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant