feat: Add banner management functionality

- Implemented a new Banner model to represent banner data.
- Created a BannerRepository for database interactions related to banners.
- Developed a BannerService to handle business logic for banners.
- Added admin views for listing and adding banners.
- Integrated banner hooks for frontend rendering and click tracking.
- Created frontend styles and scripts for banner display and interaction.
- Updated database migrations to include a new banners table.
- Enhanced AdminController to manage banner actions and pages.
This commit is contained in:
2026-05-05 01:03:05 +03:30
parent 5930c1ad6f
commit 32c065e4b6
15 changed files with 1350 additions and 4 deletions

64
app/Models/Banner.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
namespace Sodino\Models;
/**
* Banner Model
*/
class Banner {
public $id;
public $title;
public $content_type;
public $content_value;
public $link_url;
public $position;
public $display_type;
public $start_time;
public $end_time;
public $user_target;
public $device_target;
public $priority;
public $status;
public $impressions;
public $clicks;
public $created_at;
public function __construct($data = []) {
$this->id = $data['id'] ?? null;
$this->title = $data['title'] ?? '';
$this->content_type = $data['content_type'] ?? 'image';
$this->content_value = $data['content_value'] ?? '';
$this->link_url = $data['link_url'] ?? '';
$this->position = $data['position'] ?? 'top';
$this->display_type = $data['display_type'] ?? 'inline';
$this->start_time = $data['start_time'] ?? null;
$this->end_time = $data['end_time'] ?? null;
$this->user_target = $data['user_target'] ?? 'all';
$this->device_target = $data['device_target'] ?? 'all';
$this->priority = isset($data['priority']) ? (int) $data['priority'] : 10;
$this->status = isset($data['status']) ? (int) $data['status'] : 1;
$this->impressions = isset($data['impressions']) ? (int) $data['impressions'] : 0;
$this->clicks = isset($data['clicks']) ? (int) $data['clicks'] : 0;
$this->created_at = $data['created_at'] ?? null;
}
public function toArray() {
return [
'id' => $this->id,
'title' => $this->title,
'content_type' => $this->content_type,
'content_value' => $this->content_value,
'link_url' => $this->link_url,
'position' => $this->position,
'display_type' => $this->display_type,
'start_time' => $this->start_time,
'end_time' => $this->end_time,
'user_target' => $this->user_target,
'device_target' => $this->device_target,
'priority' => $this->priority,
'status' => $this->status,
'impressions' => $this->impressions,
'clicks' => $this->clicks,
'created_at' => $this->created_at,
];
}
}