|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Database\Factories; |
|
4
|
|
|
|
|
5
|
|
|
use App\Helpers\Helper; |
|
6
|
|
|
use App\Models\Insight; |
|
7
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory; |
|
8
|
|
|
|
|
9
|
|
|
class InsightFactory extends Factory |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* The name of the factory's corresponding model. |
|
13
|
|
|
* |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $model = Insight::class; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Define the model's default state. |
|
20
|
|
|
* |
|
21
|
|
|
* @return array |
|
22
|
|
|
*/ |
|
23
|
|
|
public function definition() |
|
24
|
|
|
{ |
|
25
|
|
|
// Facebook data |
|
26
|
|
|
$publishedOnFacebookOn = $facebookUrl = $facebookBody = null; |
|
27
|
|
|
if ($this->faker->boolean(50)) { |
|
28
|
|
|
$timestamp_published_on_facebook_on = rand(1444395410, 1602248210); |
|
29
|
|
|
$publishedOnFacebookOn = date("Y-m-d H:i:s", $timestamp_published_on_facebook_on); |
|
30
|
|
|
$facebookUrl = $this->faker->url(); |
|
31
|
|
|
$facebookBody = $this->faker->paragraph($nbSentences = 2, $variableNbSentences = true); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// Twitter data |
|
35
|
|
|
$publishedOnTwitterOn = $twitterUrl = $twitterBody = null; |
|
36
|
|
|
if ($this->faker->boolean(50)) { |
|
37
|
|
|
$timestamp_published_on_twitter_on = rand(1444395410, 1602248210); |
|
38
|
|
|
$publishedOnTwitterOn = date("Y-m-d H:i:s", $timestamp_published_on_twitter_on); |
|
39
|
|
|
$twitterUrl = $this->faker->url(); |
|
40
|
|
|
$twitterBody = $this->faker->paragraph($nbSentences = 2, $variableNbSentences = true); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
// Instagram data |
|
44
|
|
|
$publishedOnInstagramOn = $instagramUrl = $instagramBody = null; |
|
45
|
|
|
if ($this->faker->boolean(50)) { |
|
46
|
|
|
$timestamp_published_on_instagram_on = rand(1444395410, 1602248210); |
|
47
|
|
|
$publishedOnInstagramOn = date("Y-m-d H:i:s", $timestamp_published_on_instagram_on); |
|
48
|
|
|
$instagramUrl = $this->faker->url(); |
|
49
|
|
|
$instagramBody = $this->faker->paragraph($nbSentences = 2, $variableNbSentences = true); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return [ |
|
53
|
|
|
'title' => $this->faker->sentence($nbWords = 7, $variableNbWords = true), |
|
54
|
|
|
'body' => $this->faker->paragraph($nbSentences = 2, $variableNbSentences = true), |
|
55
|
|
|
'introimage' => 'placeholders/placeholder-768x768.png', |
|
56
|
|
|
'introimage_alt' => $this->faker->sentence($nbWords = 2, $variableNbWords = true), |
|
57
|
|
|
|
|
58
|
|
|
'is_published' => $this->faker->boolean(50), |
|
59
|
|
|
|
|
60
|
|
|
'facebook_body' => $facebookBody, |
|
61
|
|
|
'facebook_url' => $facebookUrl, |
|
62
|
|
|
'published_on_facebook_on' => $publishedOnFacebookOn, |
|
63
|
|
|
|
|
64
|
|
|
'twitter_body' => $twitterBody, |
|
65
|
|
|
'twitter_url' => $twitterUrl, |
|
66
|
|
|
'published_on_twitter_on' => $publishedOnTwitterOn, |
|
67
|
|
|
|
|
68
|
|
|
'instagram_body' => $instagramBody, |
|
69
|
|
|
'instagram_url' => $instagramUrl, |
|
70
|
|
|
'published_on_instagram_on' => $publishedOnInstagramOn, |
|
71
|
|
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|