Example of Form requests in Loydtafireyi/ZimCart-Laravel-Ecommerce

File app/Http/Requests/SubCategory/CreateSubCategoryRequest.php (link to Github)
use Illuminate\Foundation\Http\FormRequest;

class CreateSubCategoryRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        $id = $this->route('id');

        return [
            'name' => 'required:sub_categories,name,' .$id,
            'category_id' => 'required',
            'slug' => 'unique:sub_categories,slug,'.$id,
        ];
    }
}

Additional resources on Form requests: