*/ public function definition(): array { // Get a random model for polymorphic relationship $transferableModels = [ \App\Models\Package::class, \App\Models\Item::class, ]; $transferableType = $this->faker->randomElement($transferableModels); $transferable = $transferableType::factory()->create(); // Generate from_date and ensure to_date is after from_date $fromDate = $this->faker->dateTimeBetween('-1 year', 'now'); $toDate = $this->faker->dateTimeBetween($fromDate, '+1 year'); return [ 'transferable_type' => $transferableType, 'transferable_id' => $transferable->id, 'user_id' => User::factory(), 'from_date' => $fromDate, 'to_date' => $toDate, 'status' => $this->faker->randomElement(['approved', 'rejected', 'suspended']), 'user_transfer_id' => User::factory(), 'deleted_at' => null, ]; } /** * Indicate that the transfer is approved. */ public function approved(): static { return $this->state(fn (array $attributes) => [ 'status' => 'approved', ]); } /** * Indicate that the transfer is rejected. */ public function rejected(): static { return $this->state(fn (array $attributes) => [ 'status' => 'rejected', ]); } /** * Indicate that the transfer is suspended. */ public function suspended(): static { return $this->state(fn (array $attributes) => [ 'status' => 'suspended', ]); } /** * Indicate that the transfer is soft deleted. */ public function deleted(): static { return $this->state(fn (array $attributes) => [ 'deleted_at' => now(), ]); } }