Call to a member function getRelationExistenceQuery() on null #33426
              
                Unanswered
              
          
                  
                    
                      Begginer666
                    
                  
                
                  asked this question in
                General
              
            Replies: 2 comments 2 replies
-
| Your  | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            -
| In the  | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
the error appears when i try to run the seeds.
this is the error:
at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php:49
45| $method = $this->canUseExistsForExistenceCheck($operator, $count)
46| ? 'getRelationExistenceQuery'
47| : 'getRelationExistenceCountQuery';
48|
4 database/factories/UserFactory.php:59
Illuminate\Database\Eloquent\Model::__callStatic()
11 [internal]:0
Illuminate\Database\Eloquent\FactoryBuilder::Illuminate\Database\Eloquent{closure}()
this is the factory:
use App\User;
use App\Category;
use App\Product;
use App\Transaction;
use App\Seller;
use Faker\Generator as Faker;
use Illuminate\Support\Str;
$factory->define(User::class, function (Faker $faker) {
static $password;
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => Str::random(10),
'verified' => $verificado = $faker->randomElement([User::USUARIO_VERIFICADO, User::USUARIO_NO_VERIFICADO]),
'verification_token'=> $verificado == User::USUARIO_VERIFICADO ? null : User::generarVerificationToken(),
'admin' => $faker->randomElement([User::USUARIO_ADMINISTRADOR, User::USUARIO_REGULAR]),
];
});
$factory->define(Category::class, function (Faker $faker) {
return [
'name' => $faker->word,
'description'=> $faker->paragraph(1),
];
});
$factory->define(Product::class, function (Faker $faker) {
return [
'name' => $faker->name,
'description'=> $faker->paragraph(1),
'quantity'=> $faker->numberBetween(1, 10),
'status'=> $faker->randomElement([Product::PRODUCTO_DISPONIBLE, Product::PRODUCTO_NO_DISPONIBLE]),
'image'=> $faker->randomElement(['1.jgp', '2.jgp', '3.jgp']),
'seller_id'=> User::all()->random()->id,
];
});
$factory->define(Transaction::class, function (Faker $faker) {
});
this is the seed:
use Illuminate\Database\Seeder;
use App\User;
use App\Category;
use App\Product;
use App\Transaction;
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
User::truncate();
Product::truncate();
Category::truncate();
Transaction::truncate();
DB::table('category_product')->truncate();
Beta Was this translation helpful? Give feedback.
All reactions