- schema for cart and product - define relationship, DTO, Resource and API collections - Add post and get endpoint for cart api
18 lines
305 B
PHP
18 lines
305 B
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Data\CartDTO;
|
|
use App\Models\User;
|
|
|
|
final readonly class GetActiveUserCartAction
|
|
{
|
|
/**
|
|
* Execute the action.
|
|
*/
|
|
public function execute(User $user)
|
|
{
|
|
return CartDTO::fromModel($user->carts()->active()->withProducts()->first());
|
|
}
|
|
}
|