You can generate Short URL from URL or Route with/without expiration date.
And this will return an object then you can use this object to get the short url code.
1// Generate from URL 2$shortURL = shortURL()->generate('https://pharaonic.io'); 3 4// Generate from URL with Expiry date (string or Carbon object) 5$shortURL = shortURL()->generate('https://pharaonic.io', '2027-07-07'); 6 7 8// Generate from Route 9$shortURL = shortURL()->generate('route.name.here', ['param' => 1]);10 11// Generate from Route with Expiry date (string or Carbon object)12$shortURL = shortURL()->generate('route.name.here', ['param' => 1], '2027-07-07');13 14 15echo $shortURL->code;
This is how to retrieve the short url in any php file.
1echo shortURL($code)->url; // https://pharaonic.io
And This is how to retrieve the short url in any blade file.
1@shortURL($code) // https://pharaonic.io
Check if the Short URL expired or no (Boolean).
1if(shortURL($code)->expired) {2 //3}