简体   繁体   中英

Is there any way to check parameter exist in Laravel previous URL

Want to check the previous URL contains the parameter and want to get the value of the particular paramter from the previous URL like from the current URL we can check.

 if(request()->has('status')){
    //current url 
    }

 example.com/leads/personal?status=custom&userid=512

I don't think it's easy out of the box. I would suggest installing the spatie/url package and then:

use Spatie\Url\Url;

$previousUrl = Url::fromString(url()->previous());

if ($previousUrl->hasQueryParameter('status')) {
    // ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM