AsgardCms/Menu

View on GitHub
Http/Requests/UpdateMenuRequest.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php namespace Modules\Menu\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateMenuRequest extends FormRequest
{
    public function rules()
    {
        $menu = $this->route()->getParameter('menu');

        return [
            'name' => 'required',
            'primary' => "unique:menu__menus,primary,{$menu->id}",
        ];
    }

    public function authorize()
    {
        return true;
    }

    public function messages()
    {
        return [
            'name.required' => trans('menu::validation.name is required'),
            'primary.unique' => trans('menu::validation.only one primary menu'),
        ];
    }
}