Merge branch 'master' of http://git.digital-tps.tk/TPS/birzha-legalizasia
This commit is contained in:
commit
b7ec1976bd
|
|
@ -7,8 +7,9 @@
|
|||
use App\Http\Resources\ApplicationResource;
|
||||
use App\Models\Application;
|
||||
use App\Models\Attachment;
|
||||
use App\Models\Documentgroup;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -51,21 +52,6 @@ public function create()
|
|||
],400);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//upload etmeli dokumentlaryn spisogy
|
||||
$docGroup = Documentgroup::withDocs($this->account->type,$this->account->country_id)->first();
|
||||
|
||||
|
||||
if(!$docGroup || $docGroup->documents->count() == 0)
|
||||
{
|
||||
return response([
|
||||
'success' => false,
|
||||
'message' => trans('app.application.list_not_found')
|
||||
],400);
|
||||
}
|
||||
|
||||
//delete old application??? Should we replace it???
|
||||
if($app = $this->account->last_application())
|
||||
{
|
||||
|
|
@ -77,13 +63,30 @@ public function create()
|
|||
}
|
||||
}
|
||||
|
||||
//todo create attachments here
|
||||
//upload etmeli dokumentlaryn spisogy
|
||||
$documents = Document::where($this->account->type,true)
|
||||
->where(fn($query) => $query->where('all_country',true)
|
||||
->orWhereHas('countries',function(Builder $query)
|
||||
{
|
||||
$query->where('countries.id',$this->account->country_id);
|
||||
}))
|
||||
->get();
|
||||
|
||||
if($documents->count() == 0)
|
||||
{
|
||||
return response([
|
||||
'success' => false,
|
||||
'message' => trans('app.application.list_not_found')
|
||||
],400);
|
||||
}
|
||||
|
||||
|
||||
$application = Application::create([
|
||||
'account_id' => $this->account->id,
|
||||
// 'state' => 'new' //default mysql value is new
|
||||
]);
|
||||
|
||||
foreach ($docGroup->documents as $document){
|
||||
foreach ($documents as $document){
|
||||
$attachment = new Attachment([
|
||||
'name' => $document->name,
|
||||
'document_id' => $document->id
|
||||
|
|
@ -101,7 +104,13 @@ public function create()
|
|||
*/
|
||||
public function get()
|
||||
{
|
||||
if($appication = $this->account->applications()->latest()->with('attachments')->first()){
|
||||
$appication = $this->account
|
||||
->applications()
|
||||
->latest()
|
||||
->with('attachments')
|
||||
->first();
|
||||
|
||||
if($appication){
|
||||
|
||||
return ApplicationResource::make($appication);
|
||||
}
|
||||
|
|
@ -134,6 +143,7 @@ public function apply()
|
|||
$app->state = 'applied';
|
||||
$app->save();
|
||||
|
||||
//todo send email to operators
|
||||
return response([
|
||||
'success' => true,
|
||||
'message' => trans('app.app.application.app_success_message')
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public function login(LoginRequest $request){
|
|||
if($client->is_suspended)
|
||||
{
|
||||
return response()->json([
|
||||
'message' => trans('auth.suspended')
|
||||
'message' => trans('auth.auth.suspended')
|
||||
], 403);
|
||||
}
|
||||
elseif (!$client->is_verified)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public function postTicket(TicketRequest $request)
|
|||
|
||||
$ticket['client_id'] = $client->id;
|
||||
|
||||
$status = Status::where('name', 'LIKE', '%' . 'Open' . '%')->firstOrFail();
|
||||
$status = Status::where('name', 'Open')->firstOrFail();
|
||||
|
||||
$ticket['status_id'] = $status->id;
|
||||
|
||||
|
|
@ -115,6 +115,8 @@ public function postTicket(TicketRequest $request)
|
|||
|
||||
$ticket->save();
|
||||
|
||||
Message::create(['ticket_id' => $ticket->id, 'content' => $request->get("content"),'is_client'=>true]);
|
||||
|
||||
return TicketResource::make($ticket);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,39 @@ protected function setupListOperation()
|
|||
'label' => 'Max size (KBytes)',
|
||||
'default' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'order',
|
||||
'type' => 'number',
|
||||
'label' => 'Position',
|
||||
'default' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'business',
|
||||
'type' => 'radio',
|
||||
'label' => 'Enterpreneurs',
|
||||
'options' => [
|
||||
1 => 'Yes',
|
||||
0 => 'No'
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'company',
|
||||
'type' => 'radio',
|
||||
'label' => 'Companies',
|
||||
'options' => [
|
||||
1 => 'Yes',
|
||||
0 => 'No'
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'all_country',
|
||||
'type' => 'radio',
|
||||
'label' => 'All countries',
|
||||
'options' => [
|
||||
1 => 'Yes',
|
||||
0 => 'No'
|
||||
]
|
||||
],
|
||||
[
|
||||
'label' => "Document Countries",
|
||||
'type' => 'select_multiple',
|
||||
|
|
@ -93,6 +126,27 @@ protected function setupCreateOperation()
|
|||
'label' => 'Max size (KBytes)',
|
||||
'default' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'order',
|
||||
'type' => 'number',
|
||||
'label' => 'Position',
|
||||
'default' => 0
|
||||
],
|
||||
[ // Checkbox
|
||||
'name' => 'business',
|
||||
'label' => 'Enterpreneurs',
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[ // Checkbox
|
||||
'name' => 'company',
|
||||
'label' => 'Companies',
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[ // Checkbox
|
||||
'name' => 'all_country',
|
||||
'label' => 'All countries',
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
// [ // SelectMultiple = n-n relationship (with pivot table)
|
||||
// 'label' => "Document Groups",
|
||||
// 'type' => 'select_multiple',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
|||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
return response(['message' =>'Forbidden'],403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public function toArray($request)
|
|||
'bank_account' => $this->bank ? BankResource::make(json_decode($this->bank)):null,
|
||||
'contacts' => $this->contacts ? ContactResource::make(json_decode($this->contacts)):null,
|
||||
'account_type' => $this->type,
|
||||
'country' => $this->country_name,
|
||||
'country' => CountryResource::make($this->country),
|
||||
'profile' => $this->getProfile(),
|
||||
'legal_number' => $this->legalization_number,
|
||||
'legal_expires_at' => $this->expires_at,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public function toArray($request)
|
|||
'patronomic_name' => $this->patronomic_name,
|
||||
'date_of_birth' => $this->date_of_birth,
|
||||
'birth_place' => $this->birth_place,
|
||||
'citizenship_id' => $this->citizenship_id,
|
||||
'citizenship' => CountryResource::make($this->citizenship),
|
||||
'registration_address' => $this->registration_address,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public function applications():HasMany
|
|||
}
|
||||
|
||||
public function last_application(){
|
||||
$this->applications()->latest()->first();
|
||||
return $this->applications()->latest()->first();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ public function account(){
|
|||
}
|
||||
|
||||
public function attachments(){
|
||||
return $this->hasMany(Attachment::class);
|
||||
return $this->hasMany(Attachment::class)
|
||||
->leftJoin('documents','attachments.document_id','=','documents.id')
|
||||
->select('attachments.*','order')
|
||||
->orderBy('documents.order');
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@ class Document extends Model
|
|||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'max_size'
|
||||
'max_size',
|
||||
'business',
|
||||
'company',
|
||||
'all_country',
|
||||
'order'
|
||||
];
|
||||
// protected $hidden = [];
|
||||
// protected $dates = [];
|
||||
|
|
|
|||
|
|
@ -10,23 +10,10 @@
|
|||
|
||||
class BusinessProfile extends Profile
|
||||
{
|
||||
protected $fileds = [
|
||||
'profile' => [],
|
||||
'document' => []
|
||||
];// for fields that doesn need validation
|
||||
|
||||
public $form = [
|
||||
'profile' => BusinessProfileRequest::class,
|
||||
'document' => BusinessProfileDocRequest::class
|
||||
'profile' => BusinessProfileRequest::class,
|
||||
'document' => BusinessProfileDocRequest::class,
|
||||
'model' => Business::class,
|
||||
'resource' => BusinessProfileResource::class
|
||||
];
|
||||
|
||||
public function createProfile(array $data)
|
||||
{
|
||||
return Business::create($data);
|
||||
}
|
||||
|
||||
public function resource($profile) : BusinessProfileResource{
|
||||
return new BusinessProfileResource($profile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,22 +9,12 @@
|
|||
|
||||
class CompanyProfile extends Profile
|
||||
{
|
||||
protected $fileds = [
|
||||
'profile' => [],
|
||||
'document' => []
|
||||
];// for fields that doesn need validation
|
||||
|
||||
public $form = [
|
||||
'profile' => CompanyProfileRequest::class,
|
||||
'document' => CompanyProfileDocRequest::class
|
||||
'profile' => CompanyProfileRequest::class,
|
||||
'document' => CompanyProfileDocRequest::class,
|
||||
'model' => Company::class,
|
||||
'resource' => CompanyProfileResource::class
|
||||
];
|
||||
|
||||
public function createProfile(array $data){
|
||||
return Company::create($data);
|
||||
}
|
||||
|
||||
public function resource($profile){
|
||||
return new CompanyProfileResource($profile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@
|
|||
abstract class Profile
|
||||
{
|
||||
protected $request;
|
||||
protected $fileds = [];
|
||||
public $form = [];
|
||||
protected $fileds = [
|
||||
'profile' => [],
|
||||
'document' => []
|
||||
];// for fields that doesn need validation
|
||||
|
||||
abstract function createProfile(array $data);
|
||||
abstract function resource($profile);
|
||||
protected $form;
|
||||
|
||||
public function validateRequest()
|
||||
{
|
||||
|
|
@ -47,4 +48,12 @@ public function updateProfile($profile)
|
|||
|
||||
return $this->resource($profile);
|
||||
}
|
||||
|
||||
public function createProfile(array $data){
|
||||
return $this->form['model']::create($data);
|
||||
}
|
||||
|
||||
public function resource($profile){
|
||||
return $this->form['resource']::make($profile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@
|
|||
public function up()
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->string('receipt_path')->nullable();
|
||||
$table->string('questionnaire_path')->nullable();
|
||||
|
||||
$table->string('state')->default('new');
|
||||
});
|
||||
}
|
||||
|
|
@ -28,8 +27,6 @@ public function up()
|
|||
public function down()
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropColumn('receipt_path');
|
||||
$table->dropColumn('questionnaire_path');
|
||||
$table->dropColumn('state');
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropColumn('receipt_path');
|
||||
$table->dropColumn('questionnaire_path');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->boolean('business')->default(0);
|
||||
$table->boolean('company')->default(0);
|
||||
$table->boolean('all_country')->default(0);
|
||||
$table->integer('order')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->dropColumn('business');
|
||||
$table->dropColumn('company');
|
||||
$table->dropColumn('all_country');
|
||||
$table->dropColumn('order');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used during authentication for various
|
||||
| messages that we need to display to the user. You are free to modify
|
||||
| these language lines according to your application's requirements.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'password' => 'The provided password is incorrect.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
'suspended' => 'Account with this email is suspended',
|
||||
'not_verified' => 'Account email is not verified.',
|
||||
'unauthorized' => 'Unauthorized',
|
||||
'token_mismatch' => 'Tokens don\'t match',
|
||||
'user_not_found' => 'User with provided email not found',
|
||||
'token_expired' => 'Token expired',
|
||||
|
||||
];
|
||||
|
|
@ -16,5 +16,10 @@
|
|||
'failed' => 'These credentials do not match our records.',
|
||||
'password' => 'The provided password is incorrect.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
'suspended' => 'Account with this email is suspended',
|
||||
'not_verified' => 'Account email is not verified.',
|
||||
'unauthorized' => 'Unauthorized',
|
||||
'token_mismatch' => 'Tokens don\'t match',
|
||||
'user_not_found' => 'User with provided email not found',
|
||||
'token_expired' => 'Token expired',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
'email_not_found' => 'Email пользователя не найден',
|
||||
'suspended' => 'Account with this email is suspended',
|
||||
'not_verified' => 'Account email is not verified.',
|
||||
'unauthorized' => 'Unauthorized',
|
||||
'token_mismatch' => 'Tokens don\'t match',
|
||||
'user_not_found' => 'User with provided email not found',
|
||||
'token_expired' => 'Token expired',
|
||||
];
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
'email_not_found' => 'This email not found',
|
||||
'suspended' => 'Account with this email is suspended',
|
||||
'not_verified' => 'Account email is not verified.',
|
||||
'unauthorized' => 'Unauthorized',
|
||||
'token_mismatch' => 'Tokens don\'t match',
|
||||
'user_not_found' => 'User with provided email not found',
|
||||
'token_expired' => 'Token expired',
|
||||
|
||||
];
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
Route::get('/countries', [ResourceController::class, 'countries']);
|
||||
Route::get('/categories', [ResourceController::class, 'categories']);
|
||||
Route::get('/faqs', [ResourceController::class, 'faqs']);
|
||||
|
||||
// Route::post('/prof',[AccountController::class,'storeProfileInfo']);
|
||||
Route::middleware(['auth.client','auth:api', 'auth:sanctum'])->group(function () {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1635,6 +1635,40 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/application/oprosnik": {
|
||||
"get": {
|
||||
"tags": ["Application"],
|
||||
"summary": "Download oprosnik",
|
||||
"parameters": [{
|
||||
"name": "X-Localization",
|
||||
"in": "header",
|
||||
"description": "Localization",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"examples": {
|
||||
"ru": {
|
||||
"summary": "Russian localization",
|
||||
"value": "ru"
|
||||
},
|
||||
"en": {
|
||||
"summary": "English localization",
|
||||
"value": "en"
|
||||
},
|
||||
"tm": {
|
||||
"summary": "Turkmen localization",
|
||||
"value": "tm"
|
||||
}
|
||||
}
|
||||
}],
|
||||
"security":[
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue