Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im kinda new to laravel and i tried to add body. (as there is 2 elements, Name and Body) to have an update crud, however i dont know how to add body to the string

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class BedrijfUpdateRequest 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()
    {
        $bedrijf = $this->route('bedrijven');
        return [
            'name' => 'string|min:2|max:75|required|unique:bedrijven,name,'.$bedrijf->id
            
        ];
    }
    
}


What I have tried:

i tried

public function rules()
    {
        $bedrijf = $this->route('bedrijven');
        return [
            'name' => 'string|min:2|max:75|required|unique:bedrijven,name,'.$bedrijf->id
        ];
        [
            'body' => 'string|min:2|max:75|required|unique:bedrijven,body,'.$bedrijf->id
        ];
    }
    
}


public function rules()
    {
        $bedrijf = $this->route('bedrijven');
        return [
            'name', 'body' => 'string|min:2|max:75|required|unique:bedrijven,name,body'.$bedrijf->id
        ];
    }
    
}


and even (this one is paticullarly bad)
    public function rules()
    {
        $bedrijf = $this->route('bedrijven');
        return [
            'name' => 'string|min:2|max:75|required|unique:bedrijven,name,'.$bedrijf->id
        ];
    }
    public function rules()
    {
        $bedrijf = $this->route('bedrijven');
        return [
            'body' => 'string|min:2|max:75|required|unique:bedrijven,body,'.$bedrijf->id
        ];
    }
    
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900