In Laravel 8
App\Models\Model::factory()->make();
App\Models\Tweet::factory()->make();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I was working on twitter clone(in laravel from scratch series) on laravel 8, i ran command in tinker i.e App\Models\Tweets::factory()->make();
is says error .i.e:
Symfony\Component\ErrorHandler\Error\FatalError
Cannot declare class Database\Factories\TweetsFactory, because the name is already in use
at C:\wamp64\www\tweety\database\factories\TweetsFactory.php:9 5▕ use App\Models\Tweet; 6▕ use Illuminate\Database\Eloquent\Factories\Factory; 7▕ use Illuminate\Support\Str; 8▕ ➜ 9▕ class TweetFactory extends Factory 10▕ { 11▕ /** 12▕ * The name of the factory's corresponding model. 13▕ *
1 C:\wamp64\www\tweety\vendor\filp\whoops\src\Whoops\Run.php:408 Whoops\Run::handleError("Cannot declare class Database\Factories\TweetFactory, because the name is already in use", "C:\wamp64\www\tweety\database\factories\TweetFactory.php")
2 [internal]:0 Whoops\Run::handleShutdown()
Please or to participate in this conversation.