add whatsup logic

This commit is contained in:
root
2026-03-10 16:31:35 -04:00
parent 20ee70d153
commit 3bf4c687da
33 changed files with 2800 additions and 1329 deletions
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Resources\Whatsapp;
use Illuminate\Http\Resources\Json\JsonResource;
class WhatsappClassSectionContactResource extends JsonResource
{
public function toArray($request): array
{
return [
'class_section_id' => (int) ($this['class_section_id'] ?? 0),
'class_section_name' => (string) ($this['class_section_name'] ?? ''),
'semester' => (string) ($this['semester'] ?? ''),
'school_year' => (string) ($this['school_year'] ?? ''),
'description' => (string) ($this['description'] ?? ''),
'main_teachers' => array_values($this['main_teachers'] ?? []),
'teacher_assistants' => array_values($this['teacher_assistants'] ?? []),
'parents' => WhatsappClassSectionParentResource::collection($this['parents'] ?? []),
];
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources\Whatsapp;
use Illuminate\Http\Resources\Json\JsonResource;
class WhatsappClassSectionParentResource extends JsonResource
{
public function toArray($request): array
{
return [
'class_section_id' => (int) ($this['class_section_id'] ?? 0),
'primary_id' => (int) ($this['primary_id'] ?? 0),
'primary_name' => (string) ($this['primary_name'] ?? ''),
'primary_phone' => (string) ($this['primary_phone'] ?? ''),
'primary_email' => (string) ($this['primary_email'] ?? ''),
'second_id' => (int) ($this['second_id'] ?? 0),
'second_name' => (string) ($this['second_name'] ?? ''),
'second_phone' => (string) ($this['second_phone'] ?? ''),
'second_email' => (string) ($this['second_email'] ?? ''),
'primary_member' => $this['primary_member'] ?? null,
'second_member' => $this['second_member'] ?? null,
];
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources\Whatsapp;
use Illuminate\Http\Resources\Json\ResourceCollection;
class WhatsappGroupLinkCollection extends ResourceCollection
{
public $collects = WhatsappGroupLinkResource::class;
public function toArray($request): array
{
return parent::toArray($request);
}
public function with($request): array
{
return [
'meta' => [
'total' => $this->resource->total() ?? null,
'per_page' => $this->resource->perPage() ?? null,
'current_page' => $this->resource->currentPage() ?? null,
'last_page' => $this->resource->lastPage() ?? null,
],
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Resources\Whatsapp;
use Illuminate\Http\Resources\Json\JsonResource;
class WhatsappGroupLinkResource extends JsonResource
{
public function toArray($request): array
{
return [
'id' => (int) ($this->id ?? 0),
'class_section_id' => (int) ($this->class_section_id ?? 0),
'class_section_name' => (string) ($this->class_section_name ?? ''),
'school_year' => (string) ($this->school_year ?? ''),
'semester' => (string) ($this->semester ?? ''),
'invite_link' => (string) ($this->invite_link ?? ''),
'active' => (bool) ($this->active ?? false),
'created_at' => $this->created_at ?? null,
'updated_at' => $this->updated_at ?? null,
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Resources\Whatsapp;
use Illuminate\Http\Resources\Json\JsonResource;
class WhatsappParentContactResource extends JsonResource
{
public function toArray($request): array
{
return [
'firstname' => (string) ($this['firstname'] ?? ''),
'lastname' => (string) ($this['lastname'] ?? ''),
'email' => (string) ($this['email'] ?? ''),
'phone' => (string) ($this['phone'] ?? ''),
'type' => (string) ($this['type'] ?? ''),
];
}
}