# give/4.15.5/src/EventTickets/Factories/EventTicketFactory.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.15.5. 34 lines.

- Page: https://pluginprobe.com/plugins/give/4.15.5/code/src/EventTickets/Factories/EventTicketFactory.php
- Raw: https://pluginprobe.com/plugins/give/4.15.5/raw/src/EventTickets/Factories/EventTicketFactory.php
- Modified: 2025-02-03T15:13:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.15.5/code/src/EventTickets/Factories/EventTicketFactory.php#L10-L20`.

```php
<?php

namespace Give\EventTickets\Factories;

use DateTime;
use Exception;
use Give\Donations\Models\Donation;
use Give\EventTickets\Models\Event;
use Give\EventTickets\Models\EventTicketType;
use Give\Framework\Models\Factories\ModelFactory;

class EventTicketFactory extends ModelFactory
{
    /**
     * @since 3.20.0 Add amount to the properties array using the price from the ticket type
     * @since 3.6.0
     *
     * @throws Exception
     */
    public function definition(): array
    {
        $ticketType = EventTicketType::factory()->create();

        return [
            'eventId' => Event::factory()->create()->id,
            'ticketTypeId' => $ticketType->id,
            'donationId' => Donation::factory()->create()->id,
            'amount' => $ticketType->price,
            'createdAt' => new DateTime(),
            'updatedAt' => new DateTime(),
        ];
    }
}

```
