fix the user ui, create delivery order, delivery customer dashboard

This commit is contained in:
omair saleh
2022-04-03 19:10:06 +08:00
parent 745655dbfa
commit c69c043576
60 changed files with 1528 additions and 556 deletions
+3 -3
View File
@@ -18,7 +18,7 @@ class CompanyResource extends JsonResource
*/
public function toArray($request)
{
$companyModule = $this->companyModules()->where('type', '=', BusinessType::IMPORTER)->first();
$companyModule = $this->companyModules()->first();
return [
'id' => $this->id,
'hash_id' => Crypt::encryptString($this->id),
@@ -30,8 +30,8 @@ class CompanyResource extends JsonResource
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
'employee' => new UserResource($companyModule->employees()->first()),
'company_module' => new CompanyModuleResource($companyModule),
'last_order' => new OrderResource($companyModule ? $companyModule->orders()->orderBy('id', 'DESC')->first(): null),
'order_count' => $this->orders()->count(),
'last_order' => $companyModule->type === 7 ? new DeliveryOrderResource($companyModule->orders()->orderBy('id', 'DESC')->first()) : new OrderResource($companyModule->orders()->orderBy('id', 'DESC')->first()),
'order_count' => $companyModule->orders()->count(),
'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->first()),
'created_at' => $this->created_at->format('d-m-Y')