Add CheckoutAcceptance factory

This commit is contained in:
Marcus Moore 2023-05-03 14:21:13 -07:00
parent 914b2658cc
commit f96d8fe674
No known key found for this signature in database
2 changed files with 43 additions and 1 deletions

View file

@ -3,13 +3,14 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
class CheckoutAcceptance extends Model class CheckoutAcceptance extends Model
{ {
use SoftDeletes, Notifiable; use HasFactory, SoftDeletes, Notifiable;
protected $casts = [ protected $casts = [
'accepted_at' => 'datetime', 'accepted_at' => 'datetime',

View file

@ -0,0 +1,41 @@
<?php
namespace Database\Factories;
use App\Models\Accessory;
use App\Models\Asset;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class CheckoutAcceptanceFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'checkoutable_type' => Asset::class,
'checkoutable_id' => Asset::factory(),
'assigned_to_id' => User::factory(),
];
}
public function forAccessory()
{
return $this->state([
'checkoutable_type' => Accessory::class,
'checkoutable_id' => Accessory::factory(),
]);
}
public function pending()
{
return $this->state([
'accepted_at' => null,
'declined_at' => null,
]);
}
}