FundCommand.php
5 years ago
FundFactory.php
5 years ago
FundRepository.php
5 years ago
ServiceProvider.php
5 years ago
FundFactory.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\TestData\Addons\Funds; |
| 4 | |
| 5 | use Give\TestData\Framework\Factory; |
| 6 | |
| 7 | /** |
| 8 | * Class FundFactory |
| 9 | * @package Give\TestData\Funds |
| 10 | */ |
| 11 | class FundFactory extends Factory { |
| 12 | |
| 13 | /** |
| 14 | * @return int |
| 15 | */ |
| 16 | public function getRandomFund() { |
| 17 | global $wpdb; |
| 18 | $fundIds = $wpdb->get_col( "SELECT id FROM {$wpdb->prefix}give_funds" ); |
| 19 | |
| 20 | return $this->faker->randomElement( $fundIds ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @return array |
| 25 | */ |
| 26 | public function definition() { |
| 27 | return [ |
| 28 | 'title' => $this->faker->catchPhrase(), |
| 29 | 'description' => $this->faker->sentence( 6, true ), |
| 30 | 'is_default' => 0, |
| 31 | 'author_id' => $this->randomAuthor(), |
| 32 | 'date_created' => $this->faker->dateTimeThisYear()->format( 'Y-m-d H:i:s' ), |
| 33 | 'date_modified' => $this->faker->dateTimeThisYear()->format( 'Y-m-d H:i:s' ), |
| 34 | ]; |
| 35 | } |
| 36 | } |
| 37 |