Begin experimenting with context

This commit is contained in:
Marcus Moore
2025-09-25 15:43:04 -07:00
parent 9e3b56f4bc
commit a40e4d7d04
2 changed files with 10 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ use App\Models\Setting;
use App\View\Label;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Context;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
@@ -631,6 +632,8 @@ class BulkAssetsController extends Controller
*/
public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse | ModelNotFoundException
{
Context::add('action', 'bulk_asset_checkout');
$this->authorize('checkout', Asset::class);
try {

View File

@@ -33,6 +33,7 @@ use App\Notifications\CheckoutConsumableNotification;
use App\Notifications\CheckoutLicenseSeatNotification;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Context;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Exception;
@@ -428,12 +429,17 @@ class CheckoutableListener
private function shouldSendCheckoutEmailToUser(Model $checkoutable): bool
{
/**
* Send an email if any of the following conditions are met:
* Send an email if we didn't get here from a bulk checkout
* and any of the following conditions are met:
* 1. The asset requires acceptance
* 2. The item has a EULA
* 3. The item should send an email at check-in/check-out
*/
if (Context::get('action') === 'bulk_asset_checkout') {
return false;
}
if ($checkoutable->requireAcceptance()) {
return true;
}