<?php

namespace App\Http\Controllers\Concerns;

use App\Models\Admin;
use App\Models\Merchant;
use Illuminate\Http\Request;

trait ResolvesMerchantContext
{
    protected function merchantId(Request $request): int
    {
        return (int) $request->session()->get('admin_merchant_id');
    }

    protected function merchant(Request $request): Merchant
    {
        return Merchant::query()->findOrFail($this->merchantId($request));
    }

    protected function merchantAdmin(Request $request): Admin
    {
        return Admin::query()->findOrFail((int) $request->session()->get('admin_id'));
    }
}
