-
-
Save dansup/614df44762cfd7d258408b274ce3cb0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Faker\Generator as Faker; | |
use App\Util\Lexer\{AutoLink,Extractor}; | |
/* | |
|-------------------------------------------------------------------------- | |
| Model Factories | |
|-------------------------------------------------------------------------- | |
| | |
| This directory should contain each of the model factory definitions for | |
| your application. Factories provide a convenient way to generate new | |
| model instances for testing / seeding your application's database. | |
| | |
*/ | |
$factory->define(App\Status::class, function (Faker $faker) { | |
$count = App\User::count(); | |
$uid = mt_rand(1,$count); | |
$mention = mt_rand(0,1) === 1 ? '@'.App\User::orderByRaw('rand()')->first()->username.' ' : ''; | |
$hashtags = ' #test #factoryGenerated'; | |
$tweet_raw = $mention . $faker->text(140) . $hashtags; | |
$tweet_rendered = AutoLink::create()->autoLink($tweet_raw); | |
$entities = json_encode(Extractor::create()->extract($tweet_raw)); | |
return [ | |
'user_id' => $uid, | |
'content' => $tweet_raw, | |
'rendered' => $tweet_rendered, | |
'reply_id' => null, | |
'scope' => 0, | |
'source' => 'web', | |
'verb' => 'post', | |
'object_type' => 'note', | |
'entities' => $entities, | |
]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment