小编som*_*ath的帖子

Laravel 5.4表单请求唯一验证:如何访问ID?

我收到此表单请求如下:

<?php

namespace App\Http\Requests;

use App\Sociallink;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class SociallinkRequest 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 [
          'seq' => 'required|unique:sociallinks,seq,' . $this->id . ',id',
          'social_name' => 'required|unique:sociallinks,social_name,' . $this->id . ',id',
          'cssclass' => 'required',
          'url' => …
Run Code Online (Sandbox Code Playgroud)

validation unique request laravel laravel-5

4
推荐指数
1
解决办法
499
查看次数

标签 统计

laravel ×1

laravel-5 ×1

request ×1

unique ×1

validation ×1