mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 23:43:58 +00:00
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
|
|
use App\Classes\Exceptions\ErrorException;
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FetchCompanyActivityRating extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* FetchCompanyActivityRating constructor.
|
|
* @param FetchesCompany $fetchesCompany
|
|
*/
|
|
public function __construct(FetchesCompany $fetchesCompany)
|
|
{
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
}
|
|
|
|
|
|
protected function notification(): array
|
|
{
|
|
return [
|
|
'title' => 'Fetch Company Activity Rating',
|
|
'message' => 'You have successfully fetched company activity rating'
|
|
];
|
|
}
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
protected function logic(Request $request): JsonResponse
|
|
{
|
|
// TODO: Implement logic() method.
|
|
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
|
|
|
$last_booking = $company->bookings()->oldest()->first();
|
|
// $last_activity = date_format($last_booking->created_at, "Y/m/d H:i:s");
|
|
$last_activity = $last_booking->created_at;
|
|
$days_activity = date_diff($last_activity, date_create("now"))->format("%a");
|
|
|
|
$start_date = $company->created_at;
|
|
$date_age = date_diff($start_date,date_create('now'))->format("%a");
|
|
|
|
// not sure about the calculations
|
|
|
|
// dd($days_activity);
|
|
// return $this->response(['activity_rating' => $normalized]);
|
|
}
|
|
}
|