Files
freeu-project/app/Services/KYCService.php
Ritikesh yadav c661166e1d first commit
2024-03-28 14:52:40 +05:30

628 lines
46 KiB
PHP

<?php
namespace App\Services;
use App\Models\HUF;
use App\Models\NRIKyc;
use App\Models\Outhers;
use App\Models\UserKyc;
use App\Models\PartnerShip;
use App\Models\UserKycDocs;
use App\Models\UserCompanyKyc;
use App\Models\UserIndividualKyc;
class KYCService
{
public function getUserId()
{
return auth()->guard('users')->user()->id;
}
public function getUserAPIId()
{
return request()->user()->id;
}
//Block User From entering different kyc page or submitting different kyc
public function blockUser($userID, $kycType)
{
$kycExists = UserKyc::where('users_id', $userID)->first();
if ($kycExists && $kycExists->kyc_type !== $kycType) {
abort(401,'Your KYC does not exist or not in correct pan type');
}
if ($kycExists && $kycExists->status !== 'Rejected') {
abort(401,'Your KYC is not eligible for editing.');
}
}
public function homeKycExists()
{
return UserKyc::query()
->leftJoin('user_individual_kyc', 'user_kycs.users_id', 'user_individual_kyc.user_id')
->leftJoin('huf', 'user_kycs.users_id', 'huf.user_id')
->leftJoin('nri_kyc', 'user_kycs.users_id', 'nri_kyc.user_id')
->leftJoin('company', 'user_kycs.users_id', 'company.user_id')
->leftJoin('partnership', 'user_kycs.users_id', 'partnership.user_id')
->leftJoin('others', 'user_kycs.users_id', 'others.user_id')
->where('users_id', $this->getUserId())
->first();
}
public function checkKYCExists($userId)
{
return UserKyc::where('users_id', $userId)->exists();
}
public function createKYC($userId, $validated, $checkKyc)
{
return UserKyc::updateOrCreate([
'users_id' => $userId
], [
...$validated,
'status' => $checkKyc == true ? 'Pending' : 'New',
]);
}
// Individual
public function removePreviousIndividualFiles($userId)
{
$individualKycExists = UserIndividualKyc::where('user_id', $userId)->first();
if ($individualKycExists) {
\Storage::exists($individualKycExists->pan_card) ? \Storage::delete($individualKycExists->pan_card) : '';
\Storage::exists($individualKycExists->proof_of_address) ? \Storage::delete($individualKycExists->proof_of_address) : '';
\Storage::exists($individualKycExists->cancelled_cheque_or_bank_statement) ? \Storage::delete($individualKycExists->cancelled_cheque_or_bank_statement) : '';
\Storage::exists($individualKycExists->photograph) ? \Storage::delete($individualKycExists->photograph) : '';
\Storage::exists($individualKycExists->copy_of_cml) ? \Storage::delete($individualKycExists->copy_of_cml) : '';
}
}
public function individualFileUpload($userId, $validated)
{
$pan_card_fileName = 'pan_card_' . time() . $userId . '.' . $validated['pan_card']->getClientOriginalExtension();
$pan_card_path = $validated['pan_card']->storeAs('files/images/individual_kyc/pan_card', $pan_card_fileName);
$proof_of_address_fileName = 'proof_of_address_' . time() . $userId . '.' . $validated['proof_of_address']->getClientOriginalExtension();
$proof_of_address_path = $validated['proof_of_address']->storeAs('files/images/individual_kyc/proof_of_address', $proof_of_address_fileName);
$photograph_fileName = 'photograph_' . time() . $userId . '.' . $validated['Photograph']->getClientOriginalExtension();
$photograph_path = $validated['Photograph']->storeAs('files/images/individual_kyc/photograph', $photograph_fileName);
$cancelled_cheque_fileName = 'cancelled_cheque_' . time() . $userId . '.' . $validated['cancelled_cheque']->getClientOriginalExtension();
$cancelled_cheque_path = $validated['cancelled_cheque']->storeAs('files/images/individual_kyc/cancelled_cheque_or_bank_statement', $cancelled_cheque_fileName);
$copy_of_cml_fileName = 'copy_of_cml_' . time() . $userId . '.' . $validated['copy_of_cml']->getClientOriginalExtension();
$copy_of_cml_path = $validated['copy_of_cml']->storeAs('files/images/individual_kyc/copy_of_cml', $copy_of_cml_fileName);
return [
'pan_card' => $pan_card_path,
'proof_of_address' => $proof_of_address_path,
'photograph' => $photograph_path,
'cancelled_cheque_or_bank_statement' => $cancelled_cheque_path,
'copy_of_cml' => $copy_of_cml_path,
];
}
public function createIndividualKYC($userId, $individualFileUpload)
{
return UserIndividualKyc::updateOrCreate([
'user_id' => $userId
], [
...$individualFileUpload
]);
}
//HUF
public function removePreviousHUFFiles($userId)
{
$hufKycExists = HUF::where('user_id', $userId)->first();
if ($hufKycExists) {
\Storage::exists($hufKycExists->deed_of_declaration_of_huf) ? \Storage::delete($hufKycExists->deed_of_declaration_of_huf) : '';
\Storage::exists($hufKycExists->list_of_members) ? \Storage::delete($hufKycExists->list_of_members) : '';
\Storage::exists($hufKycExists->proof_of_address_of_karta_of_huf) ? \Storage::delete($hufKycExists->proof_of_address_of_karta_of_huf) : '';
\Storage::exists($hufKycExists->bank_statement_or_bank_passbook) ? \Storage::delete($hufKycExists->bank_statement_or_bank_passbook) : '';
\Storage::exists($hufKycExists->passport_size_photograph_of_karta) ? \Storage::delete($hufKycExists->passport_size_photograph_of_karta) : '';
\Storage::exists($hufKycExists->copy_of_cml) ? \Storage::delete($hufKycExists->copy_of_cml) : '';
\Storage::exists($hufKycExists->cancelled_cheque) ? \Storage::delete($hufKycExists->cancelled_cheque) : '';
}
}
public function hufFileUpload($userId, $validated)
{
$deed_of_declaration_fileName = 'deed_of_declaration_' . time() . $userId . '.' . $validated['deed_of_declaration']->getClientOriginalExtension();
$deed_of_declaration_path = $validated['deed_of_declaration']->storeAs('files/images/huf_kyc/deed_of_declaration', $deed_of_declaration_fileName);
$panCard = $validated['pan_card'];
$aadharCard = $validated['coparcenrs_aadhar_passport'];
$multipleFileUploads = $this->multipleFileUpload($userId, $panCard, $aadharCard);
$list_of_all_members_fileName = 'list_of_all_members_' . time() . $userId . '.' . $validated['list_of_all_members']->getClientOriginalExtension();
$list_of_all_members_path = $validated['list_of_all_members']->storeAs('files/images/huf_kyc/list_of_all_members', $list_of_all_members_fileName);
$proof_of_address_fileName = 'proof_of_address_' . time() . $userId . '.' . $validated['proof_of_address']->getClientOriginalExtension();
$proof_of_address_path = $validated['proof_of_address']->storeAs('files/images/huf_kyc/proof_of_address', $proof_of_address_fileName);
$bank_statement_fileName = 'bank_statement_' . time() . $userId . '.' . $validated['bank_statement']->getClientOriginalExtension();
$bank_statement_path = $validated['bank_statement']->storeAs('files/images/huf_kyc/bank_statement', $bank_statement_fileName);
$passport_size_photo_fileName = 'passport_size_photo_' . time() . $userId . '.' . $validated['passport_size_photo']->getClientOriginalExtension();
$passport_size_photo_path = $validated['passport_size_photo']->storeAs('files/images/huf_kyc/passport_size_photo', $passport_size_photo_fileName);
$copy_of_cml_fileName = 'copy_of_cml_' . time() . $userId . '.' . $validated['copy_of_cml']->getClientOriginalExtension();
$copy_of_cml_path = $validated['copy_of_cml']->storeAs('files/images/huf_kyc/copy_of_cml', $copy_of_cml_fileName);
$cancelled_cheque_fileName = 'cancelled_cheque_' . time() . $userId . '.' . $validated['cancelled_cheque']->getClientOriginalExtension();
$cancelled_cheque_path = $validated['cancelled_cheque']->storeAs('files/images/huf_kyc/cancelled_cheque_or_bank_statement', $cancelled_cheque_fileName);
return [
'deed_of_declaration_of_huf' => $deed_of_declaration_path,
'list_of_members' => $list_of_all_members_path,
'proof_of_address_of_karta_of_huf' => $proof_of_address_path,
'bank_statement_or_bank_passbook' => $bank_statement_path,
'passport_size_photograph_of_karta' => $passport_size_photo_path,
'copy_of_cml' => $copy_of_cml_path,
'cancelled_cheque' => $cancelled_cheque_path,
];
}
public function deleteMultipleFile($userId){
$userDocs = UserKycDocs::where('user_id',$userId)->get();
foreach($userDocs as $doc){
\Storage::exists($doc->file_name) ? \Storage::delete($doc->file_name) : '';
UserKycDocs::where('id',$doc->id)->delete();
}
}
public function multipleFileUpload($userId, $panCard, $aadharCard, $passport = [])
{
//Pan ,Passport ,Aadhar
foreach ($panCard as $key => $data) {
$panCardFileName = 'pan_card_' . $key . time() . $userId . '.' . $data->getClientOriginalExtension();
$panCardPath = $data->storeAs('files/pan_card', $panCardFileName);
UserKycDocs::create([
'user_id' => $userId,
'doc_type' => 'Pan',
'file_name' => $panCardPath
]);
}
foreach ($aadharCard as $key => $data) {
$aadharCardFileName = 'aadhar_card_' . $key . time() . $userId . '.' . $data->getClientOriginalExtension();
$aadharCardPath = $data->storeAs('files/aadhar', $aadharCardFileName);
UserKycDocs::create([
'user_id' => $userId,
'doc_type' => 'Aadhar',
'file_name' => $aadharCardPath
]);
}
if ($passport) {
foreach ($passport as $key => $data) {
$passportFileName = 'aadhar_card_' . $key . time() . $userId . '.' . $data->getClientOriginalExtension();
$passportPath = $data->storeAs('files/passport', $passportFileName);
UserKycDocs::create([
'user_id' => $userId,
'doc_type' => 'Passport',
'file_name' => $passportPath
]);
}
}
}
public function createHUFKYC($userID, $hufFileUpload)
{
return HUF::updateOrCreate([
'user_id' => $userID
], [
...$hufFileUpload
]);
}
//NRI
public function removePreviousNRIFiles($userId)
{
$nriKycExists = NRIKyc::where('user_id', $userId)->first();
if ($nriKycExists) {
\Storage::exists($nriKycExists->passport) ? \Storage::delete($nriKycExists->passport) : '';
\Storage::exists($nriKycExists->pio_or_oci_card) ? \Storage::delete($nriKycExists->pio_or_oci_card) : '';
\Storage::exists($nriKycExists->tin) ? \Storage::delete($nriKycExists->tin) : '';
\Storage::exists($nriKycExists->pan_card) ? \Storage::delete($nriKycExists->pan_card) : '';
\Storage::exists($nriKycExists->proof_of_address_of_india) ? \Storage::delete($nriKycExists->proof_of_address_of_india) : '';
\Storage::exists($nriKycExists->utility) ? \Storage::delete($nriKycExists->utility) : '';
\Storage::exists($nriKycExists->rental_agreement) ? \Storage::delete($nriKycExists->rental_agreement) : '';
\Storage::exists($nriKycExists->passport_size_of_photograph) ? \Storage::delete($nriKycExists->passport_size_of_photograph) : '';
\Storage::exists($nriKycExists->copy_of_cml) ? \Storage::delete($nriKycExists->copy_of_cml) : '';
\Storage::exists($nriKycExists->cancelled_cheque_nro_or_nre_account) ? \Storage::delete($nriKycExists->cancelled_cheque_nro_or_nre_account) : '';
\Storage::exists($nriKycExists->trc_copy) ? \Storage::delete($nriKycExists->trc_copy) : '';
\Storage::exists($nriKycExists->form_10f) ? \Storage::delete($nriKycExists->form_10f) : '';
\Storage::exists($nriKycExists->no_pe_declaration) ? \Storage::delete($nriKycExists->no_pe_declaration) : '';
}
}
public function nriFileUpload($userId, $validated)
{
$Passport_fileName = 'passport_' . time() . $userId . '.' . $validated['passport']->getClientOriginalExtension();
$Passport_path = $validated['passport']->storeAs('files/images/nri_kyc/passport', $Passport_fileName);
if (array_key_exists('pio_oci_card', $validated)) {
$pio_oci_card_fileName = 'pio_oci_card_' . time() . $userId . '.' . $validated['pio_oci_card']->getClientOriginalExtension();
$pio_oci_card_path = $validated['pio_oci_card']->storeAs('files/images/nri_kyc/pio_oci_card', $pio_oci_card_fileName);
}
$tin_fileName = 'tin_' . time() . $userId . '.' . $validated['tin']->getClientOriginalExtension();
$tin_path = $validated['tin']->storeAs('files/images/nri_kyc/tin', $tin_fileName);
$pan_card_fileName = 'pan_card_' . time() . $userId . '.' . $validated['pan_card']->getClientOriginalExtension();
$pan_card_path = $validated['pan_card']->storeAs('files/images/nri_kyc/pan_card', $pan_card_fileName);
$proof_of_address_of_india_fileName = 'proof_of_address_of_india_' . time() . $userId . '.' . $validated['proof_of_address_of_india']->getClientOriginalExtension();
$proof_of_address_of_india_path = $validated['proof_of_address_of_india']->storeAs('files/images/nri_kyc/proof_of_address_of_india', $proof_of_address_of_india_fileName);
// $proof_of_address_of_foreign_fileName = 'proof_of_address_of_foreign_' . time() . $userId . '.' . $validated['proof_of_address_of_foreign']->getClientOriginalExtension();
// $proof_of_address_of_foreign_path = $validated['proof_of_address_of_foreign']->storeAs('files/images/nri_kyc/proof_of_address_of_foreign', $proof_of_address_of_foreign_fileName);
$proof_of_address_of_foreign_utility_fileName = 'utility' . time() . $userId . '.' . $validated['utility']->getClientOriginalExtension();
$proof_of_address_of_foreign_utility_path = $validated['utility']->storeAs('files/images/nri_kyc/utility', $proof_of_address_of_foreign_utility_fileName);
$proof_of_address_of_foreign_rental_agreement_fileName = 'rental_agreement' . time() . $userId . '.' . $validated['rental_agreement']->getClientOriginalExtension();
$proof_of_address_of_foreign_rental_agreement_path = $validated['rental_agreement']->storeAs('files/images/nri_kyc/rental_agreement', $proof_of_address_of_foreign_rental_agreement_fileName);
$passport_size_photograph_fileName = 'passport_size_photograph_' . time() . $userId . '.' . $validated['passport_size_photograph']->getClientOriginalExtension();
$passport_size_photograph_path = $validated['passport_size_photograph']->storeAs('files/images/nri_kyc/passport_size_photograph', $passport_size_photograph_fileName);
$copy_of_cml_fileName = 'copy_of_cml_' . time() . $userId . '.' . $validated['copy_of_cml']->getClientOriginalExtension();
$copy_of_cml_path = $validated['copy_of_cml']->storeAs('files/images/nri_kyc/copy_of_cml', $copy_of_cml_fileName);
if (array_key_exists('cancelled_cheque', $validated)) {
$cancelled_cheque_fileName = 'cancelled_cheque_' . time() . $userId . '.' . $validated['cancelled_cheque']->getClientOriginalExtension();
$cancelled_cheque_path = $validated['cancelled_cheque']->storeAs('files/images/nri_kyc/cancelled_cheque', $cancelled_cheque_fileName);
}
if (array_key_exists('trc_copy', $validated)) {
$trc_copy_fileName = 'trc_copy_' . time() . $userId . '.' . $validated['trc_copy']->getClientOriginalExtension();
$trc_copy_path = $validated['trc_copy']->storeAs('files/images/nri_kyc/trc_copy', $trc_copy_fileName);
}
if (array_key_exists('form_10f', $validated)) {
$form_10f_fileName = 'form_10f_' . time() . $userId . '.' . $validated['form_10f']->getClientOriginalExtension();
$form_10f_path = $validated['form_10f']->storeAs('files/images/nri_kyc/form_10f', $form_10f_fileName);
}
if (array_key_exists('no_pe_declaration', $validated)) {
$no_pe_declaration_fileName = 'no_pe_declaration_' . time() . $userId . '.' . $validated['no_pe_declaration']->getClientOriginalExtension();
$no_pe_declaration_path = $validated['no_pe_declaration']->storeAs('files/images/nri_kyc/no_pe_declaration', $no_pe_declaration_fileName);
}
return [
'passport' => $Passport_path,
'pio_or_oci_card' => $pio_oci_card_path ?? null,
'tin' => $tin_path,
'pan_card' => $pan_card_path,
'proof_of_address_of_india' => $proof_of_address_of_india_path,
'utility' => $proof_of_address_of_foreign_utility_path,
'rental_agreement' => $proof_of_address_of_foreign_rental_agreement_path,
'passport_size_of_photograph' => $passport_size_photograph_path,
'copy_of_cml' => $copy_of_cml_path,
'cancelled_cheque_nro_or_nre_account' => $cancelled_cheque_path ?? null,
'trc_copy' => $trc_copy_path ?? null,
'form_10f' => $form_10f_path ?? null,
'no_pe_declaration' => $no_pe_declaration_path ?? null,
];
}
public function createNRIKYC($userId, $nriFileUpload)
{
return NRIKyc::updateOrCreate([
'user_id' => $userId
], [
...$nriFileUpload
]);
}
//Company
public function removePreviousCompanyFiles($userId)
{
$companyKycExists = UserCompanyKyc::where('user_id', $userId)->first();
if ($companyKycExists) {
\Storage::exists($companyKycExists->memorandum_or_articles_of_association) ? \Storage::delete($companyKycExists->memorandum_or_articles_of_association) : '';
\Storage::exists($companyKycExists->company_pan) ? \Storage::delete($companyKycExists->company_pan) : '';
\Storage::exists($companyKycExists->certificate_of_incorporation) ? \Storage::delete($companyKycExists->certificate_of_incorporation) : '';
\Storage::exists($companyKycExists->tan_allotment_letter) ? \Storage::delete($companyKycExists->tan_allotment_letter) : '';
\Storage::exists($companyKycExists->List_of_directors_or_authorized_signatories) ? \Storage::delete($companyKycExists->List_of_directors_or_authorized_signatories) : '';
\Storage::exists($companyKycExists->proof_of_address_of_the_company) ? \Storage::delete($companyKycExists->proof_of_address_of_the_company) : '';
\Storage::exists($companyKycExists->latest_income_tax_return_of_the_company_Of_last_2_years) ? \Storage::delete($companyKycExists->latest_income_tax_return_of_the_company_Of_last_2_years) : '';
\Storage::exists($companyKycExists->copy_of_cml) ? \Storage::delete($companyKycExists->copy_of_cml) : '';
\Storage::exists($companyKycExists->copy_of_audited_balance_sheet_for_the_last_2_f_y) ? \Storage::delete($companyKycExists->copy_of_audited_balance_sheet_for_the_last_2_f_y) : '';
\Storage::exists($companyKycExists->true_copy_form_32_or_dir_12_alongwith_roc_fee_payment) ? \Storage::delete($companyKycExists->true_copy_form_32_or_dir_12_alongwith_roc_fee_payment) : '';
\Storage::exists($companyKycExists->true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment) ? \Storage::delete($companyKycExists->true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment) : '';
\Storage::exists($companyKycExists->cancelled_cheque) ? \Storage::delete($companyKycExists->cancelled_cheque) : '';
}
}
public function companyFileUpload($userId, $validated)
{
$memorandum_or_articles_of_association_fileName = 'memorandum_or_articles_of_association' . time() . $userId . '.' . $validated['memorandum_or_articles_of_association']->getClientOriginalExtension();
$memorandum_or_articles_of_association_path = $validated['memorandum_or_articles_of_association']->storeAs('files/images/company_kyc/memorandum_or_articles_of_association', $memorandum_or_articles_of_association_fileName);
$company_pan_fileName = 'company_pan' . time() . $userId . '.' . $validated['company_pan']->getClientOriginalExtension();
$company_pan_path = $validated['company_pan']->storeAs('files/images/company_kyc/company_pan', $company_pan_fileName);
$certificate_of_incorporation_fileName = 'certificate_of_incorporation' . time() . $userId . '.' . $validated['certificate_of_incorporation']->getClientOriginalExtension();
$certificate_of_incorporation_path = $validated['certificate_of_incorporation']->storeAs('files/images/company_kyc/certificate_of_incorporation', $certificate_of_incorporation_fileName);
if (array_key_exists('tan_allotment_letter', $validated)) {
$tan_allotment_letter_fileName = 'tan_allotment_letter' . time() . $userId . '.' . $validated['tan_allotment_letter']->getClientOriginalExtension();
$tan_allotment_letter_path = $validated['tan_allotment_letter']->storeAs('files/images/company_kyc/tan_allotment_letter', $tan_allotment_letter_fileName);
}
if (array_key_exists('List_of_directors_or_authorized_signatories', $validated)) {
$List_of_directors_or_authorized_signatories_fileName = 'List_of_directors_or_authorized_signatories' . time() . $userId . '.' . $validated['List_of_directors_or_authorized_signatories']->getClientOriginalExtension();
$List_of_directors_or_authorized_signatories_path = $validated['List_of_directors_or_authorized_signatories']->storeAs('files/images/company_kyc/List_of_directors_or_authorized_signatories', $List_of_directors_or_authorized_signatories_fileName);
}
// $pan_card_copy_of_authorized_signatory_fileName = 'pan_card_copy_of_authorized_signatory' . $userId . '-' . time() . '.' . $validated['pan_card_copy_of_authorized_signatory->getClientOriginalExtension();
// $pan_card_copy_of_authorized_signatory_path = $validated['pan_card_copy_of_authorized_signatory->storeAs('files/images/company_kyc/pan_card_copy_of_authorized_signatory', $pan_card_copy_of_authorized_signatory_fileName);
// $aadhar_card_copy_of_authorized_signatory_fileName = 'aadhar_card_copy_of_authorized_signatory' . $userId . '-' . time() . '.' . $validated['aadhar_card_copy_of_authorized_signatory->getClientOriginalExtension();
// $aadhar_card_copy_of_authorized_signatory_fileName_path = $validated['aadhar_card_copy_of_authorized_signatory->storeAs('files/images/company_kyc/aadhar_card_copy_of_authorized_signatory', $aadhar_card_copy_of_authorized_signatory_fileName);
$panCard = $validated['pan_card_copy_of_authorized_signatory'];
$aadharCard = $validated['aadhar_card_copy_of_authorized_signatory'];
$passport = $validated['passport_photo_all_authorized_signatories_or_directors'];
$multipleFileUploads = $this->multipleFileUpload($userId, $panCard, $aadharCard, $passport);
if (array_key_exists('proof_of_address_of_the_company', $validated)) {
$proof_of_address_of_the_company_fileName = 'proof_of_address_of_the_company' . time() . $userId . '.' . $validated['proof_of_address_of_the_company']->getClientOriginalExtension();
$proof_of_address_of_the_company_path = $validated['proof_of_address_of_the_company']->storeAs('files/images/company_kyc/proof_of_address_of_the_company', $proof_of_address_of_the_company_fileName);
}
if (array_key_exists('latest_income_tax_return_of_the_company_Of_last_2_years', $validated)) {
$latest_income_tax_return_of_the_company_Of_last_2_years_fileName = 'latest_income_tax_return_of_the_company_Of_last_2_years' . time() . $userId . '.' . $validated['latest_income_tax_return_of_the_company_Of_last_2_years']->getClientOriginalExtension();
$latest_income_tax_return_of_the_company_Of_last_2_years_path = $validated['latest_income_tax_return_of_the_company_Of_last_2_years']->storeAs('files/images/company_kyc/latest_income_tax_return_of_the_company_Of_last_2_years', $latest_income_tax_return_of_the_company_Of_last_2_years_fileName);
}
if (array_key_exists('copy_of_cml', $validated)) {
$copy_of_cml_fileName = 'copy_of_cml' . time() . $userId . '.' . $validated['copy_of_cml']->getClientOriginalExtension();
$copy_of_cml_path = $validated['copy_of_cml']->storeAs('files/images/company_kyc/copy_of_cml', $copy_of_cml_fileName);
}
if (array_key_exists('copy_of_audited_balance_sheet_for_the_last_2_f_y', $validated)) {
$copy_of_audited_balance_sheet_for_the_last_2_f_y_fileName = 'copy_of_audited_balance_sheet_for_the_last_2_f_y' . time() . $userId . '.' . $validated['copy_of_audited_balance_sheet_for_the_last_2_f_y']->getClientOriginalExtension();
$copy_of_audited_balance_sheet_for_the_last_2_f_y_path = $validated['copy_of_audited_balance_sheet_for_the_last_2_f_y']->storeAs('files/images/company_kyc/copy_of_audited_balance_sheet_for_the_last_2_f_y', $copy_of_audited_balance_sheet_for_the_last_2_f_y_fileName);
}
// $passport_photo_all_authorized_signatories_or_directors_fileName = 'passport_photo_all_authorized_signatories_or_directors' . $userId . '-' . time() . '.' . $validated['passport_photo_all_authorized_signatories_or_directors->getClientOriginalExtension();
// $passport_photo_all_authorized_signatories_or_directors_filepath = $validated['passport_photo_all_authorized_signatories_or_directors->storeAs('files/images/company_kyc/passport_photo_all_authorized_signatories_or_directors', $passport_photo_all_authorized_signatories_or_directors_fileName);
if (array_key_exists('true_copy_form_32_or_dir_12_alongwith_roc_fee_payment', $validated)) {
$true_copy_form_32_or_dir_12_alongwith_roc_fee_payment_fileName = 'true_copy_form_32_or_dir_12_alongwith_roc_fee_payment' . time() . $userId . '.' . $validated['true_copy_form_32_or_dir_12_alongwith_roc_fee_payment']->getClientOriginalExtension();
$true_copy_form_32_or_dir_12_alongwith_roc_fee_payment_path = $validated['true_copy_form_32_or_dir_12_alongwith_roc_fee_payment']->storeAs('files/images/company_kyc/true_copy_form_32_or_dir_12_alongwith_roc_fee_payment', $true_copy_form_32_or_dir_12_alongwith_roc_fee_payment_fileName);
}
if (array_key_exists('true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment', $validated)) {
$true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment_fileName = 'true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment' . time() . $userId . '.' . $validated['true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment']->getClientOriginalExtension();
$true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment_path = $validated['true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment']->storeAs('files/images/company_kyc/true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment', $true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment_fileName);
}
$cancelled_cheque_fileName = 'cancelled_cheque' . time() . $userId . '.' . $validated['cancelled_cheque']->getClientOriginalExtension();
$cancelled_cheque_path = $validated['cancelled_cheque']->storeAs('files/images/company_kyc/cancelled_cheque', $cancelled_cheque_fileName);
return [
'memorandum_or_articles_of_association' => $memorandum_or_articles_of_association_path,
'company_pan' => $company_pan_path,
'certificate_of_incorporation' => $certificate_of_incorporation_path,
'tan_allotment_letter' => $tan_allotment_letter_path ?? null,
'List_of_directors_or_authorized_signatories' => $List_of_directors_or_authorized_signatories_path ?? null,
// 'pan_card_copy_of_authorized_signatory' => $pan_card_copy_of_authorized_signatory_path,
// 'aadhar_card_copy_of_authorized_signatory' => $aadhar_card_copy_of_authorized_signatory_fileName_path,
'proof_of_address_of_the_company' => $proof_of_address_of_the_company_path ?? null,
'latest_income_tax_return_of_the_company_Of_last_2_years' => $latest_income_tax_return_of_the_company_Of_last_2_years_path ?? null,
'copy_of_cml' => $copy_of_cml_path ?? null,
'copy_of_audited_balance_sheet_for_the_last_2_f_y' => $copy_of_audited_balance_sheet_for_the_last_2_f_y_path ?? null,
// 'passport_photo_all_authorized_signatories_or_directors' => $passport_photo_all_authorized_signatories_or_directors_filepath,
'true_copy_form_32_or_dir_12_alongwith_roc_fee_payment' => $true_copy_form_32_or_dir_12_alongwith_roc_fee_payment_path ?? null,
'true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment' => $true_copy_form_no_18_or_inc_22_alongwith_roc_fee_payment_path ?? null,
'cancelled_cheque' => $cancelled_cheque_path,
];
}
public function createCompanyKYC($userId, $companyFileUpload)
{
return UserCompanyKyc::updateOrCreate([
'user_id' => $userId
], [
...$companyFileUpload
]);
}
//Partnership
public function removePreviousPartnershipFiles($userId)
{
$partnershipKycExists = PartnerShip::where('user_id', $userId)->first();
if ($partnershipKycExists) {
\Storage::exists($partnershipKycExists->true_copy_of_partnership_deed) ? \Storage::delete($partnershipKycExists->true_copy_of_partnership_deed) : '';
\Storage::exists($partnershipKycExists->registration_certificate) ? \Storage::delete($partnershipKycExists->registration_certificate) : '';
\Storage::exists($partnershipKycExists->list_of_partners_or_authorised_signatories) ? \Storage::delete($partnershipKycExists->list_of_partners_or_authorised_signatories) : '';
\Storage::exists($partnershipKycExists->pan_card) ? \Storage::delete($partnershipKycExists->pan_card) : '';
\Storage::exists($partnershipKycExists->tan_allotment_letter) ? \Storage::delete($partnershipKycExists->tan_allotment_letter) : '';
\Storage::exists($partnershipKycExists->proof_of_address_firm) ? \Storage::delete($partnershipKycExists->proof_of_address_firm) : '';
\Storage::exists($partnershipKycExists->latestIincome_tax_return_of_the_firm) ? \Storage::delete($partnershipKycExists->latestIincome_tax_return_of_the_firm) : '';
\Storage::exists($partnershipKycExists->copy_of_cml) ? \Storage::delete($partnershipKycExists->copy_of_cml) : '';
\Storage::exists($partnershipKycExists->copy_of_audited_balance_sheet_for_last) ? \Storage::delete($partnershipKycExists->copy_of_audited_balance_sheet_for_last) : '';
\Storage::exists($partnershipKycExists->cancelled_cheque) ? \Storage::delete($partnershipKycExists->cancelled_cheque) : '';
}
}
public function partnershipFileUpload($userId, $validated)
{
$true_copy_of_partnership_deed_fileName = 'true_copy_of_partnership_deed' . time() . $userId . '.' . $validated['true_copy_of_partnership_deed']->getClientOriginalExtension();
$true_copy_of_partnership_deed_path = $validated['true_copy_of_partnership_deed']->storeAs('files/images/partner_Ship/true_copy_of_partnership_deed', $true_copy_of_partnership_deed_fileName);
$registration_certificate_fileName = 'registration_certificate' . time() . $userId . '.' . $validated['registration_certificate']->getClientOriginalExtension();
$registration_certificate_path = $validated['registration_certificate']->storeAs('files/images/partner_Ship/registration_certificate', $registration_certificate_fileName);
$pan_card_fileName = 'pan_card' . time() . $userId . '.' . $validated['pan_card']->getClientOriginalExtension();
$pan_card_path = $validated['pan_card']->storeAs('files/images/partner_Ship/pan_card', $pan_card_fileName);
if (array_key_exists('list_of_partners_and_authorised_signatories', $validated)) {
$list_of_partners_and_authorised_signatories_fileName = 'list_of_partners_and_authorised_signatories' . time() . $userId . '.' . $validated['list_of_partners_and_authorised_signatories']->getClientOriginalExtension();
$list_of_partners_and_authorised_signatories_path = $validated['list_of_partners_and_authorised_signatories']->storeAs('files/images/partner_Ship/list_of_partners_and_authorised_signatories', $list_of_partners_and_authorised_signatories_fileName);
}
// $pan_card_copy_of_authorized_signatory_fileName = 'pan_card_copy_of_authorized_signatory' . $userId . '-' . time() . '.' . $validated['pan_card_copy_of_authorized_signatory->getClientOriginalExtension();
// $pan_card_copy_of_authorized_signatory_path = $validated['pan_card_copy_of_authorized_signatory->storeAs('files/images/partner_Ship/pan_card_copy_of_authorized_signatory', $pan_card_copy_of_authorized_signatory_fileName);
// $aadhar_card_copy_of_authorized_signatory_fileName = 'aadhar_card_copy_of_authorized_signatory' . $userId . '-' . time() . '.' . $validated['aadhar_card_copy_of_authorized_signatory->getClientOriginalExtension();
// $aadhar_card_copy_of_authorized_signatory_path = $validated['aadhar_card_copy_of_authorized_signatory->storeAs('files/images/partner_Ship/aadhar_card_copy_of_authorized_signatory', $aadhar_card_copy_of_authorized_signatory_fileName);
if (array_key_exists('tan_allotment_letter', $validated)) {
$tan_allotment_letter_fileName = 'tan_allotment_letter' . time() . $userId . '.' . $validated['tan_allotment_letter']->getClientOriginalExtension();
$tan_allotment_letter_path = $validated['tan_allotment_letter']->storeAs('files/images/partner_Ship/tan_allotment_letter', $tan_allotment_letter_fileName);
}
$proof_of_address_firm_fileName = 'proof_of_address_firm' . time() . $userId . '.' . $validated['proof_of_address_firm']->getClientOriginalExtension();
$proof_of_address_firm_path = $validated['proof_of_address_firm']->storeAs('files/images/partner_Ship/proof_of_address_firm', $proof_of_address_firm_fileName);
if (array_key_exists('latestIincome_tax_return_of_the_firm', $validated)) {
$latestIincome_tax_return_of_the_firmfileName = 'latestIincome_tax_return_of_the_firm' . time() . $userId . '.' . $validated['latestIincome_tax_return_of_the_firm']->getClientOriginalExtension();
$latestIincome_tax_return_of_the_firm_path = $validated['latestIincome_tax_return_of_the_firm']->storeAs('files/images/partner_Ship/latestIincome_tax_return_of_the_firm', $latestIincome_tax_return_of_the_firmfileName);
}
if (array_key_exists('copy_of_cml', $validated)) {
$copy_of_cml_fileName = 'copy_of_cml' . time() . $userId . '.' . $validated['copy_of_cml']->getClientOriginalExtension();
$copy_of_cml_path = $validated['copy_of_cml']->storeAs('files/images/partner_Ship/copy_of_cml', $copy_of_cml_fileName);
}
if (array_key_exists('copy_of_audited_balance_sheet_for_last', $validated)) {
$copy_of_audited_balance_sheet_for_last_fileName = 'copy_of_audited_balance_sheet_for_last' . time() . $userId . '.' . $validated['copy_of_audited_balance_sheet_for_last']->getClientOriginalExtension();
$copy_of_audited_balance_sheet_for_last_path = $validated['copy_of_audited_balance_sheet_for_last']->storeAs('files/images/partner_Ship/copy_of_audited_balance_sheet_for_last', $copy_of_audited_balance_sheet_for_last_fileName);
}
// $passport_photo_authorized_signatories_partners_fileName = 'passport_photo_authorized_signatories_partners' . $userId . '-' . time() . '.' . $validated['passport_photo_authorized_signatories_partners->getClientOriginalExtension();
// $passport_photo_authorized_signatories_partners_path = $validated['passport_photo_authorized_signatories_partners->storeAs('files/images/partner_Ship/copy_of_audited_balance_sheet_for_last', $passport_photo_authorized_signatories_partners_fileName);
$cancelled_cheque_fileName = 'cancelled_cheque' . time() . $userId . '.' . $validated['cancelled_cheque']->getClientOriginalExtension();
$cancelled_cheque_path = $validated['cancelled_cheque']->storeAs('files/images/partner_Ship/cancelled_cheque', $cancelled_cheque_fileName);
$panCard = $validated['pan_card_copy_of_authorized_signatory'];
$aadharCard = $validated['aadhar_card_copy_of_authorized_signatory'];
$passport = $validated['passport_photo_authorized_signatories_partners'];
$multipleFileUploads = $this->multipleFileUpload($userId, $panCard, $aadharCard, $passport);
return [
'true_copy_of_partnership_deed' => $true_copy_of_partnership_deed_path,
'registration_certificate' => $registration_certificate_path,
'pan_card' => $pan_card_path,
'list_of_partners_or_authorised_signatories' => $list_of_partners_and_authorised_signatories_path ?? null,
// 'pan_card_copy_of_authorized_signatory' => $pan_card_copy_of_authorized_signatory_path,
// 'aadhar_card_copy_of_authorized_signatory' => $aadhar_card_copy_of_authorized_signatory_path,
'tan_allotment_letter' => $tan_allotment_letter_path ?? null,
'proof_of_address_firm' => $proof_of_address_firm_path,
'latestIincome_tax_return_of_the_firm' => $latestIincome_tax_return_of_the_firm_path ?? null,
'copy_of_cml' => $copy_of_cml_path ?? null,
'copy_of_audited_balance_sheet_for_last' => $copy_of_audited_balance_sheet_for_last_path ?? null,
// 'passport_photo_authorized_signatories_partners' => $passport_photo_authorized_signatories_partners_path,
'cancelled_cheque' => $cancelled_cheque_path,
];
}
public function createPartnershipKYC($userId, $partnershipFileUpload)
{
return PartnerShip::updateOrCreate([
'user_id' => $userId
], [
...$partnershipFileUpload
]);
}
//Others
public function removePreviousOtherFiles($userId)
{
$otherKycExists = Outhers::where('user_id', $userId)->first();
if ($otherKycExists) {
\Storage::exists($otherKycExists->proof_of_identity_pan_card) ? \Storage::delete($otherKycExists->proof_of_identity_pan_card) : '';
\Storage::exists($otherKycExists->addressproof_bank_statement_or_utility_bill) ? \Storage::delete($otherKycExists->addressproof_bank_statement_or_utility_bill) : '';
\Storage::exists($otherKycExists->certificate_of_registration) ? \Storage::delete($otherKycExists->certificate_of_registration) : '';
\Storage::exists($otherKycExists->list_of_authorised_signatories) ? \Storage::delete($otherKycExists->list_of_authorised_signatories) : '';
\Storage::exists($otherKycExists->cancelled_cheque) ? \Storage::delete($otherKycExists->cancelled_cheque) : '';
\Storage::exists($otherKycExists->cml_copy) ? \Storage::delete($otherKycExists->cml_copy) : '';
\Storage::exists($otherKycExists->latest_income_tax_return) ? \Storage::delete($otherKycExists->latest_income_tax_return) : '';
\Storage::exists($otherKycExists->copy_of_audited_balance_sheet_for_the_last_2_F_Y) ? \Storage::delete($otherKycExists->copy_of_audited_balance_sheet_for_the_last_2_F_Y) : '';
}
}
public function otherFileUpload($userId, $validated)
{
$proof_of_identity_pan_card_fileName = 'proof_of_identity_pan_card' . time() . $userId . '.' . $validated['proof_of_identity_pan_card']->getClientOriginalExtension();
$proof_of_identity_pan_card_path = $validated['proof_of_identity_pan_card']->storeAs('files/images/outher/proof_of_identity_pan_card', $proof_of_identity_pan_card_fileName);
$addressproof_bank_statement_or_utility_bill_fileName = 'addressproof_bank_statement_or_utility_bill' . time() . $userId . '.' . $validated['addressproof_bank_statement_or_utility_bill']->getClientOriginalExtension();
$addressproof_bank_statement_or_utility_bill_path = $validated['addressproof_bank_statement_or_utility_bill']->storeAs('files/images/outher/registration_certificate', $addressproof_bank_statement_or_utility_bill_fileName);
if (array_key_exists('certificate_of_registration', $validated)) {
$certificate_of_registration_fileName = 'certificate_of_registration' . time() . $userId . '.' . $validated['certificate_of_registration']->getClientOriginalExtension();
$certificate_of_registration_path = $validated['certificate_of_registration']->storeAs('files/images/outher/certificate_of_registration', $certificate_of_registration_fileName);
}
if (array_key_exists('list_of_authorised_signatories', $validated)) {
$list_of_authorised_signatories_fileName = 'list_of_authorised_signatories' . time() . $userId . '.' . $validated['list_of_authorised_signatories']->getClientOriginalExtension();
$list_of_partners_and_authorised_signatories_path = $validated['list_of_authorised_signatories']->storeAs('files/images/outher/list_of_authorised_signatories', $list_of_authorised_signatories_fileName);
}
// $pan_card_copy_of_authorized_signatory_fileName = 'pan_card_copy_of_authorized_signatory' . $userId . '-' . time() . '.' . $validated['pan_card_copy_of_authorized_signatory->getClientOriginalExtension();
// $pan_card_copy_of_authorized_signatory_path = $validated['pan_card_copy_of_authorized_signatory->storeAs('files/images/outher/pan_card_copy_of_authorized_signatory', $pan_card_copy_of_authorized_signatory_fileName);
// $aadhar_card_copy_of_authorized_signatory_fileName = 'aadhar_card_copy_of_authorized_signatory' . $userId . '-' . time() . '.' . $validated['aadhar_card_copy_of_authorized_signatory->getClientOriginalExtension();
// $aadhar_card_copy_of_authorized_signatory_path = $validated['aadhar_card_copy_of_authorized_signatory->storeAs('files/images/outher/aadhar_card_copy_of_authorized_signatory', $aadhar_card_copy_of_authorized_signatory_fileName);
$cancelled_cheque_fileName = 'cancelled_cheque' . time() . $userId . '.' . $validated['cancelled_cheque']->getClientOriginalExtension();
$cancelled_cheque_path = $validated['cancelled_cheque']->storeAs('files/images/outher/tan_allotment_letter', $cancelled_cheque_fileName);
$cml_copy_fileName = 'cml_copy' . time() . $userId . '.' . $validated['cml_copy']->getClientOriginalExtension();
$cml_copy_path = $validated['cml_copy']->storeAs('files/images/outher/cml_copy', $cml_copy_fileName);
if (array_key_exists('latest_income_tax_return', $validated)) {
$latest_income_tax_return_fileName = 'latest_income_tax_return' . time() . $userId . '.' . $validated['latest_income_tax_return']->getClientOriginalExtension();
$latest_income_tax_return_path = $validated['latest_income_tax_return']->storeAs('files/images/latest_income_tax_return', $latest_income_tax_return_fileName);
}
if (array_key_exists('copy_of_audited_balance_sheet_for_the_last_2_F_Y', $validated)) {
$copy_of_audited_balance_sheet_for_the_last_2_F_Y_fileName = 'copy_of_audited_balance_sheet_for_the_last_2_F_Y' . time() . $userId . '.' . $validated['copy_of_audited_balance_sheet_for_the_last_2_F_Y']->getClientOriginalExtension();
$copy_of_audited_balance_sheet_for_the_last_2_F_Y_path = $validated['copy_of_audited_balance_sheet_for_the_last_2_F_Y']->storeAs('files/images/outher/copy_of_audited_balance_sheet_for_the_last_2_F_Y', $copy_of_audited_balance_sheet_for_the_last_2_F_Y_fileName);
}
// $passport_photo_signed_authorized_signatories_or_directors_fileName = 'passport_photo_signed_authorized_signatories_or_directors' . $userId . '-' . time() . '.' . $validated['passport_photo_signed_authorized_signatories_or_directors->getClientOriginalExtension();
// $passport_photo_signed_authorized_signatories_or_directors_path = $validated['passport_photo_signed_authorized_signatories_or_directors->storeAs('files/images/outher/passport_photo_signed_authorized_signatories_or_directors', $passport_photo_signed_authorized_signatories_or_directors_fileName);
// $panCard = $request->hasfile('pan_card_copy_of_authorized_signatory') == false ? '' : $request->file('pan_card_copy_of_authorized_signatory');
// $aadharCard = $request->hasfile('aadhar_card_copy_of_authorized_signatory') == false ? '' : $request->file('aadhar_card_copy_of_authorized_signatory');
// $passport = $request->hasfile('passport_photo_signed_authorized_signatories_or_directors') == false ? '' : $request->file('passport_photo_signed_authorized_signatories_or_directors');
$panCard = $validated['pan_card_copy_of_authorized_signatory'];
$aadharCard = $validated['aadhar_card_copy_of_authorized_signatory'];
$passport = $validated['passport_photo_signed_authorized_signatories_or_directors'];
$multipleFileUploads = $this->multipleFileUpload($userId, $panCard, $aadharCard, $passport);
return [
'proof_of_identity_pan_card' => $proof_of_identity_pan_card_path,
'addressproof_bank_statement_or_utility_bill' => $addressproof_bank_statement_or_utility_bill_path,
'certificate_of_registration' => $certificate_of_registration_path ?? null,
'list_of_authorised_signatories' => $list_of_partners_and_authorised_signatories_path ?? null,
// 'pan_card_copy_of_authorized_signatory' => $pan_card_copy_of_authorized_signatory_path,
// 'aadhar_card_copy_of_authorized_signatory' => $aadhar_card_copy_of_authorized_signatory_path,
'cancelled_cheque' => $cancelled_cheque_path,
'cml_copy' => $cml_copy_path,
'latest_income_tax_return' => $latest_income_tax_return_path ?? null,
'copy_of_audited_balance_sheet_for_the_last_2_F_Y' => $copy_of_audited_balance_sheet_for_the_last_2_F_Y_path ?? null,
// 'passport_photo_signed_authorized_signatories_or_directors' => $passport_photo_signed_authorized_signatories_or_directors_path,
];
}
public function createOtherKYC($userId, $otherFileUpload)
{
return Outhers::updateOrCreate([
'user_id' => $userId
], [
...$otherFileUpload
]);
}
}