2018-08-23 00:25:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2018-08-23 10:39:29 +02:00
|
|
|
use Illuminate\Validation\Rule;
|
2018-08-23 00:25:29 +02:00
|
|
|
|
|
|
|
class LinkStoreRequest extends FormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
2018-08-23 10:39:29 +02:00
|
|
|
'url' => [
|
|
|
|
'required',
|
|
|
|
Rule::unique('links')->where(function ($query) {
|
|
|
|
return $query->where('user_id', auth()->user()->id);
|
|
|
|
}),
|
|
|
|
],
|
2018-08-23 00:25:29 +02:00
|
|
|
'is_private' => 'required|boolean',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|