first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,141 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Modules\Client\Interfaces\ClientInterface;
use Modules\Content\Interfaces\ContentInterface;
use Modules\Content\Models\Content;
use Modules\Meeting\Models\Event;
use Modules\Meeting\Models\Meeting;
use Modules\Meeting\Repositories\EventInterface;
use Modules\Meeting\Repositories\MeetingInterface;
use Modules\Product\Interfaces\ProductInterface;
class CalendarController extends Controller
{
private $event;
private $content;
private $meeting;
private $employee;
private $client;
private $product;
public function __construct(
EventInterface $event,
MeetingInterface $meeting,
ContentInterface $content,
ProductInterface $product,
ClientInterface $client
) {
$this->event = $event;
$this->meeting = $meeting;
$this->content = $content;
$this->client = $client;
$this->product = $product;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Calendar';
$data['events'] = $this->event->findAll();
$data['meetings'] = $this->meeting->findAll();
$data['contents'] = $this->content->findAllUpcomingScheduledContent();
$data['productOptions'] = $this->product->pluck();
$data['clientList'] = $this->client->pluck();
return view('calendar.index', $data);
}
public function calendarByAjax(Request $request)
{
$filters['start_date'] = $request->start;
$filters['end_date'] = $request->end;
$filters['product_id'] = $request->product_id;
$list = [];
$events = Event::when($filters, function ($query) use ($filters) {
if (isset($filters["start_date"])) {
$query->whereDate("start_date", ">=", $filters["start_date"]);
}
if (isset($filters["end_date"])) {
$query->whereDate("end_date", "<=", $filters["end_date"]);
$query->orWhereNull("end_date");
}
})->get();
foreach ($events as $event) {
$list[] = [
"id" => $event->id,
"title" => $event->title,
"type" => 'event',
"start" => $event->start_date,
"end" => $event->end_date,
"className" => "bg-primary",
"desc" => $event->description,
"location" => $event->location,
'allDay' => true,
];
}
$contents = Content::where('status', '!=', 11)
->when($filters, function ($query) use ($filters) {
if (isset($filters["start_date"])) {
$query->whereDate("release_date", ">=", $filters["start_date"]);
}
if (isset($filters["end_date"])) {
$query->where(function ($q) use ($filters) {
$q->whereDate("release_date", "<=", $filters["end_date"])
->orWhereNull("release_date");
});
}
if (isset($filters["product_id"])) {
$query->where("product_id", $filters["product_id"]);
}
})
->with(['product.client'])
->get();
foreach ($contents as $content) {
$list[] = [
"id" => $content->id,
"title" => $content->title,
"type" => 'content schedule',
"start" => Carbon::parse($content->getRawOriginal('release_date') . ' ' . $content->getRawOriginal('release_time')),
"end" => null,
"className" => "bg-success",
"location" => null,
"desc" => $content->product?->client?->name,
'allDay' => false,
];
}
$meetings = Meeting::when($filters, function ($query) use ($filters) {
if (isset($filters["start_date"])) {
$query->whereDate("date", ">=", $filters["start_date"]);
}
})->get();
foreach ($meetings as $meeting) {
$list[] = [
"id" => $meeting->id,
"title" => $meeting->title,
"type" => 'meeting',
"start" => Carbon::parse($meeting->getRawOriginal('date') . ' ' . $meeting->getRawOriginal('start_time')),
"location" => $meeting->location,
"desc" => $meeting->description,
"className" => "bg-warning",
'allDay' => false,
];
}
return $list;
}
}