Skip to main content

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

Read more here

beromir/Servas

739 stars
1 code files
View beromir/Servas on GitHub

app/Http/Requests/StoreLinkApiRequest.php

Open in GitHub
class StoreLinkApiRequest extends FormRequest
{
public function authorize(): bool
{
return Request::user()->tokenCan('create');
}
 
protected function prepareForValidation(): void
{
$this->merge([
'link' => filter_var($this->link, FILTER_VALIDATE_URL) ? $this->link : "https://$this->link",
]);
}
 
public function rules(): array
{
return Link::rules($this->request->get('link'));
}
 
public function failedValidation(Validator $validator)
{
throw new HttpResponseException(response()->json([
'success' => false,
'message' => 'Validation errors',
'data' => $validator->errors()
], 422));
}
}

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.