Merge branch 'ticket1149' into 'develop'
Fix question crud + Fix max questions request 3 months See merge request service-web-lab/crm!2
This commit is contained in:
commit
f7f4b4271a
6 changed files with 50 additions and 13 deletions
|
|
@ -18,7 +18,7 @@ class GetBrandStatsRequest extends BaseApiRequest
|
|||
public function rules(): array
|
||||
{
|
||||
try {
|
||||
if (Carbon::parse($this->end)->diffInMonths(Carbon::parse($this->start)->addDay()) >= 3) {
|
||||
if (Carbon::parse($this->end)->diffInMonths(Carbon::parse($this->start)) >= 3) {
|
||||
throw ValidationException::withMessages([
|
||||
'Vous devez sélectionner une période de maximum 3 mois'
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class GetQuestionStatsRequest extends BaseApiRequest
|
|||
public function rules(): array
|
||||
{
|
||||
try {
|
||||
if (Carbon::parse($this->end)->diffInMonths(Carbon::parse($this->start)->addDay()) >= 3) {
|
||||
if (Carbon::parse($this->end)->diffInMonths(Carbon::parse($this->start)) >= 3) {
|
||||
throw ValidationException::withMessages([
|
||||
'Vous devez sélectionner une période de maximum 3 mois'
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class Question extends Model
|
|||
*/
|
||||
protected $fillable = [
|
||||
'question',
|
||||
'type'
|
||||
'type',
|
||||
'brand_id'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -77,6 +78,7 @@ class Question extends Model
|
|||
'brand_id' => [
|
||||
'label' => Str::ucfirst(trans('models.classes.brand')),
|
||||
'type' => CrudType::belongsTo(),
|
||||
'readonly' => true,
|
||||
'belongsTo' => Brand::class,
|
||||
'actions' => [
|
||||
CrudAction::viewAny(),
|
||||
|
|
@ -94,7 +96,6 @@ class Question extends Model
|
|||
'actions' => [
|
||||
CrudAction::viewAny(),
|
||||
CrudAction::view(),
|
||||
CrudAction::create(),
|
||||
CrudAction::update(),
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"kwaadpepper/crud-policies": "^0.3.5",
|
||||
"kwaadpepper/crud-policies": "^5.0",
|
||||
"kwaadpepper/enum": "^2.1",
|
||||
"kwaadpepper/exception-handler": "^0.0.6",
|
||||
"laravel-lang/lang": "~7.0",
|
||||
|
|
|
|||
16
composer.lock
generated
16
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "754ae14d2b3a505a0f58f377d93fc1b9",
|
||||
"content-hash": "26e67a9e2292d81339b64ea6fd14f70e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "arondeparon/laravel-request-sanitizer",
|
||||
|
|
@ -1710,16 +1710,16 @@
|
|||
},
|
||||
{
|
||||
"name": "kwaadpepper/crud-policies",
|
||||
"version": "0.3.6",
|
||||
"version": "5.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Kwaadpepper/crud-policies.git",
|
||||
"reference": "205b8a16c99c362fc78422eeb31c0ba618a3d351"
|
||||
"reference": "ba3fef154bc5ce7ffe199fa7f2b692a5a410de52"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/205b8a16c99c362fc78422eeb31c0ba618a3d351",
|
||||
"reference": "205b8a16c99c362fc78422eeb31c0ba618a3d351",
|
||||
"url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/ba3fef154bc5ce7ffe199fa7f2b692a5a410de52",
|
||||
"reference": "ba3fef154bc5ce7ffe199fa7f2b692a5a410de52",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1770,9 +1770,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Kwaadpepper/crud-policies/issues",
|
||||
"source": "https://github.com/Kwaadpepper/crud-policies/tree/0.3.6"
|
||||
"source": "https://github.com/Kwaadpepper/crud-policies/tree/5.0.2"
|
||||
},
|
||||
"time": "2022-05-04T13:19:25+00:00"
|
||||
"time": "2022-11-03T16:04:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "kwaadpepper/enum",
|
||||
|
|
@ -9179,5 +9179,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "7.3.26"
|
||||
},
|
||||
"plugin-api-version": "2.2.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CascadeDeleteQuestionAnswers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// * Add cascade delete
|
||||
Schema::table('answers', function (Blueprint $table) {
|
||||
$table->dropForeign(['question_id']);
|
||||
$table->foreign('question_id')->references('id')->on('questions')->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// * Undo cascade delete (restrict as default)
|
||||
Schema::table('answers', function (Blueprint $table) {
|
||||
$table->dropForeign(['question_id']);
|
||||
$table->foreign('question_id')->references('id')->on('questions');
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue