L'ajout des étapes de recette fonctionne.
Reste à faire : - suppression d'étape - déplacement d'étape
This commit is contained in:
@@ -7,6 +7,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Propel;
|
||||
use Recettes\Form\RecetteCreateForm;
|
||||
use Recettes\Form\StepCreateForm;
|
||||
use Recettes\Model\Recipe;
|
||||
use Recettes\Model\RecipeProducts;
|
||||
use Recettes\Model\RecipeProductsQuery;
|
||||
@@ -181,4 +182,36 @@ class BackController extends BaseAdminController
|
||||
return $this->render('includes/related-products', [ 'content_id' => $contentId ]);
|
||||
}
|
||||
|
||||
|
||||
public function addStep(Request $request)
|
||||
{
|
||||
$form = new StepCreateForm($request);
|
||||
$errorUrl = "";
|
||||
try {
|
||||
$formValidate = $this->validateForm($form);
|
||||
$data = $formValidate->getData();
|
||||
|
||||
$recipeId = $data['recipe_id'];
|
||||
$step = $data['step'];
|
||||
$description = $data['description'];
|
||||
$errorUrl = $data['error_url'];
|
||||
$successUrl = $data['success_url'];
|
||||
if ($recipeId && $step && $description) {
|
||||
(new RecipeSteps())
|
||||
->setRecipeId($recipeId)
|
||||
->setStep($step)
|
||||
->setDescription($description)
|
||||
->save();
|
||||
|
||||
return new RedirectResponse(URL::getInstance()->absoluteUrl($successUrl));
|
||||
}
|
||||
else
|
||||
return new RedirectResponse(URL::getInstance()->absoluteUrl($errorUrl));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user