phpcs rmove unused imports
This commit is contained in:
parent
ad51caa2d1
commit
9847303cfb
28 changed files with 294 additions and 33 deletions
25
app/Enums/QuestionType.php
Normal file
25
app/Enums/QuestionType.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnum;
|
||||
|
||||
/**
|
||||
* @method static self select()
|
||||
* @method static self radio()
|
||||
* @method static self checkbox()
|
||||
*
|
||||
* @package LDCCrmClient
|
||||
* @subpackage enums
|
||||
*/
|
||||
class QuestionType extends BaseEnum
|
||||
{
|
||||
public static function values(): array
|
||||
{
|
||||
return [
|
||||
'select' => 1,
|
||||
'radio' => 2,
|
||||
'checkbox' => 3
|
||||
];
|
||||
}
|
||||
}
|
||||
10
app/Http/Controllers/Api/V2/AnswerController.php
Normal file
10
app/Http/Controllers/Api/V2/AnswerController.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V2;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class AnswerController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers\Api\V2;
|
||||
|
||||
use App\Enums\ApiError;
|
||||
use App\Enums\ArcadiaMailType;
|
||||
use App\Enums\ArcadiaOrderType;
|
||||
use App\Exceptions\Api\V2\ApiErrorException;
|
||||
use App\Exceptions\Api\V2\CrmException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\V2\BaseApiRequest;
|
||||
|
|
|
|||
10
app/Http/Controllers/Api/V2/QuestionController.php
Normal file
10
app/Http/Controllers/Api/V2/QuestionController.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V2;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class QuestionController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ManageBrandRequest;
|
||||
use App\Models\Brand;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BrandController extends Controller
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use App\Lib\Helper;
|
|||
use App\Models\Service;
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ namespace App\Http\Middleware;
|
|||
use App\Lib\Helper;
|
||||
use App\Models\Service;
|
||||
use Closure;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/**
|
||||
* Updated for ApiV2
|
||||
|
|
|
|||
|
|
@ -2,14 +2,10 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Brand;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceStat;
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CheckBrand
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,7 @@
|
|||
namespace App\Http\Resources\Api\V2;
|
||||
|
||||
use App\Enums\ApiStatus;
|
||||
use App\Exceptions\Api\V2\CrmException;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Contracts\Routing\UrlRoutable;
|
||||
use stdClass;
|
||||
|
||||
class ApiResponse extends JsonResource
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ namespace App\Http\Resources\Api\V2;
|
|||
|
||||
use App\Models\Brand;
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerInfo;
|
||||
use App\Models\CustomerLogin;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CustomerResource extends JsonResource
|
||||
|
|
|
|||
35
app/Models/Answer.php
Normal file
35
app/Models/Answer.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Answer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'answer'
|
||||
];
|
||||
|
||||
/**
|
||||
* Question BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function question()
|
||||
{
|
||||
return $this->belongsTo(Question::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Answer hasOneThrough relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOneThrough
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->hasOneThrough(Customer::class, 'customer_answer');
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
10
app/Models/CustomerAnswer.php
Normal file
10
app/Models/CustomerAnswer.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class CustomerAnswer extends Pivot
|
||||
{
|
||||
//
|
||||
}
|
||||
43
app/Models/Question.php
Normal file
43
app/Models/Question.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\QuestionType;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Kwaadpepper\Enum\Traits\CastsEnums;
|
||||
|
||||
class Question extends Model
|
||||
{
|
||||
use CastsEnums;
|
||||
use HasFactory;
|
||||
|
||||
protected $enumCasts = [
|
||||
'type' => 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
31
database/factories/AnswerFactory.php
Normal file
31
database/factories/AnswerFactory.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\QuestionType;
|
||||
use App\Models\Question;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class AnswerFactory extends Factory
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Question::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'question' => $this->faker->name,
|
||||
'type' => collect(QuestionType::toArray())->random()->value,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
31
database/factories/QuestionFactory.php
Normal file
31
database/factories/QuestionFactory.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\QuestionType;
|
||||
use App\Models\Question;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class QuestionFactory extends Factory
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Question::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'question' => $this->faker->name,
|
||||
'type' => collect(QuestionType::toArray())->random()->value,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateQuestionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('questions', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAnswersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('answers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('answer');
|
||||
$table->foreignId('question_id')->constrained('questions');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('answers');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCustomerAnswerTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('customer_answer', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Brand;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue