### Install Requests for Laravel via Composer Source: https://github.com/roundly-consulting/requests-for-laravel/blob/main/README.md Run these commands to install the package and publish its migrations. Requires PHP 8.4 and Laravel 12 or 13. Set REQUESTS_KEY_TYPE and APPROVALS_KEY_TYPE before migrating if your models use UUID/ULID keys. ```bash composer require roundly-consulting/requests-for-laravel php artisan vendor:publish --tag="requests-migrations" php artisan vendor:publish --tag="approvals-migrations" php artisan migrate ``` -------------------------------- ### Create a request with named approvers Source: https://github.com/roundly-consulting/requests-for-laravel/blob/main/README.md Use the Requests facade to create a request with an author, type, title, required approvers, and expiration. Only the named approvers or their delegates may decide. ```php use RoundlyConsulting\Requests\Facades\Requests; $request = Requests::make() ->author($user) ->type('Claim') ->title('Expense reimbursement') ->requireApprovalsFrom([$alice, $bob]) // only they, or their delegates, may decide ->expiresAt(now()->addDays(7)) ->create(); ``` -------------------------------- ### Use HasRequests and GivesApprovals traits on User model Source: https://github.com/roundly-consulting/requests-for-laravel/blob/main/README.md Apply the HasRequests and GivesApprovals traits to models that author and approve requests. The model must implement GivesApprovalsInterface and HasRequestsContract. ```php use Illuminate\Database\Eloquent\Model; use RoundlyConsulting\Approvals\Interfaces\GivesApprovalsInterface; use RoundlyConsulting\Approvals\Traits\GivesApprovals; use RoundlyConsulting\Requests\Concerns\HasRequests; use RoundlyConsulting\Requests\Contracts\HasRequests as HasRequestsContract; class User extends Model implements GivesApprovalsInterface, HasRequestsContract { use GivesApprovals; use HasRequests; } ``` -------------------------------- ### Approve a request and check status Source: https://github.com/roundly-consulting/requests-for-laravel/blob/main/README.md Approve a request by named approvers. By default every approver must approve. After all approvals, the status becomes Approved and the author's approved requests can be retrieved. ```php Requests::approve($request, $alice); // 1 of 2 — still New Requests::approve($request, $bob, reason: 'Looks good'); // 2 of 2 — Approved $request->status; // Status::Approved $user->approvedRequests()->get(); // the author's approved requests ```