@MohamedTammam
hello dear tammam, thank you for your respons. im glad you're respond my thread.
before i explain my problem, this is my codes
Form Request :
<?php
namespace App\Http\Requests\Product;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProductRequest 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()
{
return [
'product_name_en' => 'required',
'product_name_id' => 'required',
'product_code' => 'required',
'product_quantity' => 'required|numeric',
'product_price' => 'required|numeric',
'product_discount_name' => 'nullable',
'product_discount_type' => 'required_with:product_discount_name|nullable',
'demo1' => 'required_with:product_discount_name|nullable',
'product_discount_time' => 'required_with:product_discount_name|nullable',
'product_discount_start_date' => 'required_with:product_discount_name|nullable|date',
'product_discount_end_date' => 'required_with:product_discount_name|nullable|date',
'product_tags_en' => 'required',
'product_tags_id' => 'required',
'product_size_en' => 'nullable',
'product_size_id' => 'nullable',
'product_color_en' => 'nullable',
'product_color_id' => 'nullable',
'product_short_description_en' => 'required',
'product_short_description_id' => 'required',
'product_long_description_en' => 'required',
'product_long_description_id' => 'required',
'hot_deal' => 'nullable',
'featured' => 'nullable',
'special_offer' => 'nullable',
'special_deal' => 'nullable',
'category_id' => 'required',
'subcategory_id' => 'required',
'subsub_category_id' => 'required',
'brand_id' => 'required',
];
}
public function messages()
{
return [
// Required Discount Without Besides Discount Product Name
'product_discount_name.required_without' => 'Product discount type, percentage, time, start date and end date fields are required when product discount name is filled.',
// Required Discount With Discount Product Name
'product_discount_type.required_with' => 'Product discount type field is required when product discount name is filled.',
'demo1.required_with' => 'Product discount percentage field is required when product discount name is filled.',
'product_discount_time.required_with' => 'Product discount time field is required when product discount name is filled.',
'product_discount_start_date.required_with' => 'Product discount start date field is required when product discount name is filled.',
'product_discount_end_date.required_with' => 'Product discount end date field is required when product discount name is filled.',
];
}
}
Method Update
public function manageUpdateProduct(UpdateProductRequest $request, $id)
{
$validated = $request->validated();
$validated['product_slug_en'] = Str::slug($validated['product_name_en']);
$validated['product_slug_id'] = Str::slug($validated['product_name_id']);
Product::where('id', $id)->update($validated);
$notification = array(
'message' => 'Product Updated Successfully',
'alert-type' => 'success'
);
return redirect()->route('manage.product')->with($notification);
}
So in my case, i want to insert data table to field "product_discount_percentage" with Form Request but there's a problem which is the name's of input request for "product_discount_percentage" is a "demo1". i can't change it that name, because i need it for running the scripts from library. So i must using name "demo1" for insert data to table field "product_discount_percentage". So how can i fix this, without change the name of input request. So it's like i want to overriding the input request "demo1" to be "product_discount_percentage". Can I do that?...
Thank You @mohamedtammam , I hope you understand about what im saying. and sorry if My English's Bad.