1
0
Fork 0
pixelfed/app/Console/Commands/SeedFollows.php

62 lines
1.3 KiB
PHP
Raw Normal View History

2018-05-30 03:01:28 +00:00
<?php
namespace App\Console\Commands;
2018-08-28 03:07:36 +00:00
use App\Follower;
2018-05-30 03:01:28 +00:00
use App\Jobs\FollowPipeline\FollowPipeline;
2018-08-28 03:07:36 +00:00
use App\Profile;
use Illuminate\Console\Command;
2018-05-30 03:01:28 +00:00
class SeedFollows extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'seed:follows';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed follows for testing';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$limit = 10000;
2018-08-28 03:07:36 +00:00
for ($i = 0; $i < $limit; $i++) {
2018-05-30 03:01:28 +00:00
try {
2018-06-01 11:23:52 +00:00
$actor = Profile::inRandomOrder()->firstOrFail();
$target = Profile::inRandomOrder()->firstOrFail();
2018-05-30 03:01:28 +00:00
2018-08-28 03:07:36 +00:00
$follow = new Follower();
2018-05-30 03:01:28 +00:00
$follow->profile_id = $actor->id;
$follow->following_id = $target->id;
$follow->save();
FollowPipeline::dispatch($follow);
} catch (Exception $e) {
continue;
}
}
}
}