63315876

Date: 2020-08-08 14:27:59
Score: 5
Natty:
Report link

use this code but not work!!!! this code show error in update page that this value is already exists.

<?php

namespace App\Http\Requests;

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


class PostsRequest 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 [
            'title'  => ['required','max:255', Rule::unique('posts')->ignore($this->route('id'))],
            'slug' => ['required', Rule::unique('posts')->ignore($this->route('id'))],
            'content' => 'required',
            'type' => 'required|in:blog,download,page',
            'status' => 'required',

        ];
    }
}

please help me.

Reasons:
  • Blacklisted phrase (1.5): help me
  • RegEx Blacklisted phrase (3): please help me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Mehdi Jalali