Application status

This commit is contained in:
merdan 2022-09-12 14:03:54 +05:00
parent cfae033976
commit ad06ef2d43
5 changed files with 50 additions and 8 deletions

View File

@ -9,8 +9,6 @@
use App\Models\Attachment;
use App\Models\Documentgroup;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
class ApplicationController extends Controller
@ -40,11 +38,12 @@ public function create()
],400);
}
//delete old application
//delete old application??? Should we replace it???
if($this->account->aplication)
{
$this->account->aplication->delete();
//todo on delete cascade delete documents and files
//todo replace application & change old status to arhiw
}
//upload etmeli dokumentlaryn spisogy

View File

@ -15,10 +15,15 @@ class AccountResource extends JsonResource
public function toArray($request)
{
return [
'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,
'profile' => $this->getProfile()
'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,
'profile' => $this->getProfile(),
'legal_number' => $this->legalization_number,
'legal_expires_at' => $this->expires_at,
'legal_can_apply' => $this->can_apply_legal_number,
'legal_can_extend' => $this->can_extend_legal_number,
'legal_app_status' => $this->application_status,
];
}

View File

@ -3,6 +3,7 @@
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Account extends Model
@ -73,6 +74,30 @@ public function clients(){
|--------------------------------------------------------------------------
*/
public function getCanApplyLegalNumberAttribute(){
return is_null($this->application);
}
public function getCanExtendLegalNumberAttribute() {
$application = $this->application;
if($application && $application->status == 'approved'
&& $this->expires_at->lte(Carbon::now()->subMonth(Config::get('settings.legalization_extend') ?? 1))){
return true;
}
return false;
}
public function getApplicationStatusAttribute(){
if($application = $this->application){
return $application->status;
}
return null;
}
/*
|--------------------------------------------------------------------------
| MUTATORS

View File

@ -20,6 +20,14 @@ class SettingsSeeder extends Seeder
'field' => '{"name":"value","label":"Value","type":"checkbox"}',
'active' => 1,
],
[
'key' => 'legalization_extend',
'name' => 'Legalization number extension month',
'description' => 'Legalizasia nomeri mohleti uzatmaga, nace ay onunden rugsat berilyar',
'value' => 1,
'field' => '{"name":"value","label":"Value","type":"number"}',
'active' => 1,
],
];
/**

View File

@ -35,7 +35,12 @@
"email": "johndoe@gmail.com"
},
"account_type": "business",
"profile": null
"profile": null,
"legal_number": null,
"legal_expires_at": null,
"legal_can_apply": true,
"legal_can_extend": false,
"application_status": null
}
}
}