|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Storgman - Student Organizations Management |
|
5
|
|
|
* Copyright (C) 2014-2016, Dejan Angelov <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This file is part of Storgman. |
|
8
|
|
|
* |
|
9
|
|
|
* Storgman is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by |
|
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
12
|
|
|
* (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* Storgman is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with Storgman. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
* @package Storgman |
|
23
|
|
|
* @copyright Copyright (C) 2014-2016, Dejan Angelov <[email protected]> |
|
24
|
|
|
* @license https://github.com/angelov/storgman/blob/master/LICENSE |
|
25
|
|
|
* @author Dejan Angelov <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
use Angelov\Storgman\Events\Commands\StoreEventCommand; |
|
29
|
|
|
use Angelov\Storgman\Events\EventImage; |
|
30
|
|
|
use Angelov\Storgman\LocalCommittees\Repositories\LocalCommitteesRepositoryInterface; |
|
31
|
|
|
use Carbon\Carbon; |
|
32
|
|
|
use Illuminate\Database\Seeder; |
|
33
|
|
|
|
|
34
|
|
|
class FakeEventsSeeder extends Seeder |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
protected $faker; |
|
37
|
|
|
protected $localCommittees; |
|
38
|
|
|
|
|
39
|
|
|
public function __construct(\Faker\Factory $fakerFactory, LocalCommitteesRepositoryInterface $localCommittees) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->faker = $fakerFactory->create(); |
|
42
|
|
|
$this->localCommittees = $localCommittees; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function run() |
|
46
|
|
|
{ |
|
47
|
|
|
for ($i=0; $i<5; $i++) { |
|
48
|
|
|
|
|
49
|
|
|
$title = $this->faker->catchPhrase(); |
|
50
|
|
|
$description = $this->faker->realText(); |
|
51
|
|
|
|
|
52
|
|
|
$lcs = $this->localCommittees->all(); |
|
53
|
|
|
$host = $lcs[rand(0, count($lcs)-1)]; |
|
54
|
|
|
|
|
55
|
|
|
$url = $this->faker->url(); |
|
56
|
|
|
|
|
57
|
|
|
$image = $this->faker->image($dir = '/tmp', $width = 640, $height = 480); |
|
58
|
|
|
$image = new EventImage("eventimage.jpg", $image); |
|
59
|
|
|
|
|
60
|
|
|
$startDate = new Carbon($this->faker->dateTimeBetween('now', '+1 month')->format('d-m-Y')); |
|
|
|
|
|
|
61
|
|
|
$endDate = clone $startDate; |
|
62
|
|
|
$endDate->addDays(rand(7, 10)); |
|
63
|
|
|
$deadline = (new Carbon())->addDays(rand(3, 10)); |
|
64
|
|
|
|
|
65
|
|
|
dispatch(new StoreEventCommand($title, $description, $host->getId(), $url, $image, $startDate, $endDate, $deadline)); |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.