<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class RtlMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        $rtl = $request->cookie('rtl') === 'true' ||
            ($request->user() && $request->user()->locale === 'ar');

        view()->share('rtl', $rtl);

        return $next($request);
    }
}
