File "StoreWishlistRequest.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Requests/User/StoreWishlistRequest.php
File size: 649 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Http\Requests\User;

use Gate;
use Illuminate\Foundation\Http\FormRequest;

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

    public function rules()
    {
        return [
            'product_id' => [
                'required',
                'integer',
                'unique:wishlists,product_id,NULL,id,user_id,' . auth()->id(),
                'exists:products,id'
            ],
        ];
    }

    public function messages()
    {
        return [
            'product_id.unique' => 'Product already exists in your wishlist.',
        ];
    }
}