Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Console/Commands/CalculateRent.php
Назад
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use App\Repositories\UserRepository; use App\Repositories\PaymentRepository; use App\Models\User; use App\Models\RentPayment; class CalculateRent extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'app:calculate-rent'; /** * The console command description. * * @var string */ protected $description = 'This command calculates the rent for a tenant & Stores into database'; /** * Execute the console command. */ public function handle() { //Manually Fetch each unit's payment dua and store in the database $userRepoObj = new UserRepository; $payment_repoObj = new PaymentRepository; $tenants_with_units = $userRepoObj->getAssignedTenants(); foreach($tenants_with_units as $tenant){ $payment_record = $payment_repoObj->getLastRentPaymentRecord($tenant->unit->id,$tenant->tenant->id); if($payment_record == null){ // Which means there is no records and there should be one in rent_payment table //store in table $renting['user_id'] = $tenant->tenant->id; $renting['unit_id'] = $tenant->unit->id; $rent_due_dat = $tenant->unit->rent_due_date; $date = \Carbon\Carbon::parse($rent_due_dat); $current_date = now(); $renting['month'] = $current_date->format('m'); $renting['year'] = $date->format('Y'); $renting['amount_due'] = $tenant->unit->monthly_rent ?? 0; $renting['amount_paid'] = 0; $renting['status'] = 'active'; $renting['created_at'] = now(); RentPayment::create($renting); } } $this->info('Successfully Ran Calculate Command, rent_payment table populated.'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка