From 9847303cfbb7d408afaf22cdcbe001a231e84f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Tue, 10 Aug 2021 12:09:49 +0200 Subject: [PATCH] phpcs rmove unused imports --- app/Enums/QuestionType.php | 25 +++++++++++ .../Controllers/Api/V2/AnswerController.php | 10 +++++ .../Controllers/Api/V2/ArcadiaController.php | 2 - .../Controllers/Api/V2/QuestionController.php | 10 +++++ app/Http/Controllers/BrandController.php | 1 - app/Http/Middleware/ApiResponse.php | 1 - app/Http/Middleware/Authenticate.php | 3 -- app/Http/Middleware/CheckBrand.php | 4 -- app/Http/Resources/Api/V2/ApiResponse.php | 3 -- .../Resources/Api/V2/CustomerResource.php | 2 - app/Models/Answer.php | 35 +++++++++++++++ app/Models/Customer.php | 1 - app/Models/CustomerAnswer.php | 10 +++++ app/Models/Question.php | 43 +++++++++++++++++++ app/Models/User.php | 1 - app/Providers/AuthServiceProvider.php | 1 - app/Providers/EventServiceProvider.php | 1 - app/Providers/RouteServiceProvider.php | 1 - database/factories/AnswerFactory.php | 31 +++++++++++++ database/factories/CustomerLoginFactory.php | 1 - database/factories/QuestionFactory.php | 31 +++++++++++++ ...21_08_10_103745_create_questions_table.php | 34 +++++++++++++++ ...2021_08_10_103757_create_answers_table.php | 33 ++++++++++++++ ...10_104859_create_customer_answer_table.php | 32 ++++++++++++++ database/seeders/DatabaseSeeder.php | 2 - tests/Feature/ApiV2/ArcadiaTest.php | 1 - tests/Unit/CrmClientV1CustomerTest.php | 7 --- tests/Unit/CrmClientV2ClientTest.php | 1 - 28 files changed, 294 insertions(+), 33 deletions(-) create mode 100644 app/Enums/QuestionType.php create mode 100644 app/Http/Controllers/Api/V2/AnswerController.php create mode 100644 app/Http/Controllers/Api/V2/QuestionController.php create mode 100644 app/Models/Answer.php create mode 100644 app/Models/CustomerAnswer.php create mode 100644 app/Models/Question.php create mode 100644 database/factories/AnswerFactory.php create mode 100644 database/factories/QuestionFactory.php create mode 100644 database/migrations/2021_08_10_103745_create_questions_table.php create mode 100644 database/migrations/2021_08_10_103757_create_answers_table.php create mode 100644 database/migrations/2021_08_10_104859_create_customer_answer_table.php diff --git a/app/Enums/QuestionType.php b/app/Enums/QuestionType.php new file mode 100644 index 0000000..da7ef21 --- /dev/null +++ b/app/Enums/QuestionType.php @@ -0,0 +1,25 @@ + 1, + 'radio' => 2, + 'checkbox' => 3 + ]; + } +} diff --git a/app/Http/Controllers/Api/V2/AnswerController.php b/app/Http/Controllers/Api/V2/AnswerController.php new file mode 100644 index 0000000..64bca6d --- /dev/null +++ b/app/Http/Controllers/Api/V2/AnswerController.php @@ -0,0 +1,10 @@ +belongsTo(Question::class); + } + + /** + * Answer hasOneThrough relation + * + * @return \Illuminate\Database\Eloquent\Relations\HasOneThrough + */ + public function customer() + { + return $this->hasOneThrough(Customer::class, 'customer_answer'); + } +} diff --git a/app/Models/Customer.php b/app/Models/Customer.php index ffeee64..2a72b53 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -5,7 +5,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Hash; class Customer extends Model { diff --git a/app/Models/CustomerAnswer.php b/app/Models/CustomerAnswer.php new file mode 100644 index 0000000..b613fe1 --- /dev/null +++ b/app/Models/CustomerAnswer.php @@ -0,0 +1,10 @@ + QuestionType::class + ]; + + protected $fillable = [ + 'question', + 'type' + ]; + + /** + * Brand BelongsTo relation + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function brand() + { + return $this->belongsTo(Brand::class); + } + + /** + * Answer BelongsTo relation + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function answers() + { + return $this->hasMany(Answer::class); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 95af624..6232f42 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 21af851..797d739 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index cf1e2ab..2c03558 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -5,7 +5,6 @@ namespace App\Providers; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; -use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index cba00ca..b54ffc7 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use App\Models\Brand; use App\Models\Customer; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; diff --git a/database/factories/AnswerFactory.php b/database/factories/AnswerFactory.php new file mode 100644 index 0000000..3564a18 --- /dev/null +++ b/database/factories/AnswerFactory.php @@ -0,0 +1,31 @@ + $this->faker->name, + 'type' => collect(QuestionType::toArray())->random()->value, + ]; + } +} diff --git a/database/factories/CustomerLoginFactory.php b/database/factories/CustomerLoginFactory.php index d5b8c42..056ff0e 100644 --- a/database/factories/CustomerLoginFactory.php +++ b/database/factories/CustomerLoginFactory.php @@ -4,7 +4,6 @@ namespace Database\Factories; use App\Models\CustomerLogin; use Illuminate\Database\Eloquent\Factories\Factory; -use Illuminate\Support\Facades\Hash; class CustomerLoginFactory extends Factory { diff --git a/database/factories/QuestionFactory.php b/database/factories/QuestionFactory.php new file mode 100644 index 0000000..42843a0 --- /dev/null +++ b/database/factories/QuestionFactory.php @@ -0,0 +1,31 @@ + $this->faker->name, + 'type' => collect(QuestionType::toArray())->random()->value, + ]; + } +} diff --git a/database/migrations/2021_08_10_103745_create_questions_table.php b/database/migrations/2021_08_10_103745_create_questions_table.php new file mode 100644 index 0000000..90ec94e --- /dev/null +++ b/database/migrations/2021_08_10_103745_create_questions_table.php @@ -0,0 +1,34 @@ +id(); + $table->text('question'); + $table->tinyInteger('type'); // QuestionType + $table->foreignId('brand_id')->constrained('brands'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('questions'); + } +} diff --git a/database/migrations/2021_08_10_103757_create_answers_table.php b/database/migrations/2021_08_10_103757_create_answers_table.php new file mode 100644 index 0000000..79d038b --- /dev/null +++ b/database/migrations/2021_08_10_103757_create_answers_table.php @@ -0,0 +1,33 @@ +id(); + $table->text('answer'); + $table->foreignId('question_id')->constrained('questions'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('answers'); + } +} diff --git a/database/migrations/2021_08_10_104859_create_customer_answer_table.php b/database/migrations/2021_08_10_104859_create_customer_answer_table.php new file mode 100644 index 0000000..6124faf --- /dev/null +++ b/database/migrations/2021_08_10_104859_create_customer_answer_table.php @@ -0,0 +1,32 @@ +foreignId('question_id')->constrained('questions'); + $table->foreignId('customer_id')->constrained('customers'); + $table->timestamp('created_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('customer_answer'); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index e584dcf..f5a1b5c 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,8 +2,6 @@ namespace Database\Seeders; -use App\Models\Brand; -use App\Models\Customer; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder diff --git a/tests/Feature/ApiV2/ArcadiaTest.php b/tests/Feature/ApiV2/ArcadiaTest.php index 61c885d..38cdc72 100644 --- a/tests/Feature/ApiV2/ArcadiaTest.php +++ b/tests/Feature/ApiV2/ArcadiaTest.php @@ -3,7 +3,6 @@ namespace Tests\Feature\ApiV2; use App\Enums\ApiStatus; -use App\Enums\ArcadiaMailType; use App\Enums\ArcadiaOrderType; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; diff --git a/tests/Unit/CrmClientV1CustomerTest.php b/tests/Unit/CrmClientV1CustomerTest.php index c47b006..df98b1a 100644 --- a/tests/Unit/CrmClientV1CustomerTest.php +++ b/tests/Unit/CrmClientV1CustomerTest.php @@ -3,15 +3,8 @@ namespace Tests\Unit; use App\Models\Customer as ModelsCustomer; -use LDC\LDCCRM\CrmApiV2; -use LDC\LDCCRM\Enums\ApiError; -use LDC\LDCCRM\Enums\ArcadiaOrderType; use LDC\LDCCRM\Enums\Country; -use LDC\LDCCRM\Exceptions\ApiErrorException; -use LDC\LDCCRM\Exceptions\ValidationException; -use LDC\LDCCRM\Models\Customer; use LDCCRM\ApiV1; -use TypeError; class CrmClientV1CustomerTest extends CrmClientTester { diff --git a/tests/Unit/CrmClientV2ClientTest.php b/tests/Unit/CrmClientV2ClientTest.php index c83ac31..9db3b96 100644 --- a/tests/Unit/CrmClientV2ClientTest.php +++ b/tests/Unit/CrmClientV2ClientTest.php @@ -7,7 +7,6 @@ use LDC\LDCCRM\Enums\ApiStatus; use LDC\LDCCRM\Enums\HttpMethods; use LDC\LDCCRM\Transport\ApiInterface; use LDC\LDCCRM\Transport\Request; -use ReflectionClass; class CrmClientV2ClientTest extends CrmClientTester {