169 lines
4.8 KiB
PHP
169 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\frontend;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Invoice;
|
|
use App\Models\Discount;
|
|
use App\Models\InvoiceItem;
|
|
use App\Models\ModuleDomain;
|
|
use App\Models\ModuleHosting;
|
|
use App\Models\ModuleVmware;
|
|
use App\Models\Post;
|
|
use App\Models\Ticket;
|
|
use App\Repositories\Discount\DiscountRepositoryInterface;
|
|
use App\Repositories\Invoice\InvoiceRepositoryInterface;
|
|
use App\Repositories\InvoiceItem\InvoiceItemRepositoryInterface;
|
|
use App\Repositories\Module\Domain\DomainRepositoryInterface;
|
|
use App\Repositories\Module\Hosting\HostingRepository;
|
|
use App\Repositories\Module\Vmware\VmwareRepositoryInterface;
|
|
use App\Repositories\Post\PostRepositoryInterface;
|
|
use App\Repositories\Ticket\TicketRepositoryInterface;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class MainController extends Controller
|
|
{
|
|
public function __construct(
|
|
public DomainRepositoryInterface $moduleDomainRepository,
|
|
public InvoiceRepositoryInterface $invoiceRepository,
|
|
public TicketRepositoryInterface $ticketRepository,
|
|
public DiscountRepositoryInterface $discountRepository,
|
|
public PostRepositoryInterface $postRepository,
|
|
public InvoiceItemRepositoryInterface $invoiceItemRepository,
|
|
public VmwareRepositoryInterface $vmwareRepository,
|
|
public HostingRepository $moduleHostingRepository
|
|
|
|
)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
$domain = $this->moduleDomainRepository->filter(
|
|
[
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 0
|
|
]
|
|
);
|
|
|
|
$invocie_unpaid = $this->invoiceRepository->filter(
|
|
[
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 0
|
|
]
|
|
);
|
|
|
|
$ticket = $this->ticketRepository->filter(
|
|
[
|
|
'customer' => auth('users')->id()
|
|
]
|
|
)->unique('ticket_num');
|
|
|
|
$discount = $this->discountRepository->filter(
|
|
[
|
|
'status' => 'active',
|
|
'end' => [
|
|
'key' => 'end',
|
|
'condition' => '>',
|
|
'value' => Carbon::now()->timestamp
|
|
]
|
|
]
|
|
);
|
|
|
|
$posts = $this->postRepository->filter([
|
|
'published' => 1,
|
|
'limit' => 4
|
|
]);
|
|
|
|
$vmware = $this->vmwareRepository->filter([
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 1
|
|
]);
|
|
$hosting = $this->moduleHostingRepository->filter([
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 1
|
|
]);
|
|
|
|
$title = "Khu vực khách hàng";
|
|
return view('frontend.home', compact(
|
|
'domain',
|
|
'discount',
|
|
'invocie_unpaid',
|
|
'ticket',
|
|
'title',
|
|
'posts',
|
|
'vmware',
|
|
'hosting'
|
|
));
|
|
}
|
|
|
|
public function index_new()
|
|
{
|
|
$title = "Khu vực khách hàng";
|
|
$domain = $this->moduleDomainRepository->filter(
|
|
[
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 0
|
|
]
|
|
);
|
|
|
|
$invocie_unpaid = $this->invoiceRepository->filter(
|
|
[
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 0
|
|
]
|
|
);
|
|
|
|
$ticket = $this->ticketRepository->filter(
|
|
[
|
|
'customer' => auth('users')->id()
|
|
]
|
|
)->unique('ticket_num');
|
|
|
|
$discount = $this->discountRepository->filter(
|
|
[
|
|
'status' => 'active',
|
|
'end' => [
|
|
'key' => 'end',
|
|
'condition' => '>',
|
|
'value' => Carbon::now()->timestamp
|
|
]
|
|
]
|
|
);
|
|
|
|
$posts = $this->postRepository->filter([
|
|
'published' => 1,
|
|
'limit' => 4
|
|
]);
|
|
|
|
$vmware = $this->vmwareRepository->filter([
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 1
|
|
]);
|
|
|
|
|
|
$hosting = $this->moduleHostingRepository->filter([
|
|
'customer_id' => auth('users')->id(),
|
|
'status' => 1
|
|
]);
|
|
|
|
return view(
|
|
"frontend.home.index",
|
|
[
|
|
'title' => $title,
|
|
'breadcrumbs' => $this->crums->add(__('Dashboard'))->add(__('Khu vực khách hàng')),
|
|
'domain' => $domain,
|
|
'discount' => $discount,
|
|
'invocie_unpaid' => $invocie_unpaid,
|
|
'ticket' => $ticket,
|
|
'posts' => $posts,
|
|
'vmware' => $vmware,
|
|
'hosting' => $hosting
|
|
]
|
|
);
|
|
}
|
|
}
|