Rework on product name/description and translate
This commit is contained in:
@@ -84,7 +84,7 @@ class ProductController extends Controller
|
||||
|
||||
public function details_addedit(ProductAddEdit $request,Product $o)
|
||||
{
|
||||
foreach ($request->except(['_token','submit','description']) as $key => $item)
|
||||
foreach ($request->except(['_token','submit','translate']) as $key => $item)
|
||||
$o->{$key} = $item;
|
||||
|
||||
$o->active = (bool)$request->active;
|
||||
@@ -95,13 +95,12 @@ class ProductController extends Controller
|
||||
return redirect()->back()->withErrors($e->getMessage())->withInput();
|
||||
}
|
||||
|
||||
$o->load(['description']);
|
||||
$oo = $o->description ?: new ProductTranslate;
|
||||
|
||||
foreach ($request->get('description',[]) as $key => $item)
|
||||
$o->load(['translate']);
|
||||
$oo = $o->translate ?: new ProductTranslate;
|
||||
foreach ($request->get('translate',[]) as $key => $item)
|
||||
$oo->{$key} = $item;
|
||||
|
||||
$o->description()->save($oo);
|
||||
$o->translate()->save($oo);
|
||||
|
||||
return redirect()->back()
|
||||
->with('success','Product saved');
|
||||
|
@@ -28,7 +28,9 @@ class ProductAddEdit extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'description.name' => 'required|string|min:2|max:100',
|
||||
'translate.name_short' => 'required|string|min:2|max:100',
|
||||
'translate.name_detail' => 'required|string|min:2|max:100',
|
||||
'translate.description' => 'required|string|min:2|max:255',
|
||||
'active' => 'sometimes|accepted',
|
||||
'model' => 'sometimes|string', // @todo Check that it is a valid model type
|
||||
'model_id' => 'sometimes|int', // @todo Check that it is a valid model type
|
||||
|
Reference in New Issue
Block a user