Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

realodix/urlhub

532 stars
1 code files
View realodix/urlhub on GitHub

app/Http/Requests/StoreUrl.php

Open in GitHub
use App\Rules\StrAlphaUnderscore;
use App\Rules\URL\DomainBlacklist;
use Illuminate\Foundation\Http\FormRequest;
 
class StoreUrl extends FormRequest
{
public function authorize()
{
return true;
}
 
public function rules()
{
return [
'long_url' => ['required', 'url', 'max:65535', new DomainBlacklist],
'custom_key' => ['nullable', 'max:20', new StrAlphaUnderscore, 'unique:urls,keyword'],
];
}
 
public function messages()
{
return [
'long_url.required' => __('Must be filled, should not be empty.'),
'long_url.url' => __('Incorrect link format. The link must begin "http://" or "https://".'),
'custom_key.max' => __('The custom url may not be greater than :max characters.'),
'custom_key.unique' => __(':input has already been taken'),
];
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.