fix #64 Discount status update

This commit is contained in:
Jérémy Munsch 2023-05-11 10:46:40 +02:00
parent 95f8e54167
commit ef1c2896fc
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
3 changed files with 9 additions and 3 deletions

View file

@ -137,6 +137,7 @@ class DiscountController extends Controller
// * Minicrud fill
$discount->fill($request->validated());
$discount->makeStatusSense();
$discount->associateProducts($request->prods);
if ($discount->saveOrFail()) {

View file

@ -214,6 +214,9 @@ class ProductController extends Controller
\json_decode(\json_encode($product->toArray()), true),
$request->validated()
));
$product->makeStatusSense();
$product->makeStarSense();
$product->makeOrderableSense();
$product->tags()->sync($request->tag_list);
$product->associatedProducts()->sync($request->product_list);
@ -262,6 +265,7 @@ class ProductController extends Controller
Gate::allowIf(request()->isMethod('post'));
$this->authorize('associateToInco', $product);
$product->makeStatusSense();
$product->xmlInco()->associate($xml_inco);
$product->saveOrFail();
return redirect()->route('bo.products.edit', $product)

View file

@ -19,6 +19,7 @@ use Kwaadpepper\Enum\Traits\CastsEnums;
* @property integer $discount_value Discount value in percent or cents.
* @property-read integer|float $discount_calculation The discount value
* ready to be used for calculations.
* @property-read integer|float $planificated_status The planificated Status.
*/
class Discount extends Model
{
@ -76,9 +77,6 @@ class Discount extends Model
static::created(function (self $model) {
$model->flashMessages();
});
static::updated(function (self $model) {
$model->flashMessages();
});
static::updating(function (self $model) {
// * ASSERTIONS
self::assertIsAboveZero(
@ -89,6 +87,9 @@ class Discount extends Model
// * TRANSFORMATIONS
$model->makeStatusSense();
});
static::updated(function (self $model) {
$model->flashMessages();
});
}
// * RELATIONSHIPS