required_if Laravel 5 validation

assuming that list_type is the name of the select box to choose from (values : selling or rent)

use it this way

"sale_price" => "required_if:list_type,==,selling"

what does this mean?
:

the sale price is only required if the value of list_type is equal to selling

do the same for rent_price

edit

public function rules()
{
  return [
   'list_type'  => 'required',
   'sale_price' => 'required_if:list_type,==,For Sale',
   'rent_price' => 'required_if:list_type,==,For Rent'
}

Leave a Comment