New Yoga
This commit is contained in:
parent
b74dc3d017
commit
04dd1c2804
@ -1,18 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
66
.env.example
66
.env.example
@ -1,66 +0,0 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_TIMEZONE=UTC
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=simedkom_rebuild
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
11
.gitattributes
vendored
11
.gitattributes
vendored
@ -1,11 +0,0 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
28
.gitignore
vendored
28
.gitignore
vendored
@ -1,28 +0,0 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/storage/app/public/
|
||||
/storage/framework/
|
||||
/storage/logs/
|
||||
/vendor
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
.VSCodeCounter
|
||||
@ -1,34 +0,0 @@
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
IMAGE_NAME: purwakarta-diskominfo-simedkom
|
||||
IMAGE_TAG: v1.0.0
|
||||
CONTAINER_NAME: purwakarta-diskominfo-simedkom
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
tags:
|
||||
- docker
|
||||
script:
|
||||
- docker info
|
||||
- docker build -t $IMAGE_NAME:$IMAGE_TAG .
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
tags:
|
||||
- docker
|
||||
before_script:
|
||||
- echo -e "$ENV_FILE" > .env
|
||||
script:
|
||||
- docker compose down || true
|
||||
- docker compose up -d --build
|
||||
only:
|
||||
- main
|
||||
28
Dockerfile
28
Dockerfile
@ -1,28 +0,0 @@
|
||||
FROM dunglas/frankenphp:latest
|
||||
|
||||
ENV SERVER_NAME=":80"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy project ke dalam container
|
||||
COPY . /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libfreetype6-dev \
|
||||
libzip-dev \
|
||||
libicu-dev \
|
||||
pkg-config \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install gd \
|
||||
&& docker-php-ext-install pdo pdo_mysql zip bcmath intl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
RUN composer install --no-dev --optimize-autoloader && \
|
||||
composer clear-cache
|
||||
|
||||
@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Company;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CompanyExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $status;
|
||||
|
||||
protected $edit_status;
|
||||
|
||||
protected $address;
|
||||
|
||||
protected $register_year;
|
||||
|
||||
protected $register_month;
|
||||
|
||||
protected $register_date;
|
||||
|
||||
public function __construct($status, $edit_status, $address, $register_year, $register_month, $register_date)
|
||||
{
|
||||
$this->status = $status;
|
||||
$this->edit_status = $edit_status;
|
||||
$this->address = $address;
|
||||
$this->register_year = $register_year;
|
||||
$this->register_month = $register_month;
|
||||
$this->register_date = $register_date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Company::with(['user']);
|
||||
|
||||
if ($this->status !== 'all') {
|
||||
if ($this->status === 'waiting') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '0');
|
||||
});
|
||||
} elseif ($this->status === 'accepted') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '1');
|
||||
});
|
||||
} elseif ($this->status === 'rejected') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '2');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->edit_status !== 'all') {
|
||||
if ($this->edit_status === 'no-edit') {
|
||||
$query->where('edit_status', '0');
|
||||
} elseif ($this->edit_status === 'waiting') {
|
||||
$query->where('edit_status', '1');
|
||||
} elseif ($this->edit_status === 'accepted') {
|
||||
$query->where('edit_status', '2');
|
||||
} elseif ($this->edit_status === 'rejected') {
|
||||
$query->where('edit_status', '3');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->address) {
|
||||
$query->where('address', 'LIKE', '%'.$this->address.'%');
|
||||
}
|
||||
|
||||
if ($this->register_year) {
|
||||
$query->whereYear('created_at', $this->register_year);
|
||||
}
|
||||
|
||||
if ($this->register_month) {
|
||||
$monthYear = Carbon::parse($this->register_month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->register_date) {
|
||||
$query->whereDate('created_at', $this->register_date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($company): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$company->name,
|
||||
$company->email,
|
||||
$company->director_name,
|
||||
$company->address,
|
||||
get_user_status($company->user->status),
|
||||
get_edit_status($company->edit_status),
|
||||
Carbon::parse($company->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
Carbon::parse($company->validated_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Perusahaan', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Perusahaan', 'Email', 'Direktur', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:I1'); // A1 sampai I1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:I1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:I1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('I')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:I1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:I1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\ContentRecap;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ContentRecapExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $classification;
|
||||
|
||||
protected $channel;
|
||||
|
||||
protected $social_media;
|
||||
|
||||
protected $content_type;
|
||||
|
||||
protected $posted_year;
|
||||
|
||||
protected $posted_month;
|
||||
|
||||
protected $posted_date;
|
||||
|
||||
public function __construct($classification, $channel, $social_media, $content_type, $posted_year, $posted_month, $posted_date)
|
||||
{
|
||||
$this->classification = $classification;
|
||||
$this->channel = $channel;
|
||||
$this->social_media = $social_media;
|
||||
$this->content_type = $content_type;
|
||||
$this->posted_year = $posted_year;
|
||||
$this->posted_month = $posted_month;
|
||||
$this->posted_date = $posted_date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = ContentRecap::with(['enhancer', 'classification']);
|
||||
|
||||
if ($this->classification && $this->classification !== 'all') {
|
||||
$query->where('classification_id', decrypt_id($this->classification));
|
||||
}
|
||||
|
||||
if ($this->channel && $this->channel !== 'all') {
|
||||
$query->where('channel', $this->channel);
|
||||
}
|
||||
|
||||
if ($this->social_media && $this->social_media !== 'all') {
|
||||
$query->where('social_media', $this->social_media);
|
||||
}
|
||||
|
||||
if ($this->content_type && $this->content_type !== 'all') {
|
||||
$query->where('content_type', 'LIKE', '%'.$this->content_type.'%');
|
||||
}
|
||||
|
||||
if ($this->posted_year) {
|
||||
$query->whereYear('posted_date', $this->posted_year);
|
||||
}
|
||||
|
||||
if ($this->posted_month) {
|
||||
$monthYear = Carbon::parse($this->posted_month);
|
||||
$query->whereYear('posted_date', $monthYear->year)
|
||||
->whereMonth('posted_date', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->posted_date) {
|
||||
$query->whereDate('posted_date', $this->posted_date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($contentRecap): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$contentRecap->content_theme,
|
||||
$contentRecap->link,
|
||||
$contentRecap->classification->name,
|
||||
$contentRecap->social_media,
|
||||
filled($contentRecap->content_type) ? titlefy($contentRecap->content_type) : '-',
|
||||
Carbon::parse($contentRecap->posted_date)->locale('id')->translatedFormat('l, d F Y'),
|
||||
$contentRecap->channel,
|
||||
filled($contentRecap->description) ? strip_tags($contentRecap->description) : 'Tidak ada',
|
||||
Carbon::parse($contentRecap->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Rekap Konten', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Tema Konten', 'Link', 'Klasifikasi', 'Media Sosial', 'Jenis Konten', 'Tanggal Posting', 'Channel', 'Deskripsi', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:I1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:J1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:I1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('I')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('J')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:I1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:I1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Cooperation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CooperationArchiveExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($year, $month, $date)
|
||||
{
|
||||
$this->year = $year;
|
||||
$this->month = $month;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Cooperation::with(['media', 'mediaOrder']);
|
||||
|
||||
if (is_role(['1'])) {
|
||||
// Hanya untuk role 1: filter kerja sama lebih dari 1 tahun
|
||||
if (! $this->year && ! $this->month && ! $this->date) {
|
||||
$query->where('created_at', '<=', Carbon::now()->subYear());
|
||||
}
|
||||
} elseif (is_role(['3'])) {
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
|
||||
$query->whereHas('proposals', function ($query) use ($mediaId) {
|
||||
$query->where('status', 1)->where('media_id', $mediaId);
|
||||
});
|
||||
|
||||
if (! $this->year && ! $this->month && ! $this->date) {
|
||||
$query->where('created_at', '<=', Carbon::now()->subYear());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->year) {
|
||||
$query->whereYear('created_at', $this->year);
|
||||
}
|
||||
|
||||
if ($this->month) {
|
||||
$monthYear = Carbon::parse($this->month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->date) {
|
||||
$query->whereDate('created_at', $this->date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($cooperationArchive): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$cooperationArchive->name,
|
||||
Carbon::parse($cooperationArchive->start_date)->locale('id')->translatedFormat('l, d F Y'),
|
||||
Carbon::parse($cooperationArchive->end_date)->locale('id')->translatedFormat('l, d F Y'),
|
||||
strip_tags($cooperationArchive->description),
|
||||
Carbon::parse($cooperationArchive->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Rekap Konten', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Taanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:I1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:J1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:F1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:F1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:F1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,130 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\CooperationCompletion;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CooperationCompletionExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $media;
|
||||
|
||||
protected $status;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $from_month;
|
||||
|
||||
protected $to_month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($media, $status, $year, $from_month, $to_month, $date)
|
||||
{
|
||||
$this->media = $media;
|
||||
$this->status = $status;
|
||||
$this->year = $year;
|
||||
$this->from_month = $from_month;
|
||||
$this->to_month = $to_month;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = CooperationCompletion::with(['media.company']);
|
||||
} elseif (is_role(['3'])) {
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
$query = CooperationCompletion::with(['media.company', 'order.cooperation'])->where('media_id', '=', $mediaId);
|
||||
}
|
||||
|
||||
if (! empty($this->media[0])) {
|
||||
$query->whereIn('media_id', $this->media);
|
||||
}
|
||||
|
||||
if ($this->status) {
|
||||
switch ($this->status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
case 'accepted':
|
||||
$query->where('status', '1');
|
||||
break;
|
||||
case 'rejected':
|
||||
$query->where('status', '2');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->year) {
|
||||
$query->whereYear('created_at', $this->year);
|
||||
}
|
||||
|
||||
if ($this->from_month && $this->to_month) {
|
||||
$start = Carbon::parse($this->from_month)->startOfMonth();
|
||||
$end = Carbon::parse($this->to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
|
||||
if ($this->date) {
|
||||
$query->whereDate('created_at', $this->date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($report): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$report->order->cooperation->name,
|
||||
$report->media->name,
|
||||
$report->media->company->name,
|
||||
Carbon::parse($report->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
$report->status === '0' ? 'Menunggu' : ($report->status === '1' ? 'Diterima' : 'Ditolak'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Penyelesaian Kerja Sama', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Media', 'Perusahaan', 'Tanggal Upload', 'Status'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:F1'); // A1 sampai F1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:F1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:F1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getStyle('F:F')->getAlignment()->setWrapText(true);
|
||||
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:F1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:F1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Cooperation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CooperationExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($year, $month, $date)
|
||||
{
|
||||
$this->year = $year;
|
||||
$this->month = $month;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Cooperation::with(['media', 'mediaOrder']);
|
||||
|
||||
if (is_role(['3'])) {
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
|
||||
$query->whereHas('proposals', function ($q) use ($mediaId) {
|
||||
$q->where('status', 1)
|
||||
->where('media_id', $mediaId);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->year) {
|
||||
$query->whereYear('created_at', $this->year);
|
||||
}
|
||||
|
||||
if ($this->month) {
|
||||
$monthYear = Carbon::parse($this->month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->date) {
|
||||
$query->whereDate('created_at', $this->date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($cooperation): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$cooperation->name,
|
||||
Carbon::parse($cooperation->start_date)->locale('id')->translatedFormat('l, d F Y'),
|
||||
Carbon::parse($cooperation->end_date)->locale('id')->translatedFormat('l, d F Y'),
|
||||
strip_tags($cooperation->description),
|
||||
$cooperation->media->pluck('name')->implode(', '),
|
||||
Carbon::parse($cooperation->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Rekap Konten', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Tanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Media', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:G1'); // A1 sampai G1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:G1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:G1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getStyle('F:F')->getAlignment()->setWrapText(true);
|
||||
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:G1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:G1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,218 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\IssueManagement;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class IssueManagementExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $classification;
|
||||
|
||||
protected $sub_classification;
|
||||
|
||||
protected $location;
|
||||
|
||||
protected $sub_location;
|
||||
|
||||
protected $government_agency;
|
||||
|
||||
protected $issue;
|
||||
|
||||
protected $response;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
protected $start_date;
|
||||
|
||||
protected $end_date;
|
||||
|
||||
protected $user;
|
||||
|
||||
public function __construct(
|
||||
$classification,
|
||||
$sub_classification,
|
||||
$location,
|
||||
$sub_location,
|
||||
$government_agency,
|
||||
$issue,
|
||||
$response,
|
||||
$year,
|
||||
$month,
|
||||
$date,
|
||||
$start_date,
|
||||
$end_date,
|
||||
$user
|
||||
) {
|
||||
$this->classification = $classification;
|
||||
$this->sub_classification = $sub_classification;
|
||||
$this->location = $location;
|
||||
$this->sub_location = $sub_location;
|
||||
$this->government_agency = $government_agency;
|
||||
$this->issue = $issue;
|
||||
$this->response = $response;
|
||||
$this->year = $year;
|
||||
$this->month = $month;
|
||||
$this->date = $date;
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = IssueManagement::with(['location', 'subLocation', 'classification', 'subClassification', 'enhancer', 'governmentAgencies']);
|
||||
|
||||
if ($this->classification) {
|
||||
$query->where('classification_id', decrypt_id($this->classification));
|
||||
}
|
||||
|
||||
if ($this->sub_classification) {
|
||||
$query->where('sub_classification_id', decrypt_id($this->sub_classification));
|
||||
}
|
||||
|
||||
if ($this->location) {
|
||||
$query->where('location_id', decrypt_id($this->location));
|
||||
}
|
||||
|
||||
if ($this->sub_location) {
|
||||
$query->where('sub_location_id', decrypt_id($this->sub_location));
|
||||
}
|
||||
|
||||
if ($this->government_agency) {
|
||||
$query->whereHas('governmentAgencies', function ($query) {
|
||||
$query->where('issue_managements_government_agencies.government_agency_id', decrypt_id($this->government_agency));
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->issue) {
|
||||
switch ($this->issue) {
|
||||
case 'positive':
|
||||
$query->where('issue', 'positif');
|
||||
break;
|
||||
case 'negative':
|
||||
$query->where('issue', 'negatif');
|
||||
break;
|
||||
case 'neutral':
|
||||
$query->where('issue', 'netral');
|
||||
break;
|
||||
case 'crisis':
|
||||
$query->where('issue', 'krisis');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->response) {
|
||||
switch ($this->response) {
|
||||
case 'positive':
|
||||
$query->where('response', 'positif');
|
||||
break;
|
||||
case 'negative':
|
||||
$query->where('response', 'negatif');
|
||||
break;
|
||||
case 'neutral':
|
||||
$query->where('response', 'netral');
|
||||
break;
|
||||
case 'crisis':
|
||||
$query->where('response', 'krisis');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->year) {
|
||||
$query->whereYear('created_at', $this->year);
|
||||
}
|
||||
|
||||
if ($this->month) {
|
||||
$monthYear = Carbon::parse($this->month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->date) {
|
||||
$query->whereDate('created_at', $this->date);
|
||||
}
|
||||
|
||||
if ($this->start_date && $this->end_date) {
|
||||
$start = \Carbon\Carbon::createFromFormat('m/d/Y', $this->start_date)->startOfDay();
|
||||
$end = \Carbon\Carbon::createFromFormat('m/d/Y', $this->end_date)->endOfDay();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
|
||||
if ($this->user) {
|
||||
$query->where('enhancer_id', decrypt_id($this->user));
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($issueManagement): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$issueManagement->mediaMonitoring->code,
|
||||
$issueManagement->mediaMonitoring->title,
|
||||
$issueManagement->classification->name,
|
||||
$issueManagement->subClassification->name,
|
||||
$issueManagement->location->name,
|
||||
$issueManagement->subLocation->name,
|
||||
ucfirst($issueManagement->issue),
|
||||
ucfirst($issueManagement->response),
|
||||
$issueManagement->governmentAgencies->map(function ($agency) {
|
||||
return Str::ucfirst($agency->name);
|
||||
})->implode(', '),
|
||||
$issueManagement->enhancer->name ?? 'Admin',
|
||||
Carbon::parse($issueManagement->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Managemen Isu', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Kode', 'Monitoring Media', 'Klasifikasi', 'Sub Klasifikasi', 'Lokus', 'Sub Lokus', 'Isu', 'Tanggapan', 'Dinas', 'Oleh', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:L1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:L1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:L1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('I')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('J')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('K')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('L')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:L1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:L1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,146 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Journalist;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class JournalistExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $media_ids;
|
||||
|
||||
protected $status;
|
||||
|
||||
protected $edit_status;
|
||||
|
||||
protected $register_year;
|
||||
|
||||
protected $register_month;
|
||||
|
||||
protected $register_date;
|
||||
|
||||
public function __construct($media_ids, $status, $edit_status, $register_year, $register_month, $register_date)
|
||||
{
|
||||
$this->media_ids = $media_ids;
|
||||
$this->status = $status;
|
||||
$this->edit_status = $edit_status;
|
||||
$this->register_year = $register_year;
|
||||
$this->register_month = $register_month;
|
||||
$this->register_date = $register_date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Journalist::with(['media' => function ($q) {
|
||||
$q->withTrashed();
|
||||
}, 'media.company' => function ($q) {
|
||||
$q->withTrashed();
|
||||
}, 'media.company.user' => function ($q) {
|
||||
$q->withTrashed();
|
||||
}])
|
||||
->where('approved_status', '1')
|
||||
->whereNull('deleted_at');
|
||||
|
||||
if (is_array($this->media_ids) && ! in_array('all', $this->media_ids)) {
|
||||
$query->whereIn('media_id', array_map('decrypt_id', $this->media_ids));
|
||||
}
|
||||
|
||||
if ($this->status !== 'all') {
|
||||
if ($this->status === 'waiting') {
|
||||
$query->whereHas('media.company.user', function ($q) {
|
||||
$q->where('status', '0'); // Status waiting di User
|
||||
});
|
||||
} elseif ($this->status === 'accepted') {
|
||||
$query->whereHas('media.company.user', function ($q) {
|
||||
$q->where('status', '1'); // Status accepted di User
|
||||
});
|
||||
} elseif ($this->status === 'rejected') {
|
||||
$query->whereHas('media.company.user', function ($q) {
|
||||
$q->where('status', '2'); // Status rejected di User
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->edit_status !== 'all') {
|
||||
if ($this->edit_status === 'no-edit') {
|
||||
$query->where('edit_status', '0');
|
||||
} elseif ($this->edit_status === 'waiting') {
|
||||
$query->where('edit_status', '1');
|
||||
} elseif ($this->edit_status === 'accepted') {
|
||||
$query->where('edit_status', '2');
|
||||
} elseif ($this->edit_status === 'rejected') {
|
||||
$query->where('edit_status', '3');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->register_year) {
|
||||
$query->whereYear('created_at', $this->register_year);
|
||||
}
|
||||
|
||||
if ($this->register_month) {
|
||||
$monthYear = Carbon::parse($this->register_month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->register_date) {
|
||||
$query->whereDate('created_at', $this->register_date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($journalist): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$journalist->name,
|
||||
$journalist->media->name,
|
||||
$journalist->media->company->name,
|
||||
$journalist->media->company->email,
|
||||
get_user_status($journalist->media->company->user->status),
|
||||
get_edit_status($journalist->edit_status),
|
||||
Carbon::parse($journalist->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Jurnalis', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Jurnalis', 'Nama Media', 'Nama Perusahaan', 'Email', 'Status', 'Status Edit', 'Tanggal Daftar'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:H1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:H1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:H1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:H1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:H1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,172 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Media;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class MediaExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $type;
|
||||
|
||||
protected $classification;
|
||||
|
||||
protected $status;
|
||||
|
||||
protected $edit_status;
|
||||
|
||||
protected $address;
|
||||
|
||||
protected $register_year;
|
||||
|
||||
protected $register_month;
|
||||
|
||||
protected $register_date;
|
||||
|
||||
public function __construct($type, $classification, $status, $edit_status, $address, $register_year, $register_month, $register_date)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->classification = $classification;
|
||||
$this->status = $status;
|
||||
$this->edit_status = $edit_status;
|
||||
$this->address = $address;
|
||||
$this->register_year = $register_year;
|
||||
$this->register_month = $register_month;
|
||||
$this->register_date = $register_date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Media::with(['company.user']);
|
||||
|
||||
if ($this->type !== 'all') {
|
||||
if ($this->type === 'online') {
|
||||
$query->where('type', 'online');
|
||||
} elseif ($this->type === 'print') {
|
||||
$query->where('type', 'cetak');
|
||||
} elseif ($this->type === 'radio') {
|
||||
$query->where('type', 'radio');
|
||||
} elseif ($this->type === 'television') {
|
||||
$query->where('type', 'televisi');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->classification !== 'all') {
|
||||
if ($this->classification === 'local') {
|
||||
$query->where('classification', 'lokal');
|
||||
} elseif ($this->classification === 'regional') {
|
||||
$query->where('classification', 'regional');
|
||||
} elseif ($this->classification === 'national') {
|
||||
$query->where('classification', 'nasional');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->status !== 'all') {
|
||||
if ($this->status === 'waiting') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '0');
|
||||
});
|
||||
} elseif ($this->status === 'accepted') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '1');
|
||||
});
|
||||
} elseif ($this->status === 'rejected') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '2');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->edit_status !== 'all') {
|
||||
if ($this->edit_status === 'no-edit') {
|
||||
$query->where('edit_status', '0');
|
||||
} elseif ($this->edit_status === 'waiting') {
|
||||
$query->where('edit_status', '1');
|
||||
} elseif ($this->edit_status === 'accepted') {
|
||||
$query->where('edit_status', '2');
|
||||
} elseif ($this->edit_status === 'rejected') {
|
||||
$query->where('edit_status', '3');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->address) {
|
||||
$query->where('address', 'LIKE', '%'.$this->address.'%');
|
||||
}
|
||||
|
||||
if ($this->register_year) {
|
||||
$query->whereYear('created_at', $this->register_year);
|
||||
}
|
||||
|
||||
if ($this->register_month) {
|
||||
$monthYear = Carbon::parse($this->register_month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->register_date) {
|
||||
$query->whereDate('created_at', $this->register_date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($media): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$media->name,
|
||||
$media->company->name,
|
||||
$media->company->email,
|
||||
ucfirst($media->type),
|
||||
ucfirst($media->classification),
|
||||
$media->address,
|
||||
get_user_status($media->company->user->status),
|
||||
get_edit_status($media->edit_status),
|
||||
Carbon::parse($media->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
Carbon::parse($media->company->validated_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Media', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Media', 'Nama Perusahaan', 'Email', 'Tipe', 'Klasifikasi', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:K1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:K1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:K1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('I')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('J')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('K')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:K1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:K1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,166 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\MediaMonitoring;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class MediaMonitoringExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $news_title;
|
||||
|
||||
protected $channel;
|
||||
|
||||
protected $issue_status;
|
||||
|
||||
protected $keyword;
|
||||
|
||||
protected $input_year;
|
||||
|
||||
protected $input_month;
|
||||
|
||||
protected $input_date;
|
||||
|
||||
protected $release_year;
|
||||
|
||||
protected $release_month;
|
||||
|
||||
protected $release_date;
|
||||
|
||||
public function __construct($news_title, $channel, $issue_status, $keyword, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date)
|
||||
{
|
||||
$this->news_title = $news_title;
|
||||
$this->channel = $channel;
|
||||
$this->issue_status = $issue_status;
|
||||
$this->keyword = $keyword;
|
||||
$this->input_year = $input_year;
|
||||
$this->input_month = $input_month;
|
||||
$this->input_date = $input_date;
|
||||
$this->release_year = $release_year;
|
||||
$this->release_month = $release_month;
|
||||
$this->release_date = $release_date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = MediaMonitoring::with(['enhancer', 'issue']);
|
||||
|
||||
if ($this->news_title) {
|
||||
$query->where('title', 'LIKE', '%'.$this->news_title.'%');
|
||||
}
|
||||
|
||||
if ($this->channel && $this->channel !== 'all') {
|
||||
$query->where('channel', $this->channel);
|
||||
}
|
||||
|
||||
if ($this->issue_status && $this->issue_status !== 'all') {
|
||||
if ($this->issue_status === 'added') {
|
||||
$query->whereHas('issue');
|
||||
} elseif ($this->issue_status === 'not_added') {
|
||||
$query->whereDoesntHave('issue');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->keyword) {
|
||||
$query->where('keyword', 'LIKE', '%'.$this->keyword.'%');
|
||||
}
|
||||
|
||||
if ($this->input_year) {
|
||||
$query->whereYear('created_at', $this->input_year);
|
||||
}
|
||||
|
||||
if ($this->input_month) {
|
||||
$monthYear = Carbon::parse($this->input_month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->input_date) {
|
||||
$query->whereDate('created_at', $this->input_date);
|
||||
}
|
||||
|
||||
if ($this->release_year) {
|
||||
$query->whereYear('release_date', $this->release_year);
|
||||
}
|
||||
|
||||
if ($this->release_month) {
|
||||
$monthYear = Carbon::parse($this->release_month);
|
||||
$query->whereYear('release_date', $monthYear->year)
|
||||
->whereMonth('release_date', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->release_date) {
|
||||
$query->whereDate('release_date', $this->release_date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($mediaMonitoring): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$mediaMonitoring->code,
|
||||
$mediaMonitoring->title,
|
||||
$mediaMonitoring->media_name,
|
||||
$mediaMonitoring->theme,
|
||||
$mediaMonitoring->writter,
|
||||
$mediaMonitoring->channel,
|
||||
$mediaMonitoring->keyword,
|
||||
$mediaMonitoring->influencer,
|
||||
$mediaMonitoring->link,
|
||||
$mediaMonitoring->news_page,
|
||||
$mediaMonitoring->release_date,
|
||||
$mediaMonitoring->issue ? 'Sudah Ditambahkan' : 'Belum Ditambahkan',
|
||||
$mediaMonitoring->enhancer->name ?? 'Admin',
|
||||
Carbon::parse($mediaMonitoring->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Monitoring Media', '', '', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Kode', 'Judul Berita', 'Media', 'Tema', 'Penulis', 'Channel', 'Kata Kunci', 'Influencer', 'Link', 'Halaman Berita', 'Tanggal Rilis', 'Status Isu', 'Oleh',
|
||||
'Tanggal Input'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:N1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:N1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:N1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('I')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('J')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('K')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('L')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('M')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('N')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:N1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:N1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\News;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class NewsExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $category;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($category, $year, $month, $date)
|
||||
{
|
||||
$this->category = $category;
|
||||
$this->year = $year;
|
||||
$this->month = $month;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = News::query();
|
||||
|
||||
if ($this->category !== 'all') {
|
||||
if ($this->category === 'news') {
|
||||
$query->where('category', '0');
|
||||
} elseif ($this->category === 'announcement') {
|
||||
$query->where('category', '1');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->year) {
|
||||
$query->whereYear('created_at', $this->year);
|
||||
}
|
||||
|
||||
if ($this->month) {
|
||||
$monthYear = Carbon::parse($this->month);
|
||||
$query->whereYear('created_at', $monthYear->year)
|
||||
->whereMonth('created_at', $monthYear->month);
|
||||
}
|
||||
|
||||
if ($this->date) {
|
||||
$query->whereDate('created_at', $this->date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($news): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$news->title,
|
||||
$news->link ?? 'Tidak ada',
|
||||
$news->tag ?? 'Tidak ada',
|
||||
$news->category === '0' ? 'Berita' : 'Pengumuman',
|
||||
$news->views == '0' ? '0' : $news->views,
|
||||
Carbon::parse($news->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
$news->author->name,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Berita', '', '', '', '', '', '', ''],
|
||||
['NO', 'Judul', 'Link', 'Tag', 'Kategori', 'Dilihat', 'Dibuat Pada', 'Dibuat Oleh'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:D1'); // A1 sampai D1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:H1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:H1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('H')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:H1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:H1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Report;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ReportExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $media;
|
||||
|
||||
protected $status;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $from_month;
|
||||
|
||||
protected $to_month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($media, $status, $year, $from_month, $to_month, $date)
|
||||
{
|
||||
$this->media = $media;
|
||||
$this->status = $status;
|
||||
$this->year = $year;
|
||||
$this->from_month = $from_month;
|
||||
$this->to_month = $to_month;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = Report::with(['media.company', 'order.cooperation']);
|
||||
} elseif (is_role(['3'])) {
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
$query = Report::with(['media.company', 'order.cooperation'])->where('media_id', '=', $mediaId);
|
||||
}
|
||||
|
||||
if (! empty($this->media) && is_array($this->media)) {
|
||||
$query->whereIn('media_id', $this->media);
|
||||
}
|
||||
|
||||
if ($this->status) {
|
||||
switch ($this->status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
case 'accepted':
|
||||
$query->where('status', '1');
|
||||
break;
|
||||
case 'rejected':
|
||||
$query->where('status', '2');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->year) {
|
||||
$query->whereYear('created_at', $this->year);
|
||||
}
|
||||
|
||||
if ($this->from_month && $this->to_month) {
|
||||
$start = Carbon::parse($this->from_month)->startOfMonth();
|
||||
$end = Carbon::parse($this->to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
|
||||
if ($this->date) {
|
||||
$query->whereDate('created_at', $this->date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($report): array
|
||||
{
|
||||
return [
|
||||
$this->no++,
|
||||
$report->order->cooperation->name,
|
||||
$report->media->name,
|
||||
$report->media->company->name,
|
||||
Carbon::parse($report->publication_date)->locale('id')->translatedFormat('l, d F Y'),
|
||||
Carbon::parse($report->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
$report->status === '0' ? 'Menunggu' : ($report->status === '1' ? 'Diterima' : 'Ditolak'),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Laporan Bukti Tayang', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Media', 'Perusahaan', 'Tanggal Upload', 'Tanggal Melaporkan', 'Status'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->mergeCells('A1:G1'); // A1 sampai G1 digabung
|
||||
|
||||
// Set alignment untuk pusat horizontal dan vertikal
|
||||
$sheet->getStyle('A1:G1')->getAlignment()->setHorizontal('center');
|
||||
$sheet->getStyle('A1:G1')->getAlignment()->setVertical('center');
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('F')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
$sheet->getStyle('G:G')->getAlignment()->setWrapText(true);
|
||||
|
||||
$sheet->getColumnDimension('G')->setAutoSize(true);
|
||||
|
||||
// Menambahkan gaya lain jika diperlukan
|
||||
$sheet->getStyle('A1:G1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:G1')->getFont()->setSize(14);
|
||||
}
|
||||
}
|
||||
@ -1,551 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Hashids\Hashids;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
// Template
|
||||
// if (! function_exists('my_custom_function')) {
|
||||
// function my_custom_function($param) {
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(env('FILESYSTEM_DISK') === 's3'){
|
||||
// if (! function_exists('store_file')) {
|
||||
// function store_file($file = null, $path, $disk = null)
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
// if (filled($file) && $file instanceof \Illuminate\Http\UploadedFile) {
|
||||
// $randomFilename = Str::random(35) . time() . '.' . $file->getClientOriginalExtension();
|
||||
// $originalFileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
// $stored = $file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
// if ($stored) {
|
||||
// $url = Storage::disk($disk)->url($stored);
|
||||
|
||||
// return [
|
||||
// 'randomFileName' => $randomFilename,
|
||||
// 'originalFileName' => $originalFileName,
|
||||
// 'url' => $url,
|
||||
// 'isSuccess' => true,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// return [
|
||||
// 'randomFileName' => null,
|
||||
// 'originalFileName' => null,
|
||||
// 'url' => null,
|
||||
// 'isSuccess' => false,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!function_exists('display_file')) {
|
||||
// function display_file($dir, $filename, $disk = null, $expirationMinutes = 60): string
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
// if (!filled($filename)) {
|
||||
// return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
// }
|
||||
|
||||
// $path = "uploads/{$dir}/{$filename}";
|
||||
|
||||
// try {
|
||||
// $fileExists = is_file_exists($path, $disk);
|
||||
|
||||
// if (!$fileExists) {
|
||||
// return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
// }
|
||||
|
||||
// if ($disk === 's3') {
|
||||
// $fileUrl = Storage::disk($disk)->temporaryUrl($path, now()->addMinutes($expirationMinutes));
|
||||
// } else {
|
||||
// $fileUrl = Storage::disk($disk)->url($path);
|
||||
// }
|
||||
|
||||
// $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
// $mimeType = match ($ext) {
|
||||
// 'jpg', 'jpeg', 'png', 'gif', 'webp' => 'image/' . $ext,
|
||||
// 'pdf' => 'application/pdf',
|
||||
// default => 'unknown',
|
||||
// };
|
||||
|
||||
// if (str_contains($mimeType, 'image')) {
|
||||
// return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
// } elseif ($mimeType === 'application/pdf') {
|
||||
// return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
// }
|
||||
|
||||
// return '<p class="text-center">Format file tidak didukung</p>';
|
||||
// } catch (\Exception $e) {
|
||||
// return '<p class="text-center text-danger">Terjadi kesalahan saat menampilkan file.</p>';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (! function_exists('delete_file')) {
|
||||
// function delete_file($path, $disk = null): bool
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
// try {
|
||||
// if(is_file_exists($path)){
|
||||
// return Storage::disk($disk)->delete($path);
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!function_exists('is_file_exists')) {
|
||||
// function is_file_exists($path, $disk = null): bool
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
// try {
|
||||
// $file = Storage::disk($disk)->get($path);
|
||||
// return !empty($file);
|
||||
// } catch (\Throwable $e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else if(env('FILESYSTEM_DISK') === 'local'){
|
||||
if (! function_exists('store_file')) {
|
||||
function store_file($file = null, $path = null, $disk = 'public')
|
||||
{
|
||||
if (filled($file) && $file && $file instanceof \Illuminate\Http\UploadedFile) {
|
||||
$randomFilename = Str::random(35).time().'.'.$file->getClientOriginalExtension();
|
||||
$originalFileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'.'.$file->getClientOriginalExtension();
|
||||
|
||||
$file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
return [
|
||||
'randomFileName' => $randomFilename,
|
||||
'originalFileName' => $originalFileName,
|
||||
'isSuccess' => true,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'randomFileName' => null,
|
||||
'originalFileName' => null,
|
||||
'isSuccess' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('display_file')) {
|
||||
function display_file($dir, $filename)
|
||||
{
|
||||
$path = storage_path("app/public/uploads/{$dir}/{$filename}");
|
||||
|
||||
if (! filled($filename)) {
|
||||
return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
}
|
||||
|
||||
if (! file_exists($path)) {
|
||||
return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
}
|
||||
|
||||
$mimeType = mime_content_type($path);
|
||||
$fileUrl = asset("storage/uploads/{$dir}/{$filename}");
|
||||
|
||||
if (str_contains($mimeType, 'image')) {
|
||||
return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
} elseif ($mimeType === 'application/pdf') {
|
||||
return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
}
|
||||
|
||||
return '<p class="text-center">Format file tidak didukung</p>';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('delete_file')) {
|
||||
function delete_file($path)
|
||||
{
|
||||
// Menggunakan public_path untuk file yang berada di dalam storage/public
|
||||
$fullPath = public_path('storage/'.$path);
|
||||
|
||||
if (File::exists($fullPath)) {
|
||||
File::delete($fullPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('is_file_exists')) {
|
||||
function is_file_exists($path)
|
||||
{
|
||||
return File::exists(public_path('storage/'.$path));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_role_name')) {
|
||||
function get_role_name($role = null)
|
||||
{
|
||||
|
||||
if ($role === null) {
|
||||
$role = Auth::user()->role_id;
|
||||
}
|
||||
|
||||
switch ($role) {
|
||||
case '1':
|
||||
return 'Administrator';
|
||||
case '2':
|
||||
return 'Admin Monitoring';
|
||||
case '3':
|
||||
return 'Perusahaan';
|
||||
case '4':
|
||||
return 'Admin Konten';
|
||||
case '5':
|
||||
return 'Admin Keuangan';
|
||||
default:
|
||||
return 'Role Tidak Dikenal';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('shorten_text')) {
|
||||
function shorten_text($text, $maxLength = 100)
|
||||
{
|
||||
if (strlen($text) > $maxLength) {
|
||||
return substr($text, 0, $maxLength).'...';
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('is_role')) {
|
||||
function is_role($roles)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
return in_array(Auth::user()->role_id, (array) $roles) || Auth::user()->role_id === '4';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('encrypt_id')) {
|
||||
function encrypt_id($id)
|
||||
{
|
||||
$hashids = new Hashids('alwayssaybismillahirrahmanirrahim', 15);
|
||||
|
||||
return $hashids->encode($id);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('decrypt_id')) {
|
||||
function decrypt_id($hash)
|
||||
{
|
||||
$hashids = new Hashids('alwayssaybismillahirrahmanirrahim', 15);
|
||||
$result = $hashids->decode($hash);
|
||||
|
||||
return $result ? $result[0] : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('idn_date')) {
|
||||
function idn_date($tanggal, $format = 'd F Y')
|
||||
{
|
||||
return Carbon::parse($tanggal)->locale('id')->translatedFormat($format);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_user_status')) {
|
||||
function get_user_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
case '0':
|
||||
return 'Menunggu';
|
||||
case '1':
|
||||
return 'Diterima';
|
||||
case '2':
|
||||
return 'Ditolak';
|
||||
default:
|
||||
return 'Tidak Diketahui';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_edit_status')) {
|
||||
function get_edit_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
case '0':
|
||||
return 'Tidak Ada';
|
||||
case '1':
|
||||
return 'Menunggu';
|
||||
case '2':
|
||||
return 'Diterima';
|
||||
case '3':
|
||||
return 'Ditolak';
|
||||
default:
|
||||
return 'Tidak Diketahui';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_cooperation_notif')) {
|
||||
function get_cooperation_notif()
|
||||
{
|
||||
$user = User::findOrFail(Auth::id());
|
||||
if ($user->role_id === 3) {
|
||||
$mediaId = $user->company->media->id;
|
||||
|
||||
$media = Media::with('cooperations')->findOrFail($mediaId);
|
||||
|
||||
return $media->cooperations()
|
||||
->where('start_date', '<=', Carbon::now()->locale('id')->toDateString())
|
||||
->where('end_date', '>=', Carbon::now()->locale('id')->toDateString())
|
||||
->count();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('slugify')) {
|
||||
function slugify($param)
|
||||
{
|
||||
return Str::slug($param);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_unread_announcements')) {
|
||||
function get_unread_announcements()
|
||||
{
|
||||
$user = User::findOrFail(Auth::id());
|
||||
if ($user->role_id === 3) {
|
||||
$userId = $user->id;
|
||||
|
||||
$user = User::with('announcements')->findOrFail($userId);
|
||||
|
||||
return $user->announcements()
|
||||
->wherePivot('status', '=', '0')
|
||||
->count();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('display_image')) {
|
||||
function display_image($name, $dir = 'defaults', $default = 'default.jpg')
|
||||
{
|
||||
$path = "uploads/{$dir}/{$name}";
|
||||
$defaultPath = "assets/defaults/{$default}";
|
||||
|
||||
if (Storage::disk('public')->exists($path)) {
|
||||
try {
|
||||
if (Storage::disk('public')->get($path)) {
|
||||
return "storage/{$path}";
|
||||
} else {
|
||||
return $defaultPath;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $defaultPath;
|
||||
}
|
||||
}
|
||||
|
||||
return $defaultPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_user_agent')) {
|
||||
function get_user_agent($userAgentParam): array
|
||||
{
|
||||
$userAgent = $userAgentParam;
|
||||
|
||||
// Deteksi Sistem Operasi
|
||||
$osArray = [
|
||||
'Windows' => 'Windows',
|
||||
'Mac' => 'Macintosh',
|
||||
'Linux' => 'Linux',
|
||||
'Android' => 'Android',
|
||||
'iOS' => 'iPhone|iPad|iPod',
|
||||
];
|
||||
|
||||
$osDetected = 'Unknown OS';
|
||||
foreach ($osArray as $os => $pattern) {
|
||||
if (preg_match("/$pattern/i", $userAgent)) {
|
||||
$osDetected = $os;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Deteksi Browser
|
||||
$browserArray = [
|
||||
'Chrome' => 'Chrome',
|
||||
'Firefox' => 'Firefox',
|
||||
'Safari' => 'Safari',
|
||||
'Edge' => 'Edg', // Microsoft Edge pakai "Edg" di User-Agent
|
||||
'Opera' => 'Opera|OPR',
|
||||
'Internet Explorer' => 'MSIE|Trident',
|
||||
];
|
||||
|
||||
$browserDetected = 'Unknown Browser';
|
||||
foreach ($browserArray as $browser => $pattern) {
|
||||
if (preg_match("/$pattern/i", $userAgent)) {
|
||||
$browserDetected = $browser;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'os' => $osDetected,
|
||||
'browser' => $browserDetected,
|
||||
'user_agent' => $userAgent,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('change_status')) {
|
||||
function change_status($status, $category)
|
||||
{
|
||||
if (in_array($category, ['company_edit', 'media_edit'])) {
|
||||
switch ($status) {
|
||||
case '0':
|
||||
return '1';
|
||||
case '1':
|
||||
return '2';
|
||||
case '2':
|
||||
return '3';
|
||||
default:
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('titlefy')) {
|
||||
function titlefy($text)
|
||||
{
|
||||
if (filled($text)) {
|
||||
return Str::title($text);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_activity_log_name')) {
|
||||
function get_activity_log_name($name)
|
||||
{
|
||||
|
||||
switch ($name) {
|
||||
case 'airing_proof_theme':
|
||||
return [
|
||||
'name' => 'Tema Bukti Tayang',
|
||||
'route' => 'dashboard.airing.proof.themes.show',
|
||||
];
|
||||
case 'announcement':
|
||||
return [
|
||||
'name' => 'Pengumuman',
|
||||
'route' => 'dashboard.announcements.show',
|
||||
];
|
||||
case 'classification':
|
||||
return [
|
||||
'name' => 'Klasifikasi',
|
||||
'route' => 'dashboard.classifications.show',
|
||||
];
|
||||
case 'content_recap':
|
||||
return [
|
||||
'name' => 'Rekap Konten',
|
||||
'route' => 'dashboard.content.recaps.show',
|
||||
];
|
||||
case 'content_recap_classification':
|
||||
return [
|
||||
'name' => 'Klasifikasi Rekap Konten',
|
||||
'route' => 'dashboard.content.recap.classifications.show',
|
||||
];
|
||||
case 'cooperation':
|
||||
return [
|
||||
'name' => 'Kerja Sama',
|
||||
'route' => 'dashboard.cooperations.show',
|
||||
];
|
||||
case 'cooperation_completion':
|
||||
return [
|
||||
'name' => 'Penyelesaian Kerja Sama',
|
||||
'route' => 'dashboard.cooperation.completions.show',
|
||||
];
|
||||
case 'cooperation_proposal':
|
||||
return [
|
||||
'name' => 'Pengajuan Kerja Sama',
|
||||
'route' => 'dashboard.cooperations.media.proposal.show',
|
||||
];
|
||||
case 'government_agency':
|
||||
return [
|
||||
'name' => 'OPD',
|
||||
'route' => 'dashboard.government.agencies.show',
|
||||
];
|
||||
case 'issue_management':
|
||||
return [
|
||||
'name' => 'Manajemen Isu',
|
||||
'route' => 'dashboard.issue.managements.show',
|
||||
];
|
||||
case 'location':
|
||||
return [
|
||||
'name' => 'Location',
|
||||
'route' => 'dashboard.locations.show',
|
||||
];
|
||||
case 'media_monitoring':
|
||||
return [
|
||||
'name' => 'Monitoring Media',
|
||||
'route' => 'dashboard.media.monitorings.show',
|
||||
];
|
||||
case 'news':
|
||||
return [
|
||||
'name' => 'Berita',
|
||||
'route' => 'dashboard.news.show',
|
||||
];
|
||||
case 'order':
|
||||
return [
|
||||
'name' => 'Media Order',
|
||||
'route' => 'dashboard.media.orders.show',
|
||||
];
|
||||
case 'airing_proof_report':
|
||||
return [
|
||||
'name' => 'Laporan Bukti Tayang',
|
||||
'route' => 'dashboard.reports.show',
|
||||
];
|
||||
case 'user_role':
|
||||
return [
|
||||
'name' => 'Hak Akses',
|
||||
'route' => 'dashboard.role.index',
|
||||
];
|
||||
case 'sub_classification':
|
||||
return [
|
||||
'name' => 'Sub Klasifikasi',
|
||||
'route' => 'dashboard.sub.classifications.show',
|
||||
];
|
||||
case 'sub_location':
|
||||
return [
|
||||
'name' => 'Sub Lokasi',
|
||||
'route' => 'dashboard.sub.locations.show',
|
||||
];
|
||||
default:
|
||||
return [
|
||||
'name' => 'Tidak Valid',
|
||||
'route' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,183 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\LoginRequest;
|
||||
use App\Http\Requests\RegisterRequest;
|
||||
use App\Models\Company;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login()
|
||||
{
|
||||
return view('auth.login', [
|
||||
'title' => 'Masuk',
|
||||
]);
|
||||
}
|
||||
|
||||
public function loginAction(LoginRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
if (Auth::attempt(['email' => $validatedData['email'], 'password' => $validatedData['password']])) {
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended('/dashboard/overview');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Pastikan data dan akun sudah terdaftar.');
|
||||
}
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
return view('auth.register', [
|
||||
'title' => 'Daftar',
|
||||
'sample' => 'Hai',
|
||||
]);
|
||||
}
|
||||
|
||||
public function registerAction(RegisterRequest $request)
|
||||
{
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$createdUser = User::create([
|
||||
'name' => $validatedData['name'],
|
||||
'email' => $validatedData['email'],
|
||||
'password' => $validatedData['password'],
|
||||
'status' => '0',
|
||||
'role_id' => '3',
|
||||
]);
|
||||
|
||||
$companyFiles = [
|
||||
'company_director_nik_doc',
|
||||
'company_deed_incorporation_doc',
|
||||
'company_trade_license_doc',
|
||||
'company_tax_id_number_doc',
|
||||
'company_taxable_enterprise_doc',
|
||||
'company_annual_tax_return_doc',
|
||||
'company_domicile_certificate_doc',
|
||||
'company_profile_doc',
|
||||
];
|
||||
|
||||
$companyFileNames = [];
|
||||
foreach ($companyFiles as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$companyFileNames[$file] = store_file($validatedData[$file], '/uploads/companies')['randomFileName'];
|
||||
} else {
|
||||
$companyFileNames[$file] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$createdCompany = Company::create([
|
||||
'name' => $validatedData['company_name'],
|
||||
'email' => $validatedData['company_email'],
|
||||
'address' => $validatedData['company_address'],
|
||||
'director_name' => $validatedData['company_director_name'],
|
||||
'director_nik' => $validatedData['company_director_nik'],
|
||||
'director_nik_doc' => $companyFileNames['company_director_nik_doc'],
|
||||
'deed_incorporation' => $validatedData['company_deed_incorporation'],
|
||||
'deed_incorporation_doc' => $companyFileNames['company_deed_incorporation_doc'],
|
||||
'trade_license' => $validatedData['company_trade_license'],
|
||||
'trade_license_doc' => $companyFileNames['company_trade_license_doc'],
|
||||
'tax_id_number' => $validatedData['company_tax_id_number'],
|
||||
'tax_id_number_doc' => $companyFileNames['company_tax_id_number_doc'],
|
||||
'taxable_enterprise' => $validatedData['company_taxable_enterprise'],
|
||||
'taxable_enterprise_doc' => $companyFileNames['company_taxable_enterprise_doc'],
|
||||
'annual_tax_return' => $validatedData['company_annual_tax_return'],
|
||||
'annual_tax_return_doc' => $companyFileNames['company_annual_tax_return_doc'],
|
||||
'domicile_certificate' => $validatedData['company_domicile_certificate'],
|
||||
'domicile_certificate_doc' => $companyFileNames['company_domicile_certificate_doc'],
|
||||
'profile' => $validatedData['company_profile'],
|
||||
'profile_doc' => $companyFileNames['company_profile_doc'],
|
||||
'user_id' => $createdUser->id,
|
||||
]);
|
||||
|
||||
$mediaFiles = [
|
||||
'media_journalism_organization_doc',
|
||||
'media_press_council_certificate_doc',
|
||||
];
|
||||
|
||||
$mediaFileNames = [];
|
||||
foreach ($mediaFiles as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$mediaFileNames[$file] = store_file($validatedData[$file], '/uploads/media')['randomFileName'];
|
||||
} else {
|
||||
$mediaFileNames[$file] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$createdMedia = Media::create([
|
||||
'name' => $validatedData['media_name'],
|
||||
'address' => $validatedData['media_address'],
|
||||
'link' => $validatedData['media_link'],
|
||||
'type' => $validatedData['media_type'],
|
||||
'classification' => $validatedData['media_classification'],
|
||||
'journalism_organization' => $validatedData['media_journalism_organization'],
|
||||
'journalism_organization_doc' => $mediaFileNames['media_journalism_organization_doc'],
|
||||
'press_council_certificate' => $validatedData['media_press_council_certificate'],
|
||||
'press_council_certificate_doc' => $mediaFileNames['media_press_council_certificate_doc'],
|
||||
'company_id' => $createdCompany->id,
|
||||
]);
|
||||
|
||||
$journalistFiles = [
|
||||
'journalist_press_card_doc',
|
||||
'journalist_ukw_sertificate_doc',
|
||||
];
|
||||
|
||||
$journalistFileNames = [];
|
||||
foreach ($journalistFiles as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$journalistFileNames[$file] = store_file($validatedData[$file], '/uploads/journalists')['randomFileName'];
|
||||
} else {
|
||||
$journalistFileNames[$file] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$createdJournalist = Journalist::create([
|
||||
'name' => $validatedData['journalist_name'],
|
||||
'email' => $validatedData['journalist_email'],
|
||||
'phone_number' => $validatedData['journalist_phone_number'],
|
||||
'press_card' => $validatedData['journalist_press_card'],
|
||||
'press_card_doc' => $journalistFileNames['journalist_press_card_doc'],
|
||||
'ukw_sertificate' => $validatedData['journalist_ukw_sertificate'],
|
||||
'ukw_sertificate_doc' => $journalistFileNames['journalist_ukw_sertificate_doc'],
|
||||
'media_id' => $createdMedia->id,
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return redirect()->route('auth.register.success');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function registerSuccess()
|
||||
{
|
||||
return view('auth.register-success', [
|
||||
'title' => 'Daftar Berhasil',
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('login');
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AiringProofThemeRequest;
|
||||
use App\Models\AiringProofTheme;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AiringProofThemeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.airing-proof-themes.index', [
|
||||
'title' => 'Data Tema Bukti Tayang',
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.airing-proof-themes.create', [
|
||||
'title' => 'Buat Tema Bukti Tayang Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(AiringProofThemeRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$slug = $validatedData['slug'];
|
||||
$existing = AiringProofTheme::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if ($existing?->trashed()) {
|
||||
return redirect()->back()->with('data-exists', $slug);
|
||||
} elseif ($existing) {
|
||||
return redirect()->back()
|
||||
->with('failed-status', 'Tema dengan nama dan tahun tersebut sudah ada.');
|
||||
}
|
||||
|
||||
$createdAiringProofTheme = AiringProofTheme::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Airing Proof Themes (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat tema bukti tayang baru.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.airing.proof.themes.index')->with('success-status', 'Berhasil membuat tema bukti tayang baru.')->with('new_data', encrypt_id($createdAiringProofTheme->id));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.airing-proof-themes.edit', [
|
||||
'title' => 'Ubah Tema Bukti Tayang',
|
||||
'airingProofTheme' => $airingProofTheme,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(AiringProofThemeRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Airing Proof Themes (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah tema bukti tayang.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.airing.proof.themes.show', ['id' => encrypt_id($airingProofTheme->id)])->with('success-status', 'Berhasil mengubah tema bukti tayang.');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.airing-proof-themes.show', [
|
||||
'title' => 'Detail Tema Bukti Tayang',
|
||||
'airingProofTheme' => $airingProofTheme,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->delete();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Airing Proof Themes (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus tema bukti tayang.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus tema bukti tayang.']);
|
||||
}
|
||||
|
||||
public function restore($slug)
|
||||
{
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if (! $airingProofTheme) {
|
||||
return redirect()->back()->with('failed-status', 'Tema tidak ditemukan.');
|
||||
}
|
||||
|
||||
if (filled($airingProofTheme->deleted_at)) {
|
||||
$airingProofTheme->restore();
|
||||
|
||||
return redirect()->route('dashboard.airing.proof.themes.index')->with('success-status', 'Tema berhasil dipulihkan.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Airing Proof Themes (restore): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Proses pemulihan gagal.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('info-status', 'Tema sudah aktif.');
|
||||
}
|
||||
}
|
||||
@ -1,163 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AnnouncementRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AnnouncementController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Pengumuman',
|
||||
'category' => $request->input('category', 'general'),
|
||||
];
|
||||
|
||||
if (is_role(['1'])) {
|
||||
return view('dashboard.announcements.index', $data);
|
||||
} elseif (is_role(['3'])) {
|
||||
return view('dashboard.announcements.media.index', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.announcements.create', [
|
||||
'title' => 'Buat Pengumuman Baru',
|
||||
'users' => User::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(AnnouncementRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
if ($request->hasFile('attachment')) {
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements')['randomFileName'];
|
||||
}
|
||||
|
||||
$announcement = DB::transaction(function () use ($validatedData) {
|
||||
$announcement = Announcement::create($validatedData);
|
||||
$announcement->users()->attach($validatedData['user_ids']);
|
||||
|
||||
if ($announcement->users()->count() < 1) {
|
||||
throw new \Exception('Data tidak valid.');
|
||||
}
|
||||
|
||||
return $announcement;
|
||||
});
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Announcements (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat pengumuman baru');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.announcements.index')->with('success-status', 'Berhasil membuat pengumuman baru.')->with('new_data', encrypt_id($announcement->id));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.announcements.edit', [
|
||||
'title' => 'Ubah Pengumuman',
|
||||
'announcement' => $announcement,
|
||||
'users' => User::all(),
|
||||
'selectedUsersIds' => $announcement->users->pluck('id')->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(AnnouncementRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
DB::transaction(function () use ($request, $validatedData, $announcement) {
|
||||
if ($request->hasFile('attachment')) {
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], 'uploads/announcements')['randomFileName'];
|
||||
delete_file('uploads/announcements/'.$announcement->attachment);
|
||||
} else {
|
||||
$validatedData['attachment'] = $announcement->attachment;
|
||||
}
|
||||
|
||||
$announcement->update($validatedData);
|
||||
if ($request->has('user_ids')) {
|
||||
$mediaData = [];
|
||||
foreach ($validatedData['user_ids'] as $userId) {
|
||||
$mediaData[$userId] = ['status' => '0'];
|
||||
}
|
||||
|
||||
$announcement->users()->sync($mediaData);
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Announcements (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengumuman.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.announcements.show', ['id' => encrypt_id($announcement->id)])->with('success-status', 'Berhasil mengubah pengumuman.');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$announcement = Announcement::with(['users' => function ($query) {
|
||||
$query->withPivot('category');
|
||||
}])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.announcements.show', [
|
||||
'title' => 'Detail Pengumuman',
|
||||
'announcement' => $announcement,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
$announcement->users()->detach();
|
||||
$announcement->delete();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Announcements (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus pengumuman.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus pengumuman.']);
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if (! in_array(Auth::id(), $announcement->users->pluck('id')->toArray())) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
try {
|
||||
$announcement->users()->updateExistingPivot(Auth::id(), [
|
||||
'status' => '1',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Announcements (read): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal membaca pengumuman.');
|
||||
}
|
||||
|
||||
return view('dashboard.announcements.read', [
|
||||
'title' => 'Baca Pengumuman',
|
||||
'announcement' => $announcement,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClassificationRequest;
|
||||
use App\Models\Classification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ClassificationController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.classifications.index', [
|
||||
'title' => 'Data Klasifikasi',
|
||||
'filter' => $request->input('filter', null),
|
||||
'new_data' => session()->get('new_data', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.classifications.create', [
|
||||
'title' => 'Buat Klasifikasi Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ClassificationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$createdClassification = Classification::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Classifications (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat klasifikasi baru.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.classifications.index')->with('success-status', 'Berhasil membuat klasifikasi baru.')
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.classifications.edit', [
|
||||
'title' => 'Ubah Klasifikasi',
|
||||
'classification' => $classification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ClassificationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
$classification->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Classifications (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah klasifikasi.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.classifications.show', ['id' => encrypt_id($classification->id)])->with('success-status', 'Berhasil mengubah klasifikasi.');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$classification = Classification::withTrashed()->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.classifications.show', [
|
||||
'title' => 'Detail Klasifikasi',
|
||||
'classification' => $classification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
$classification->delete();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Classifications (destroy): '.$e);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Gagal menghapus klasifikasi.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Berhasil menghapus klasifikasi.',
|
||||
'id' => encrypt_id($classification->id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function restore($id)
|
||||
{
|
||||
try {
|
||||
$classification = Classification::withTrashed()->findOrFail(decrypt_id($id));
|
||||
|
||||
if (! $classification->trashed()) {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Klasifikasi belum dihapus.',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$classification->restore();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Classifications (restore): '.$e);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Gagal mengembalikan klasifikasi.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Klasifikasi berhasil dikembalikan.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,430 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\CompanyExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CompanyRequest;
|
||||
use App\Mail\AccountVerification;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Company;
|
||||
use App\Models\LoginHistory;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (is_role(['1', '5'])) {
|
||||
return view('dashboard.companies.admin.index', [
|
||||
'title' => 'Data Perusahaan',
|
||||
'status' => $request->input('status', null),
|
||||
'edit_status' => $request->input('edit_status', null),
|
||||
'address' => $request->input('address', null),
|
||||
'register_year' => $request->input('register_year', null),
|
||||
'register_month' => $request->input('register_month', null),
|
||||
'register_date' => $request->input('register_date', null),
|
||||
]);
|
||||
} elseif (is_role(['3'])) {
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
$data = [
|
||||
'title' => 'Data Perusahaan',
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
return view('dashboard.companies.index', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function editRequest()
|
||||
{
|
||||
if (! in_array(Auth::user()->company->edit_status, ['0', '2', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('dashboard.companies.edit-request', [
|
||||
'title' => 'Permohonan Ubah Data Perusahaan',
|
||||
]);
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
if (! in_array(Auth::user()->company->edit_status, ['0', '2', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'edit_description' => ['required'],
|
||||
], [
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
$user = User::with(['company'])->findOrFail(Auth::id());
|
||||
$user->company->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description'],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (editRequestAction): '.$e);
|
||||
|
||||
return redirect()->route('dashboard.companies.index')->with('failed-status', 'Gagal melakukan permohonan edit data perusahaan.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.companies.index')->with('success-status', 'Berhasil melakukan permohonan edit data perusahaan.');
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
if (Auth::user()->company->edit_status !== '2') {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
return view('dashboard.companies.edit', [
|
||||
'title' => 'Ubah Data Perusahaan',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(CompanyRequest $request)
|
||||
{
|
||||
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
if (Auth::user()->company->edit_status !== '2') {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$company = User::with(['company'])->findOrFail(Auth::id())->company;
|
||||
|
||||
$fileFieldMap = [
|
||||
'company_director_nik_doc' => 'director_nik_doc',
|
||||
'company_deed_incorporation_doc' => 'deed_incorporation_doc',
|
||||
'company_trade_license_doc' => 'trade_license_doc',
|
||||
'company_tax_id_number_doc' => 'tax_id_number_doc',
|
||||
'company_taxable_enterprise_doc' => 'taxable_enterprise_doc',
|
||||
'company_annual_tax_return_doc' => 'annual_tax_return_doc',
|
||||
'company_domicile_certificate_doc' => 'domicile_certificate_doc',
|
||||
'company_profile_doc' => 'profile_doc',
|
||||
];
|
||||
|
||||
$companyFileNames = [];
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$companyFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/companies')['randomFileName'];
|
||||
} else {
|
||||
$companyFileNames[$requestKey] = $company->{$dbField};
|
||||
}
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($company, $validatedData, $companyFileNames) {
|
||||
$company->update([
|
||||
'name' => $validatedData['company_name'],
|
||||
'email' => $validatedData['company_email'],
|
||||
'address' => $validatedData['company_address'],
|
||||
'phone_number' => $validatedData['company_phone_number'],
|
||||
'director_name' => $validatedData['company_director_name'],
|
||||
'director_nik' => $validatedData['company_director_nik'],
|
||||
'director_nik_doc' => $companyFileNames['company_director_nik_doc'],
|
||||
'deed_incorporation' => $validatedData['company_deed_incorporation'],
|
||||
'deed_incorporation_doc' => $companyFileNames['company_deed_incorporation_doc'],
|
||||
'trade_license' => $validatedData['company_trade_license'],
|
||||
'trade_license_doc' => $companyFileNames['company_trade_license_doc'],
|
||||
'tax_id_number' => $validatedData['company_tax_id_number'],
|
||||
'tax_id_number_doc' => $companyFileNames['company_tax_id_number_doc'],
|
||||
'taxable_enterprise' => $validatedData['company_taxable_enterprise'],
|
||||
'taxable_enterprise_doc' => $companyFileNames['company_taxable_enterprise_doc'],
|
||||
'annual_tax_return' => $validatedData['company_annual_tax_return'],
|
||||
'annual_tax_return_doc' => $companyFileNames['company_annual_tax_return_doc'],
|
||||
'domicile_certificate' => $validatedData['company_domicile_certificate'],
|
||||
'domicile_certificate_doc' => $companyFileNames['company_domicile_certificate_doc'],
|
||||
'profile' => $validatedData['company_profile'],
|
||||
'profile_doc' => $companyFileNames['company_profile_doc'],
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (update): '.$e);
|
||||
|
||||
return redirect()->route('dashboard.companies.index')->with('failed-status', 'Gagal mengubah data perusahaan.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.companies.index')->with('success-status', 'Berhasil mengubah data perusahaan.');
|
||||
}
|
||||
|
||||
public function show($id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
'title' => 'Data Perusahaan',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'company',
|
||||
'purpose' => 'show',
|
||||
'idnPage' => 'perusahaan',
|
||||
'route' => 'companies',
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
|
||||
return response()->json([
|
||||
'status' => 'warning',
|
||||
'message' => 'Aksi belum tersedia.',
|
||||
]);
|
||||
|
||||
// try{
|
||||
// $company = Company::with(['user', 'media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
// DB::transaction(function(){
|
||||
// });
|
||||
// }catch(\Exception $e){
|
||||
// Log::error('Gagal menghapus perusahaan: ' . $e->getMessage());
|
||||
// return response()->json(['message' => 'Gagal menghapus perusahaan.'], 500);
|
||||
// }
|
||||
}
|
||||
|
||||
public function process(Request $request, $id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if ($request->query('category') && ! in_array($request->query('category'), ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => 'Data Perusahaan',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'company',
|
||||
'purpose' => 'process',
|
||||
'idnPage' => 'perusahaan',
|
||||
'route' => 'companies',
|
||||
'type' => $type,
|
||||
'category' => $request->query('category', null),
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function processAcceptAction(Request $request, $id, $type, $category)
|
||||
{
|
||||
try {
|
||||
$user = User::with(['company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if (! in_array($category, ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (! is_role(['1'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($user, $category) {
|
||||
if ($category === 'account-status' && $user->status === '0') {
|
||||
$user->update(['status' => '1']);
|
||||
|
||||
$announcement = Announcement::create([
|
||||
'headline' => 'Pendaftaran Media Anda Telah Disetujui!',
|
||||
'content' => 'Selamat! Permohonan pendaftaran media Anda telah disetujui oleh tim kami.',
|
||||
'enhancer_id' => auth()->id(),
|
||||
]);
|
||||
|
||||
$user->announcements()->attach($announcement->id);
|
||||
|
||||
DB::afterCommit(fn () => Mail::to($user->email)->send(
|
||||
new AccountVerification($user, 'accepted')
|
||||
)
|
||||
);
|
||||
} elseif ($category === 'edit-request' && $user->company->edit_status === '1') {
|
||||
$user->company->update(['edit_status' => '2']);
|
||||
}
|
||||
});
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (processAcceptAction): '.$e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'failed-status' => 'Gagal menyetujui'.($category === 'edit-request' ? ' permohonan edit' : '').' perusahaan.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function processRejectAction(Request $request, $id, $type, $category)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try {
|
||||
$user = User::with(['company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if (! in_array($category, ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (! is_role(['1'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($user, $category, $validatedData) {
|
||||
if ($category === 'account-status' && $user->status === '0') {
|
||||
$announcement = Announcement::create([
|
||||
'headline' => 'Pendaftaran Media Anda Belum Dapat Disetujui',
|
||||
'content' => $validatedData['rejection_reason'],
|
||||
'enhancer_id' => auth()->id(),
|
||||
]);
|
||||
|
||||
$user->announcements()->attach($announcement->id);
|
||||
|
||||
$user->update(['status' => '2']);
|
||||
$user->company->update([
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
DB::afterCommit(
|
||||
fn () => Mail::to($user->email)->send(
|
||||
new AccountVerification($user, 'rejected', $validatedData['rejection_reason'])
|
||||
)
|
||||
);
|
||||
} elseif ($category === 'edit-request' && $user->company->edit_status === '1') {
|
||||
$user->company->update([
|
||||
'edit_status' => '3',
|
||||
'edit_rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
return redirect()
|
||||
->route('dashboard.companies.index')
|
||||
->with('success-status', 'Berhasil menolak'.($category === 'edit-request' ? ' permohonan edit' : '').' perusahaan.');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (processRejectAction): '.$e->getMessage());
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('faileds-status', 'Gagal melakukan proses.');
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new CompanyExport($status, $edit_status, $address, $register_year, $register_month, $register_date), 'companies-'.$formattedNow.'.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (export): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.companies.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (filter): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filter data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$company = Company::with(['user.role'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.companies.print', compact('company'));
|
||||
|
||||
return $pdf->stream('perusahaan-'.slugify($company->name).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (printData): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.contacts.index', [
|
||||
'title' => 'Pesan Kontak',
|
||||
'status' => $request->input('status', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.contacts.show', [
|
||||
'title' => 'Detail Pesan',
|
||||
'contact' => $contact,
|
||||
]);
|
||||
}
|
||||
|
||||
public function reply($id)
|
||||
{
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.contacts.reply', [
|
||||
'title' => 'Balas Pesan',
|
||||
'contact' => $contact,
|
||||
]);
|
||||
}
|
||||
|
||||
public function replyAction(Request $request, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'reply_message' => ['required'],
|
||||
], [
|
||||
'reply_message.required' => 'Pesan balasan wajib diisi.',
|
||||
]);
|
||||
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
|
||||
$contact->update([
|
||||
'reply_message' => $validatedData['reply_message'],
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
return redirect()->route('dashboard.contact.messages.show', ['id' => encrypt_id($contact->id)])->with('success-status', 'Berhasil membalas pesan.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
$contact->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus kontak pesan.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus kontak pesan.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ContentRecapClassificationRequest;
|
||||
use App\Models\ContentRecapClassification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ContentRecapClassificationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.content-recaps.classifications.index', [
|
||||
'title' => 'Klasifikasi Rekap Konten',
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.content-recaps.classifications.create', [
|
||||
'title' => 'Buat Klasifikasi Rekap Konten Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ContentRecapClassificationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$existedData = ContentRecapClassification::withTrashed()->where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if ($existedData && filled($existedData->deleted_at)) {
|
||||
return redirect()->back()->with('data-exists', $validatedData['slug']);
|
||||
} elseif ($existedData) {
|
||||
return redirect()->back()->with('failed-status', 'Tema dengan nama tersebut sudah ada.');
|
||||
}
|
||||
|
||||
$createdClassification = ContentRecapClassification::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecapClassifications (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan klasifikasi rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recap.classifications.index')->with('success-status', 'Berhasil menambahkan klasifikasi rekap konten.')
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.content-recaps.classifications.edit', [
|
||||
'title' => 'Ubah Klasifikasi Rekap Konten',
|
||||
'contentRecapClassification' => $contentRecapClassification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ContentRecapClassificationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
$contentRecapClassification->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecapClassifications (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah klasifikasi rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recap.classifications.show', ['id' => encrypt_id($contentRecapClassification->id)])->with('success-status', 'Berhasil mengubah klasifikasi rekap konten.');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.content-recaps.classifications.show', [
|
||||
'title' => 'Detail Klasifikasi Rekap Konten',
|
||||
'contentRecapClassification' => $contentRecapClassification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
$contentRecapClassification->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus klasifikasi rekap konten.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecapClassifications (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus klasifikasi rekap konten.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function restore($slug)
|
||||
{
|
||||
|
||||
try {
|
||||
$recapContentClassification = ContentRecapClassification::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if (! $recapContentClassification) {
|
||||
return redirect()->back()->with('failed-status', 'Klasifikasi tidak ditemukan.');
|
||||
}
|
||||
|
||||
if (filled($recapContentClassification->deleted_at)) {
|
||||
$recapContentClassification->restore();
|
||||
|
||||
return redirect()->back()->with('success-status', 'Klasifikasi berhasil dipulihkan.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('info-status', 'Klasifikasi sudah aktif.');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecapClassifications (restore): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses pemulihan.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\ContentRecapExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ContentRecapRequest;
|
||||
use App\Models\ContentRecap;
|
||||
use App\Models\ContentRecapClassification;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ContentRecapController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.content-recaps.index', [
|
||||
'title' => 'Rekap Konten',
|
||||
'classifications' => ContentRecapClassification::all(),
|
||||
'channel' => $request->input('channel', null),
|
||||
'classification' => $request->input('classification', null),
|
||||
'social_media' => $request->input('social_media', null),
|
||||
'content_type' => $request->input('content_type', null),
|
||||
'posted_year' => $request->input('posted_year', null),
|
||||
'posted_month' => $request->input('posted_month', null),
|
||||
'posted_date' => $request->input('posted_date', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.content-recaps.create', [
|
||||
'title' => 'Tambah Rekap Konten',
|
||||
'classifications' => ContentRecapClassification::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ContentRecapRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$createdContentRecap = ContentRecap::create($validatedData);
|
||||
|
||||
if ($request->has('image') && filled($validatedData['image'])) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.index')->with('success-status', 'Berhasil menambahkan rekap konten.')
|
||||
->with('new_data', encrypt_id($createdContentRecap->id));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.content-recaps.edit', [
|
||||
'title' => 'Ubah Rekap Konten',
|
||||
'contentRecap' => $contentRecap,
|
||||
'classifications' => ContentRecapClassification::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ContentRecapRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
if ($request->has('image') && filled($validatedData['image'])) {
|
||||
delete_file('app/public/uploads/content-recaps/'.$contentRecap->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['image'] = $contentRecap->image;
|
||||
}
|
||||
|
||||
$contentRecap->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.show', ['id' => encrypt_id($contentRecap->id)])->with('success-status', 'Berhasil mengubah rekap konten.');
|
||||
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.content-recaps.show', [
|
||||
'title' => 'Detail Rekap Konten',
|
||||
'contentRecap' => $contentRecap,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
$contentRecap->delete();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus rekap konten.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus rekap konten.']);
|
||||
}
|
||||
|
||||
public function checkLink(Request $request)
|
||||
{
|
||||
$linkExists = ContentRecap::where('link', $request->link)->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (filter): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filter data.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.index', $filterField);
|
||||
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try {
|
||||
$classification = $request->input('classification', 'all');
|
||||
$channel = $request->input('channel', 'all');
|
||||
$social_media = $request->input('social_media', 'all');
|
||||
$content_type = $request->input('content_type', 'all');
|
||||
$posted_year = $request->input('posted_year', null);
|
||||
$posted_month = $request->input('posted_month', null);
|
||||
$posted_date = $request->input('posted_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new ContentRecapExport($classification, $channel, $social_media, $content_type, $posted_year, $posted_month, $posted_date), 'content-recaps-'.$formattedNow.'.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (export): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$contentRecap = ContentRecap::with(['enhancer', 'classification'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.content-recaps.print', compact('contentRecap'));
|
||||
|
||||
return $pdf->stream(slugify('rekap konten '.$contentRecap->content_theme).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (printData): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\CooperationArchiveExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class CooperationArchiveController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.cooperation-archives.index', [
|
||||
'title' => 'Arsip Kerja Sama',
|
||||
'date' => $request->input('date', null),
|
||||
'month' => $request->input('month', null),
|
||||
'year' => $request->input('year', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
return Excel::download(new CooperationArchiveExport($year, $month, $date), 'cooperation-archives.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.cooperation.archives.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,297 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\CooperationCompletionExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CooperationCompletionRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\CooperationCompletion;
|
||||
use App\Models\Media;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class CooperationCompletionController extends Controller
|
||||
{
|
||||
// Main page: Penyelesaian Kerja Sama
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.cooperation-completions.index', [
|
||||
'title' => 'Penyelesaian Kerja Sama',
|
||||
'mediaCollection' => Media::all(),
|
||||
'media' => $request->input('media', []),
|
||||
'status' => $request->input('status', null),
|
||||
'date' => $request->input('date', null),
|
||||
'from_month' => $request->input('from_month', null),
|
||||
'to_month' => $request->input('to_month', null),
|
||||
'year' => $request->input('year', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(CooperationCompletionRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$validatedData['payment_request_letter'] = store_file($validatedData['payment_request_letter'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['invoice'] = store_file($validatedData['invoice'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['bank_reference'] = store_file($validatedData['bank_reference'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['electronic_tax_invoice'] = store_file($validatedData['electronic_tax_invoice'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
if (isset($validatedData['other_document'])) {
|
||||
$validatedData['other_document'] = store_file($validatedData['other_document'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['other_document'] = null;
|
||||
}
|
||||
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
|
||||
CooperationCompletion::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengirim formulir.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengirim formulir.');
|
||||
}
|
||||
|
||||
public function show($mediaOrderId, $id)
|
||||
{
|
||||
$cooperationCompletion = CooperationCompletion::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-completions.show', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'cooperationCompletion' => $cooperationCompletion,
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function showIndex($id)
|
||||
{
|
||||
$cooperationCompletion = CooperationCompletion::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-completions.index.show', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'cooperationCompletion' => $cooperationCompletion,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processIndex($id)
|
||||
{
|
||||
$cooperationCompletion = CooperationCompletion::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-completions.index.process', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'cooperationCompletion' => $cooperationCompletion,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accept($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$completion->update([
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerja sama <u>'.$completion->order->cooperation->name.'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui laporan formulir penyelesaian kerja sama Anda.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (accept): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui penyelesaian kerja sama');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui penyelesaian kerja sama.');
|
||||
|
||||
}
|
||||
|
||||
public function reject($mediaOrderId, $id)
|
||||
{
|
||||
$cooperationCompletion = CooperationCompletion::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-completions.reject', [
|
||||
'title' => 'Tolak Penyelesaian Kerja Sama',
|
||||
'cooperationCompletion' => $cooperationCompletion,
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id)
|
||||
{
|
||||
|
||||
try {
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$completion->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerja sama <u>'.$completion->order->cooperation->name.'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan formulir penyelesaian kerja sama Anda.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (rejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak penyelesaian kerja sama');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak penyelesaian kerja sama.');
|
||||
|
||||
}
|
||||
|
||||
public function rejectActionIndex(Request $request, $id)
|
||||
{
|
||||
|
||||
try {
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$completion->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerja sama <u>'.$completion->order->cooperation->name.'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan formulir penyelesaian kerja sama Anda.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (rejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak penyelesaian kerja sama');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak penyelesaian kerja sama.');
|
||||
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try {
|
||||
$export_type = $request->input('export_type', 'excel');
|
||||
|
||||
$status = $request->input('status', null);
|
||||
$media = $request->input('media', null);
|
||||
$year = $request->input('year', null);
|
||||
$from_month = $request->input('from_month', null);
|
||||
$to_month = $request->input('to_month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
if ($export_type === 'excel') {
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new CooperationCompletionExport($media, $status, $year, $from_month, $to_month, $date), 'reports-'.$formattedNow.'.xlsx');
|
||||
} elseif ($export_type === 'pdf') {
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = CooperationCompletion::with(['media.company']);
|
||||
} elseif (is_role(['3'])) {
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
$query = CooperationCompletion::with(['media.company', 'order.cooperation'])->where('media_id', '=', $mediaId);
|
||||
}
|
||||
|
||||
if (! empty($media) && is_array($media)) {
|
||||
$query->whereIn('media_id', $media);
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
switch ($status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
case 'accepted':
|
||||
$query->where('status', '1');
|
||||
break;
|
||||
case 'rejected':
|
||||
$query->where('status', '2');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
}
|
||||
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
|
||||
if ($date) {
|
||||
$query->whereDate('created_at', $date);
|
||||
}
|
||||
|
||||
$cooperationCompletions = $query->get();
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.cooperation-completions.prints.collection', compact('cooperationCompletions'));
|
||||
|
||||
return $pdf->stream(slugify('laporan bukti tayang ').'.pdf');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function singlePrint()
|
||||
{
|
||||
try {
|
||||
$cooperationCompletion = CooperationCompletion::with(['media.company'])->first();
|
||||
// dd('hai');
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.cooperation-completions.prints.single', compact('cooperationCompletion'));
|
||||
|
||||
return $pdf->stream(slugify('Penyelesaian kerja sama '.$cooperationCompletion->media->name).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,306 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\JournalistCooperationProposalRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\CooperationProposal;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CooperationRequestController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.cooperation-requests.index', [
|
||||
'title' => 'Ajuan Kerja Sama',
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperationPivot = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first()->pivot;
|
||||
|
||||
return view('dashboard.cooperation-requests.show', [
|
||||
'title' => 'Tolak Kerja Sama',
|
||||
'cooperation' => $cooperation,
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposal()
|
||||
{
|
||||
return view('dashboard.cooperation-requests.media-proposals.index', [
|
||||
'title' => 'Ajuan Kerja Sama Saya',
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalShow($id)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-requests.media-proposals.show', [
|
||||
'title' => 'Detail Ajuan Kerja Sama',
|
||||
'proposal' => $proposal,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accept(Request $request, $id)
|
||||
{
|
||||
|
||||
try {
|
||||
if (! Auth::check() || Auth::user()->role_id !== 3) {
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
$cooperation = Cooperation::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperation = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (! $mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
// Pastikan data yang ingin diperbarui ada dan statusnya belum '3'
|
||||
if ($mediaCooperation->pivot->status == '0') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerja Sama <u>'.$cooperation->name.'</u> <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name.'</u>',
|
||||
'content' => '<p>Ajuan Kerja Sama <u>'.$cooperation->name.'</u> telah <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name.'</u></p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menerima kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menerima kerja sama.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja Sama sudah diterima sebelumnya.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (accept): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createProposal($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperationPivot = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first()->pivot;
|
||||
|
||||
return view('dashboard.cooperation-requests.create-proposal', [
|
||||
'title' => 'Ajukan Kerja Sama',
|
||||
'user' => Auth::user(),
|
||||
'cooperation' => $cooperation,
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot,
|
||||
]);
|
||||
}
|
||||
|
||||
public function storeProposal(JournalistCooperationProposalRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
|
||||
$createdCooperationProposal = CooperationProposal::create($validatedData);
|
||||
$createdCooperationProposal->journalists()->attach($validatedData['journalist_ids']);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.Auth::user()->company->media->name.'</u> telah mengirimkan formulir pengajuan kerja sama <u>'.$cooperation->name.'</u>',
|
||||
'content' => 'Media <u>'.Auth::user()->company->media->name.'</u> telah mengirimkan formulir pengajuan kerja sama <u>'.$cooperation->name.'</u> pada <b>'.idn_date($createdCooperationProposal->created_at, 'l, d F Y H:i').'</b>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($createdCooperationProposal->journalists()->count() <= 0) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::info('ERROR Cooperation Proposals: '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan pengajuan kerja sama');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.cooperations.requests.index')->with('success-status', 'Berhasil melakukan pengajuan kerja sama.');
|
||||
}
|
||||
|
||||
public function reject($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperationPivot = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first()->pivot;
|
||||
|
||||
return view('dashboard.cooperation-requests.reject', [
|
||||
'title' => 'Tolak Kerja Sama',
|
||||
'cooperation' => $cooperation,
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejectAction(Request $request, $id)
|
||||
{
|
||||
|
||||
try {
|
||||
if (! Auth::check() || Auth::user()->role_id !== 3) {
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$cooperation = Cooperation::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperation = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (! $mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
if ($mediaCooperation->pivot->status != '3') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerja Sama <u>'.$cooperation->name.'</u> <span class="text-danger fw-bold">ditolak</span> oleh media <u>'.$mediaCooperation->name.'</u>',
|
||||
'content' => '<p>Ajuan Kerja Sama <u>'.$cooperation->name.'</u> <span class="text-danger">ditolak</span> oleh media <u>'.$mediaCooperation->name.'</u></p>
|
||||
<p>Alasan: <br> '.$validatedData['rejection_reason'].'</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak kerja sama');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja sama sudah ditolak sebelumnya.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (rejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editProposal($id)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-requests.media-proposals.edit', [
|
||||
'title' => 'Ubah Ajuan Kerja Sama',
|
||||
'proposal' => $proposal,
|
||||
'selectedJournalists' => $proposal->journalists->pluck('id')->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateProposal(JournalistCooperationProposalRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
|
||||
try {
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $proposal->cooperation_id;
|
||||
|
||||
if ($request->hasFile('attachment')) {
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
delete_file('app/public/uploads/cooperation-proposals/'.$proposal->image);
|
||||
} else {
|
||||
$validatedData['attachment'] = $proposal->attachment;
|
||||
}
|
||||
|
||||
$proposal->update($validatedData);
|
||||
|
||||
if ($request->has('journalist_ids')) {
|
||||
$proposal->journalists()->sync($validatedData['journalist_ids']);
|
||||
}
|
||||
|
||||
if ($proposal->journalists()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengajuan kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengajuan kerja sama');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (updateProposal): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengajuan kerja sama');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function destroyProposal($id)
|
||||
{
|
||||
try {
|
||||
$cooperationProposal = CooperationProposal::findOrFail(decrypt_id($id));
|
||||
delete_file('app/public/uploads/cooperation-proposals/'.$cooperationProposal->attachment);
|
||||
$cooperationProposal->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus ajuan kerja sama.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (destroyProposal): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus ajuan kerja sama.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\GovernmentAgencyRequest;
|
||||
use App\Models\GovernmentAgency;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GovernmentAgencyController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.government-agencies.index', [
|
||||
'title' => 'Data OPD',
|
||||
'new_data' => session()->get('new_data', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.government-agencies.create', [
|
||||
'title' => 'Buat OPD Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(GovernmentAgencyRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$createdGovernmentAgency = GovernmentAgency::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.government.agencies.index')->with('success-status', 'Berhasil membuat OPD baru.')
|
||||
->with('new_data', encrypt_id($createdGovernmentAgency->id));
|
||||
} catch (\Exception $e) {
|
||||
Log::error('GovernmentAgencies (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan OPD');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.government-agencies.edit', [
|
||||
'title' => 'Ubah OPD',
|
||||
'governmentAgency' => $governmentAgency,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(GovernmentAgencyRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
$governmentAgency->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('GovernmentAgencies (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah OPD');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.government.agencies.show', ['id' => encrypt_id($governmentAgency->id)])->with('success-status', 'Berhasil mengubah OPD.');
|
||||
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$governmentAgency = GovernmentAgency::find(decrypt_id($id));
|
||||
|
||||
return view('dashboard.government-agencies.show', [
|
||||
'title' => 'Detail OPD',
|
||||
'governmentAgency' => $governmentAgency,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
|
||||
$governmentAgency->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus OPD']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('GovernmentAgencies (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus OPD.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,256 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\IssueManagementExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\IssueManagementRequest;
|
||||
use App\Models\Classification;
|
||||
use App\Models\GovernmentAgency;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Location;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\SubClassification;
|
||||
use App\Models\SubLocation;
|
||||
use App\Models\User;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class IssueManagementController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.issue-managements.index', [
|
||||
'title' => 'Manajemen Isu',
|
||||
'classification' => $request->input('classification', null),
|
||||
'sub_classification' => $request->input('sub_classification', null),
|
||||
'location' => $request->input('location', null),
|
||||
'sub_location' => $request->input('sub_location', null),
|
||||
'government_agency' => $request->input('government_agency', null),
|
||||
'media_monitoring' => $request->input('media_monitoring', null),
|
||||
'issue' => $request->input('issue', null),
|
||||
'response' => $request->input('response', null),
|
||||
'year' => $request->input('year', null),
|
||||
'month' => $request->input('month', null),
|
||||
'date' => $request->input('date', null),
|
||||
'start_date' => $request->input('start_date', null),
|
||||
'end_date' => $request->input('end_date', null),
|
||||
'user' => $request->input('user', null),
|
||||
|
||||
'locations' => Location::all(),
|
||||
'sub_locations' => SubLocation::all(),
|
||||
'classifications' => Classification::all(),
|
||||
'sub_classifications' => SubClassification::all(),
|
||||
'government_agencies' => GovernmentAgency::all(),
|
||||
'users' => User::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
return view('dashboard.issue-managements.create', [
|
||||
'title' => 'Tambah Manajemen Isu',
|
||||
'locations' => Location::all(),
|
||||
'classifications' => Classification::all(),
|
||||
'governmentAgencies' => GovernmentAgency::all(),
|
||||
'mediaMonitoring' => MediaMonitoring::with(['enhancer'])->find(decrypt_id($request->input('media_monitoring'))),
|
||||
'mediaMonitoringId' => $request->input('media_monitoring') ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(IssueManagementRequest $request, $media_monitoring_id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_monitoring_id'] = decrypt_id($media_monitoring_id);
|
||||
|
||||
try {
|
||||
$createdIssueManagement = DB::transaction(function () use ($validatedData, $request) {
|
||||
$createdIssueManagement = IssueManagement::create($validatedData);
|
||||
$createdIssueManagement->governmentAgencies()->attach($request->input('government_agencies'));
|
||||
|
||||
return $createdIssueManagement;
|
||||
});
|
||||
|
||||
if ($createdIssueManagement->governmentAgencies()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan manajemen isu.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan manajemen isu');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan manajemen isu');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location',
|
||||
'subLocation',
|
||||
'classification',
|
||||
'subClassification',
|
||||
'mediaMonitoring',
|
||||
'enhancer',
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.issue-managements.edit', [
|
||||
'title' => 'Ubah Manajemen Isu',
|
||||
'locations' => Location::all(),
|
||||
'classifications' => Classification::all(),
|
||||
'governmentAgencies' => GovernmentAgency::all(),
|
||||
'selectedGovernmentAgencies' => $issueManagement->governmentAgencies->pluck('id')->toArray(),
|
||||
'issueManagement' => $issueManagement,
|
||||
'mediaMonitoring' => MediaMonitoring::with(['enhancer'])->find($issueManagement->media_monitoring_id),
|
||||
'mediaMonitoringId' => $request->input('media_monitoring') ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(IssueManagementRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location',
|
||||
'subLocation',
|
||||
'classification',
|
||||
'subClassification',
|
||||
'mediaMonitoring',
|
||||
'enhancer',
|
||||
])->findOrFail(decrypt_id($id));
|
||||
$validatedData['media_monitoring_id'] = $issueManagement->media_monitoring_id;
|
||||
|
||||
$issueManagement->update($validatedData);
|
||||
if ($request->has('government_agencies')) {
|
||||
$issueManagement->governmentAgencies()->sync($validatedData['government_agencies']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah manajemen isu');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.issue.managements.show', ['id' => encrypt_id($issueManagement->id)])->with('success-status', 'Berhasil mengubah manajemen isu.');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location',
|
||||
'subLocation',
|
||||
'classification',
|
||||
'subClassification',
|
||||
'mediaMonitoring',
|
||||
'enhancer',
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.issue-managements.show', [
|
||||
'title' => 'Detail Manajemen Isu',
|
||||
'issueManagement' => $issueManagement,
|
||||
'mediaMonitoring' => MediaMonitoring::with(['enhancer'])->find($issueManagement->media_monitoring_id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$issueManagement = IssueManagement::findOrFail(decrypt_id($id));
|
||||
|
||||
$issueManagement->governmentAgencies()->detach();
|
||||
$issueManagement->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus manajemen isu']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus manajemen isu.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubLocations($location_id)
|
||||
{
|
||||
$subLocations = SubLocation::where('location_id', $location_id)->get();
|
||||
|
||||
return response()->json(['sub_locations' => $subLocations]);
|
||||
}
|
||||
|
||||
public function getSubClassifications($location_id)
|
||||
{
|
||||
$subLocations = SubClassification::where('classification_id', $location_id)->get();
|
||||
|
||||
return response()->json(['sub_classifications' => $subLocations]);
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.issue.managements.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try {
|
||||
$classification = $request->input('classification', null);
|
||||
$sub_classification = $request->input('sub_classification', null);
|
||||
$location = $request->input('location', null);
|
||||
$sub_location = $request->input('sub_location', null);
|
||||
$government_agency = $request->input('government_agency', null);
|
||||
$issue = $request->input('issue', null);
|
||||
$response = $request->input('response', null);
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
$start_date = $request->input('start_date', null);
|
||||
$end_date = $request->input('end_date', null);
|
||||
$user = $request->input('user', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new IssueManagementExport(
|
||||
$classification,
|
||||
$sub_classification,
|
||||
$location,
|
||||
$sub_location,
|
||||
$government_agency,
|
||||
$issue,
|
||||
$response,
|
||||
$year,
|
||||
$month,
|
||||
$date,
|
||||
$start_date,
|
||||
$end_date,
|
||||
$user
|
||||
), 'issue-managements-'.$formattedNow.'.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id)
|
||||
{
|
||||
try {
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location',
|
||||
'subLocation',
|
||||
'classification',
|
||||
'subClassification',
|
||||
'governmentAgencies',
|
||||
'enhancer',
|
||||
'mediaMonitoring',
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.issue-managements.print', compact('issueManagement'));
|
||||
|
||||
return $pdf->stream(slugify('manajemen isu '.$issueManagement->mediaMonitoring->code).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,367 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\JournalistExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\JournalistRequest;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class JournalistController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (is_role(['1', '5'])) {
|
||||
|
||||
if ($request->has('media_ids') && $request->input('media_ids') && count($request->input('media_ids')) > 10) {
|
||||
return redirect()->back()->with('failed-status', 'Hanya bisa memfilter 10 media');
|
||||
}
|
||||
|
||||
return view('dashboard.journalists.admin.index', [
|
||||
'title' => 'Data Jurnalis',
|
||||
'media' => Media::all(),
|
||||
'media_ids' => $request->input('media_ids', null),
|
||||
'status' => $request->input('status', null),
|
||||
'edit_status' => $request->input('edit_status', null),
|
||||
'register_year' => $request->input('register_year', null),
|
||||
'register_month' => $request->input('register_month', null),
|
||||
'register_date' => $request->input('register_date', null),
|
||||
]);
|
||||
} elseif (is_role(['3'])) {
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
return view('dashboard.journalists.index', [
|
||||
'title' => 'Data Jurnalis',
|
||||
'user' => $user,
|
||||
'journalists' => $user->company->media->journalists
|
||||
->where('approved_status', '1')
|
||||
->whereNull('deleted_at'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submission()
|
||||
{
|
||||
return view('dashboard.journalists.submission', [
|
||||
'title' => 'Data Permohonan Penambahan Jurnalis',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processSubmission($id)
|
||||
{
|
||||
$journalist = Journalist::with(['media.company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.journalists.process-submission', [
|
||||
'title' => 'Data Permohonan Penambahan Jurnalis',
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processSubmissionAction(Request $request, $id, $action)
|
||||
{
|
||||
$journalist = Journalist::with(['media.company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if ($action === 'accept') {
|
||||
$acceptedJournalist = $journalist->update([
|
||||
'approved_status' => '1',
|
||||
'approved_at' => now(),
|
||||
]);
|
||||
|
||||
if ($acceptedJournalist) {
|
||||
return response()->json(['message' => 'Berhasil menyetujui jurnalis.']);
|
||||
}
|
||||
|
||||
} elseif ($action === 'reject') {
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
$rejectedJournalist = $journalist->update([
|
||||
'approved_status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
return redirect()->route('dashboard.journalists.submissions')->with('success-status', 'Berhasil menolak jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.journalists.create', [
|
||||
'title' => 'Tambah Data Jurnalis',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(JournalistRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$fileFieldMap = [
|
||||
'journalist_ukw_sertificate_doc' => 'ukw_sertificate_doc',
|
||||
'journalist_press_card_doc' => 'press_card_doc',
|
||||
];
|
||||
|
||||
$journalistFileNames = [];
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists')['randomFileName'];
|
||||
} else {
|
||||
$journalistFileNames[$requestKey] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$createdJournalist = Journalist::create([
|
||||
'name' => $validatedData['journalist_name'],
|
||||
'email' => $validatedData['journalist_email'],
|
||||
'phone_number' => $validatedData['journalist_phone_number'],
|
||||
'press_card' => $validatedData['journalist_press_card'],
|
||||
'press_card_doc' => $journalistFileNames['journalist_press_card_doc'],
|
||||
'ukw_sertificate' => $validatedData['journalist_ukw_sertificate'],
|
||||
'ukw_sertificate_doc' => $journalistFileNames['journalist_ukw_sertificate_doc'],
|
||||
'approved_status' => '0',
|
||||
'approved_at' => null,
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
'media_id' => Auth::user()->company->media->id,
|
||||
]);
|
||||
|
||||
if ($createdJournalist) {
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil menambahkan jurnalis.')->with('created-journalist', true);
|
||||
} else {
|
||||
return redirect()->route('dashboard.journalists.index')->with('failed-status', 'Gagal menambahkan jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function editRequest($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if (! in_array($journalist->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('dashboard.journalists.edit-request', [
|
||||
'title' => 'Permohonan Ubah Data Jurnalis',
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request, $id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if (! in_array($journalist->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'edit_description' => ['required'],
|
||||
], [
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
if (! Auth::check()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$updatedJournalist = $journalist->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description'],
|
||||
]);
|
||||
|
||||
if ($updatedJournalist) {
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil melakukan permohonan edit data jurnalis.');
|
||||
} else {
|
||||
return redirect()->route('dashboard.journalists.index')->with('failed-status', 'Gagal melakukan permohonan edit data jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function processEdit($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if (! in_array($journalist->edit_status, ['1', '2']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('dashboard.journalists.show', [
|
||||
'title' => 'Permohonan Ubah Data Jurnalis',
|
||||
'journalist' => $journalist,
|
||||
'purpose' => 'processEdit',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processEditAction(Request $request, $id, $action)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if (! in_array($journalist->edit_status, ['1']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (is_role(['1'])) {
|
||||
|
||||
if ($action === 'accept') {
|
||||
$acceptedJournalist = $journalist->update([
|
||||
'edit_status' => '2',
|
||||
]);
|
||||
|
||||
if ($acceptedJournalist) {
|
||||
return response()->json(['message' => 'Berhasil menyetujui permohonan edit jurnalis.']);
|
||||
}
|
||||
} elseif ($action === 'reject') {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'edit_rejection_reason' => ['required'],
|
||||
], [
|
||||
'edit_rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$journalist->update([
|
||||
'edit_status' => '3',
|
||||
'edit_rejection_reason' => $validatedData['edit_rejection_reason'],
|
||||
]);
|
||||
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil menolak permohonan edit jurnalis.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.journalists.edit', [
|
||||
'title' => 'Ubah Data Jurnalis',
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(JournalistRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if (! in_array($journalist->edit_status, ['2'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$fileFieldMap = [
|
||||
'journalist_ukw_sertificate_doc' => 'ukw_sertificate_doc',
|
||||
'journalist_press_card_doc' => 'press_card_doc',
|
||||
];
|
||||
|
||||
$journalistFileNames = [];
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists')['randomFileName'];
|
||||
} else {
|
||||
$journalistFileNames[$requestKey] = $journalist->{$dbField};
|
||||
}
|
||||
}
|
||||
|
||||
$createdJournalist = $journalist->update([
|
||||
'name' => $validatedData['journalist_name'],
|
||||
'email' => $validatedData['journalist_email'],
|
||||
'phone_number' => $validatedData['journalist_phone_number'],
|
||||
'press_card' => $validatedData['journalist_press_card'],
|
||||
'press_card_doc' => $journalistFileNames['journalist_press_card_doc'],
|
||||
'ukw_sertificate' => $validatedData['journalist_ukw_sertificate'],
|
||||
'ukw_sertificate_doc' => $journalistFileNames['journalist_ukw_sertificate_doc'],
|
||||
'approved_status' => $journalist->approved_status,
|
||||
'approved_at' => $journalist->approved_at,
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
'media_id' => Auth::user()->company->media->id,
|
||||
]);
|
||||
|
||||
if ($createdJournalist) {
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil mengubah jurnalis.');
|
||||
} else {
|
||||
return redirect()->route('dashboard.journalists.index')->with('failed-status', 'Gagal mengubah jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.journalists.show', [
|
||||
'title' => 'Detail Jurnalis',
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
|
||||
$user = User::with(['company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
$journalists = optional($user->company?->media)->journalists?->whereNull('deleted_at')->where('approved_status', '1');
|
||||
|
||||
if ($journalists->count() <= 1) {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Media harus punya minimal satu jurnalis.',
|
||||
]);
|
||||
}
|
||||
|
||||
$journalist->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus jurnalis.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus jurnalis.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$media_ids = $request->input('media_ids', null);
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new JournalistExport($media_ids, $status, $edit_status, $register_year, $register_month, $register_date), 'journalist-'.$formattedNow.'.xlsx');
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
// Kalau "all" dipilih di media_ids, set ulang jadi hanya ["all"]
|
||||
if (isset($filteredRequest['media_ids']) && in_array('all', $filteredRequest['media_ids'])) {
|
||||
$filteredRequest['media_ids'] = ['all'];
|
||||
} else {
|
||||
// Buang media kosong
|
||||
$filteredRequest['media_ids'] = array_filter($filteredRequest['media_ids'] ?? []);
|
||||
}
|
||||
|
||||
// Filter semua field yang terisi
|
||||
$filterField = array_filter($filteredRequest, fn ($val) => filled($val));
|
||||
|
||||
return redirect()->route('dashboard.journalists.index', $filterField);
|
||||
}
|
||||
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
$journalist = Journalist::with(['media.company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.journalists.print', compact('journalist'));
|
||||
|
||||
return $pdf->stream('perusahaan-'.slugify($journalist->name).'.pdf');
|
||||
}
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\LocationRequest;
|
||||
use App\Models\Location;
|
||||
|
||||
class LocationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.locations.index', [
|
||||
'title' => 'Data Lokus',
|
||||
'new_data' => session()->get('new_data', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.locations.create', [
|
||||
'title' => 'Buat Lokus Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(LocationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$createdLocation = Location::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.locations.index')->with('success-status', 'Berhasil membuat lokus baru.')
|
||||
->with('new_data', encrypt_id($createdLocation->id));
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.locations.edit', [
|
||||
'title' => 'Ubah Lokus',
|
||||
'location' => $location,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(LocationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
$location->update($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.locations.show', ['id' => encrypt_id($location->id)])->with('success-status', 'Berhasil mengubah lokus.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.locations.show', [
|
||||
'title' => 'Detail Lokus',
|
||||
'location' => $location,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
$location->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus lokus.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus lokus.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class LogActivityController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.log-activities.index', [
|
||||
'title' => 'Log',
|
||||
'year' => $request->input('year', null),
|
||||
'from_month' => $request->input('from_month', null),
|
||||
'to_month' => $request->input('to_month', null),
|
||||
'date' => $request->input('date', null),
|
||||
'event' => $request->input('event', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$log = Activity::findOrFail(decrypt_id($id));
|
||||
|
||||
// dd($log);
|
||||
return view('dashboard.log-activities.show', [
|
||||
'title' => 'Log',
|
||||
'log' => $log,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginHistoryController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.login-history.index', [
|
||||
'title' => 'Aktivitas Login',
|
||||
'year' => $request->input('year', null),
|
||||
'month' => $request->input('month', null),
|
||||
'date' => $request->input('date', null),
|
||||
'role' => $request->input('role', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.login.history.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filtering data.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,336 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\MediaExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\MediaRequest;
|
||||
use App\Models\LoginHistory;
|
||||
use App\Models\Media;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class MediaController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (is_role(['1', '5'])) {
|
||||
return view('dashboard.media.admin.index', [
|
||||
'title' => 'Data Media',
|
||||
'type' => $request->input('type', null),
|
||||
'classification' => $request->input('classification', null),
|
||||
'status' => $request->input('status', null),
|
||||
'edit_status' => $request->input('edit_status', null),
|
||||
'address' => $request->input('address', null),
|
||||
'register_year' => $request->input('register_year', null),
|
||||
'register_month' => $request->input('register_month', null),
|
||||
'register_date' => $request->input('register_date', null),
|
||||
]);
|
||||
} elseif (is_role(['3'])) {
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
$data = [
|
||||
'title' => 'Data Media',
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
return view('dashboard.media.index', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function editRequest()
|
||||
{
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('dashboard.media.edit-request', [
|
||||
'title' => 'Permohonan Ubah Data Media',
|
||||
]);
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request)
|
||||
{
|
||||
try {
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'edit_description' => ['required'],
|
||||
], [
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
if (! Auth::check()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$user = User::with(['company.media'])->findOrFail(Auth::id());
|
||||
$user->company->media->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description'],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('dashboard.media.index')->with('failed-status', 'Gagal melakukan permohonan edit data media.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil melakukan permohonan edit data media.');
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['2'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
return view('dashboard.media.edit', [
|
||||
'title' => 'Ubah Data Media',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(MediaRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['2'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$media = User::with(['company.media'])->findOrFail(Auth::id())->company->media;
|
||||
|
||||
$fileFieldMap = [
|
||||
'media_journalism_organization_doc' => 'journalism_organization_doc',
|
||||
'media_press_council_certificate_doc' => 'press_council_certificate_doc',
|
||||
];
|
||||
|
||||
$mediaFileNames = [];
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$mediaFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/media')['randomFileName'];
|
||||
} else {
|
||||
$mediaFileNames[$requestKey] = $media->{$dbField};
|
||||
}
|
||||
}
|
||||
|
||||
$updatedMedia = $media->update([
|
||||
'name' => $validatedData['media_name'],
|
||||
'address' => $validatedData['media_address'],
|
||||
'link' => $validatedData['media_link'],
|
||||
'type' => $validatedData['media_type'],
|
||||
'classification' => $validatedData['media_classification'],
|
||||
'journalism_organization' => $validatedData['media_journalism_organization'],
|
||||
'journalism_organization_doc' => $mediaFileNames['media_journalism_organization_doc'],
|
||||
'press_council_certificate' => $validatedData['media_press_council_certificate'],
|
||||
'press_council_certificate_doc' => $mediaFileNames['media_press_council_certificate_doc'],
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('dashboard.media.index')->with('failed-status', 'Gagal mengubah data media.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil mengubah data media.');
|
||||
}
|
||||
|
||||
public function show($id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
'title' => 'Data Media',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'media',
|
||||
'purpose' => 'show',
|
||||
'idnPage' => 'media',
|
||||
'route' => 'media',
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // optional: menangani type yang tidak dikenal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'warning',
|
||||
'message' => 'Aksi belum tersedia.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function process(Request $request, $id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if ($request->query('category') && ! in_array($request->query('category'), ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => 'Data Media',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'media',
|
||||
'purpose' => 'process',
|
||||
'idnPage' => 'media',
|
||||
'route' => 'media',
|
||||
'type' => $type,
|
||||
'category' => $request->query('category', null),
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // atau bisa redirect atau response lainnya jika $type tidak valid
|
||||
}
|
||||
}
|
||||
|
||||
public function processAcceptAction(Request $request, $id, $type, $category)
|
||||
{
|
||||
$user = User::with(['company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if (! in_array($category, ['account-status', 'edit-request']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (is_role(['1']) && $category === 'edit-request') {
|
||||
$user->company->media->update([
|
||||
'edit_status' => '2',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Berhasil menyetujui permohonan edit media.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processRejectAction(Request $request, $id, $type, $category)
|
||||
{
|
||||
$user = User::with(['company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if (! in_array($category, ['account-status', 'edit-request']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (is_role(['1'])) {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
if ($category === 'edit-request' && $user->company->media->edit_status === '1') {
|
||||
$user->company->media->update([
|
||||
'edit_status' => '3',
|
||||
'edit_rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil menolak permohonan edit media.');
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try {
|
||||
$type = $request->input('type', null);
|
||||
$classification = $request->input('classification', null);
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new MediaExport($type, $classification, $status, $edit_status, $address, $register_year, $register_month, $register_date), 'media-'.$formattedNow.'.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.media.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$media = Media::with(['user.role', 'company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.media.print', compact('media'));
|
||||
|
||||
return $pdf->stream('media-'.slugify($media->name).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,599 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\CooperationExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CooperationRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\CooperationProposal;
|
||||
use App\Models\Media;
|
||||
use App\Models\MediaOrder;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class MediaCooperationController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.media-cooperations.index', [
|
||||
'title' => 'Kerja Sama',
|
||||
'date' => $request->input('date', null),
|
||||
'month' => $request->input('month', null),
|
||||
'year' => $request->input('year', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.media-cooperations.create', [
|
||||
'title' => 'Tambah Kerja Sama',
|
||||
'media' => Media::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(CooperationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
if ($request->hasFile('banner')) {
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
}
|
||||
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
|
||||
$createdCooperation = DB::transaction(function () use ($validatedData) {
|
||||
$createdCooperation = Cooperation::create($validatedData);
|
||||
|
||||
$allMediaIds = Media::pluck('id')->toArray();
|
||||
if (in_array('all', $validatedData['media_ids'])) {
|
||||
$createdCooperation->media()->attach($allMediaIds);
|
||||
} else {
|
||||
$createdCooperation->media()->attach($validatedData['media_ids']);
|
||||
}
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
if (in_array('all', $validatedData['media_ids'])) {
|
||||
foreach ($allMediaIds as $mediaId) {
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
} else {
|
||||
foreach ($validatedData['media_ids'] as $mediaId) {
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
}
|
||||
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan kerja sama baru: <u>'.$createdCooperation->name.'</u>',
|
||||
'content' => '<p>Kerja Sama: <b>'.$validatedData['name'].'</b> </p>
|
||||
<p>Periode Pengajuan: <b>'.idn_date($createdCooperation->start_date).'</b> s.d. <b>'.idn_date($createdCooperation->end_date).'</b></p>
|
||||
<p>Deskripsi: <br>
|
||||
'.$createdCooperation->description.'
|
||||
</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
return $createdCooperation;
|
||||
});
|
||||
|
||||
if ($createdCooperation->media()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.index')->with('success-status', 'Berhasil menambahkan kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan kerja sama');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::info('ERROR (Cooperation): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan kerja sama');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-cooperations.edit', [
|
||||
'title' => 'Ubah Kerja Sama',
|
||||
'cooperation' => $cooperation,
|
||||
'media' => Media::all(),
|
||||
'selectedMediaIds' => $cooperation->media->pluck('id')->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(CooperationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
$oldCooperationName = $cooperation->name;
|
||||
|
||||
if ($request->hasFile('banner')) {
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->banner);
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['banner'] = $cooperation->banner;
|
||||
}
|
||||
|
||||
if ($request->hasFile('offer_file_template')) {
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->offer_file_template);
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['offer_file_template'] = $cooperation->offer_file_template;
|
||||
}
|
||||
|
||||
$cooperation->update($validatedData);
|
||||
if ($request->has('media_ids')) {
|
||||
$cooperation->media()->sync($validatedData['media_ids']);
|
||||
}
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach ($validatedData['media_ids'] as $mediaId) {
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
|
||||
$announcementData = [
|
||||
'headline' => 'Admin melakukan pembaruan pada ajuan kerja sama <u>'.$oldCooperationName.'</u>',
|
||||
'content' => '<p>Admin telah melakukan pembaruan pada kerja sama <u>'.$oldCooperationName.'</u>.
|
||||
Mohon untuk segera meninjau perubahan tersebut</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($cooperation->media()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah kerja sama');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah kerja sama');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$mediaCooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-cooperations.show', [
|
||||
'title' => 'Detail Kerja Sama',
|
||||
'mediaCooperation' => $mediaCooperation,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new CooperationExport($year, $month, $date), 'cooperations-'.$formattedNow.'.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.cooperations.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function mediaProposal($id)
|
||||
{
|
||||
$mediaCooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-cooperations.media-proposals.index', [
|
||||
'title' => 'Data Pengajuan Kerja Sama',
|
||||
'mediaCooperation' => $mediaCooperation,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalShow($id, $proposalId)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
return view('dashboard.media-cooperations.media-proposals.show', [
|
||||
'title' => 'Detail Ajuan Kerja Sama',
|
||||
'proposal' => $proposal,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalAccept($id, $proposalId)
|
||||
{
|
||||
|
||||
try {
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
$acceptedProposal = $proposal->update([
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerja sama <u>'.$proposal->cooperation->name.'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui formulir pengajuan kerja sama Anda.</p>
|
||||
<p>Sekarang, kerja sama ini sudah tersedia di menu <b>Kerja Sama</b>. Harap tunggu hingga Admin menerbitkan <b>Media Order</b>.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($acceptedProposal) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui pengajuan kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui pengajuan kerja sama');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui pengajuan kerja sama');
|
||||
}
|
||||
}
|
||||
|
||||
public function mediaProposalReject($id, $proposalId)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
return view('dashboard.media-cooperations.media-proposals.reject', [
|
||||
'title' => 'Tolak Ajuan Kerja Sama',
|
||||
'proposal' => $proposal,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalRejectAction(Request $request, $id, $proposalId)
|
||||
{
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try {
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
$rejectedProposal = $proposal->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerja sama <u>'.$proposal->cooperation->name.'</u> <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak formulir pengajuan kerja sama Anda.
|
||||
<p>Alasan penolakan:<br> '.$validatedData['rejection_reason'].' </p>
|
||||
</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($rejectedProposal) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak pengajuan kerja sama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak pengajuan kerja sama');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak pengajuan kerja sama');
|
||||
}
|
||||
}
|
||||
|
||||
public function process($id, $process, $paramMediaId = null)
|
||||
{
|
||||
$mediaCooperation = Cooperation::with([
|
||||
'media',
|
||||
'mediaOrder.media',
|
||||
'mediaOrder.reports',
|
||||
'mediaOrder.completions',
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
'process' => $process,
|
||||
'mediaCooperation' => $mediaCooperation,
|
||||
'mediaOrder' => $mediaCooperation->mediaOrder,
|
||||
'mediaId' => is_role(['3']) ? Auth::user()->company->media->id : null,
|
||||
];
|
||||
|
||||
if (is_role(['3']) && $data['mediaOrder'] && $data['mediaOrder']->reports) {
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
|
||||
if (filled($reports)) {
|
||||
$isAllReportsAccepted = $reports->every(function ($item) {
|
||||
return $item->status === '1';
|
||||
});
|
||||
|
||||
$data['isAllReportsAccepted'] = $isAllReportsAccepted && ($reports->count() === $data['mediaOrder']->required_reports);
|
||||
$data['isHaveReports'] = true;
|
||||
} else {
|
||||
$data['isAllReportsAccepted'] = false;
|
||||
$data['isHaveReports'] = false;
|
||||
}
|
||||
} else {
|
||||
$data['isAllReportsAccepted'] = false;
|
||||
$data['isHaveReports'] = false;
|
||||
}
|
||||
|
||||
// Tab Kerja Sama
|
||||
if ($process === 'cooperation') {
|
||||
$data['title'] = 'Detail Kerja Sama';
|
||||
|
||||
if (is_role(['3'])) {
|
||||
$mediaOrderSafe = $data['mediaOrder'] ? $data['mediaOrder']->media->where('id', $data['mediaId'])->first() : null;
|
||||
|
||||
if ($mediaOrderSafe) {
|
||||
$data['mediaOrderPivot'] = $mediaOrderSafe->pivot;
|
||||
}
|
||||
|
||||
// Can Commented
|
||||
if ($mediaOrderSafe) {
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
} else {
|
||||
$reports = null;
|
||||
}
|
||||
|
||||
if (filled($reports)) {
|
||||
$data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
return $item->status === '1';
|
||||
});
|
||||
$data['isHaveReports'] = true;
|
||||
} else {
|
||||
$data['isAllReportsAccepted'] = false;
|
||||
$data['isHaveReports'] = false;
|
||||
}
|
||||
// Can Commented
|
||||
|
||||
}
|
||||
|
||||
return view('dashboard.media-cooperations.processes.cooperations.index', $data);
|
||||
|
||||
// Tab Media order
|
||||
} elseif ($process === 'media-order') {
|
||||
$data['title'] = 'Media Order';
|
||||
|
||||
if (is_role(['3'])) {
|
||||
$data['mediaOrderPivot'] = $data['mediaOrder']->media->where('id', $data['mediaId'])->first()->pivot;
|
||||
|
||||
// Can Commented
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
|
||||
if (filled($reports)) {
|
||||
$data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
return $item->status === '1';
|
||||
});
|
||||
$data['isHaveReports'] = true;
|
||||
} else {
|
||||
$data['isAllReportsAccepted'] = false;
|
||||
$data['isHaveReports'] = false;
|
||||
}
|
||||
// Can Commented
|
||||
|
||||
}
|
||||
|
||||
return view('dashboard.media-cooperations.processes.media-orders.index', $data);
|
||||
|
||||
// Tab laporan
|
||||
} elseif ($process === 'reports') {
|
||||
$data['title'] = 'Laporan';
|
||||
// dd($data['mediaOrder']);
|
||||
if (is_role(['3'])) {
|
||||
$data['mediaOrderPivot'] = $data['mediaOrder']?->media->where('id', $data['mediaId'])->first()->pivot;
|
||||
|
||||
$data['reporterMediaId'] = Auth::user()->company->media->id;
|
||||
// Can Commented
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
|
||||
// if(filled($reports)){
|
||||
// $data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
// return $item->status === '1';
|
||||
// });
|
||||
// $data['isHaveReports'] = true;
|
||||
// }else{
|
||||
// $data['isAllReportsAccepted'] = false;
|
||||
// $data['isHaveReports'] = false;
|
||||
// }
|
||||
// Can Commented
|
||||
// dd($reports);
|
||||
|
||||
$reportCount = $reports->count();
|
||||
$data['reportCount'] = $reportCount;
|
||||
|
||||
$data['cooperationCompletion'] = $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first();
|
||||
|
||||
if ($reportCount === $data['mediaOrder']->required_reports) {
|
||||
$data['isReportsCompleted'] = true;
|
||||
} else {
|
||||
$data['isReportsCompleted'] = false;
|
||||
}
|
||||
|
||||
return view('dashboard.media-cooperations.processes.reports.index-media', $data);
|
||||
} else {
|
||||
$data['mediaOrder'] = $mediaCooperation->mediaOrder;
|
||||
$data['reporterMedia'] = $paramMediaId ? Media::findOrFail(decrypt_id($paramMediaId)) : null;
|
||||
$data['reporterMediaId'] = $paramMediaId ? decrypt_id($paramMediaId) : null;
|
||||
|
||||
if (! $paramMediaId) {
|
||||
return view('dashboard.media-cooperations.processes.reports.index-admin', $data);
|
||||
} else {
|
||||
return view('dashboard.media-cooperations.processes.reports.index-media', $data);
|
||||
}
|
||||
}
|
||||
|
||||
// if (is_role(['3'])) {
|
||||
// // Pastikan mediaOrder dan relasi media tidak null
|
||||
// if ($data['mediaOrder'] && $data['mediaOrder']->media && $data['mediaOrder']->media->where('id', $data['mediaId'])->first()) {
|
||||
// $mediaOrderItem = $data['mediaOrder']->media->where('id', $data['mediaId'])->first();
|
||||
// $data['mediaOrderPivot'] = $mediaOrderItem->pivot;
|
||||
// } else {
|
||||
// $data['mediaOrderPivot'] = null; // atau abort(404) jika dianggap error penting
|
||||
// }
|
||||
|
||||
// $data['reporterMediaId'] = Auth::user()->company->media->id;
|
||||
|
||||
// // Can Commented
|
||||
// $reports = null;
|
||||
|
||||
// if ($data['mediaOrder'] && $data['mediaOrder']->reports) {
|
||||
// $reports = $data['mediaOrder']->reports->filter(function ($report) use ($data) {
|
||||
// return $report->media_id == Auth::user()->company->media->id;
|
||||
// });
|
||||
// }
|
||||
|
||||
// if (filled($reports)) {
|
||||
// $data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
// return $item->status === '1';
|
||||
// });
|
||||
// $data['isHaveReports'] = true;
|
||||
// } else {
|
||||
// $data['isAllReportsAccepted'] = false;
|
||||
// $data['isHaveReports'] = false;
|
||||
// }
|
||||
// // Can Commented
|
||||
|
||||
// $reportCount = filled($reports) ? $reports->count() : 0;
|
||||
// $data['reportCount'] = $reportCount;
|
||||
|
||||
// $data['cooperationCompletion'] = $data['mediaOrder'] && $data['mediaOrder']->completions()
|
||||
// ? $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first()
|
||||
// : null;
|
||||
|
||||
// if ($data['mediaOrder'] && $reportCount === $data['mediaOrder']->required_reports) {
|
||||
// $data['isReportsCompleted'] = true;
|
||||
// } else {
|
||||
// $data['isReportsCompleted'] = false;
|
||||
// }
|
||||
|
||||
// // $data['meuda']
|
||||
|
||||
// // dd($mediaCooperation);
|
||||
|
||||
// return view('dashboard.media-cooperations.processes.reports.index-media', $data);
|
||||
// } else {
|
||||
// $data['mediaOrder'] = $mediaCooperation->mediaOrder;
|
||||
// $data['reporterMedia'] = $paramMediaId ? Media::findOrFail(decrypt_id($paramMediaId)) : null;
|
||||
// $data['reporterMediaId'] = $paramMediaId ? decrypt_id($paramMediaId) : null;
|
||||
|
||||
// if (!$paramMediaId) {
|
||||
// return view('dashboard.media-cooperations.processes.reports.index-admin', $data);
|
||||
// } else {
|
||||
// return view('dashboard.media-cooperations.processes.reports.index-media', $data);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Tab Selesai
|
||||
} elseif ($process === 'completion') {
|
||||
$data['title'] = 'Penyelesaian';
|
||||
|
||||
$data['isHaveReports'] = true;
|
||||
$data['isAllReportsAccepted'] = true;
|
||||
|
||||
$data['cooperationCompletion'] = $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first();
|
||||
|
||||
if (is_role(['3'])) {
|
||||
$data['mediaOrderPivot'] = $data['mediaOrder']->media->where('id', $data['mediaId'])->first()->pivot;
|
||||
|
||||
// Can Commented
|
||||
// $reports = $data['mediaOrder']->reports->filter(function ($reports) use ($data) {
|
||||
// return $reports->media_id == Auth::user()->company->media->id;
|
||||
// });
|
||||
|
||||
// if(filled($reports)){
|
||||
// $data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
// return $item->status === '1';
|
||||
// });
|
||||
// $data['isHaveReports'] = true;
|
||||
// }else{
|
||||
// $data['isAllReportsAccepted'] = false;
|
||||
// $data['isHaveReports'] = false;
|
||||
// }
|
||||
// Can Commented
|
||||
|
||||
return view('dashboard.media-cooperations.processes.completions.index-media', $data);
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
} elseif ($process === 'completions') {
|
||||
$data['title'] = 'Penyelesaian';
|
||||
|
||||
$data['isHaveReports'] = true;
|
||||
$data['isAllReportsAccepted'] = true;
|
||||
|
||||
$data['cooperationCompletion'] = $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first();
|
||||
|
||||
if (is_role(['1'])) {
|
||||
return view('dashboard.media-cooperations.processes.completions.index-admin', $data);
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$cooperation = Cooperation::with(['media', 'mediaOrder'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if ($cooperation->mediaOrder) {
|
||||
|
||||
DB::transaction(function () use ($cooperation) {
|
||||
$cooperation->media()->detach();
|
||||
$cooperation->delete();
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ajuan kerja sama dan semua media berhasil dihapus.',
|
||||
]);
|
||||
} else {
|
||||
return response()->json(['message' => 'Kerja Sama sudah memiliki media order.'], 500);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus ajuan kerja sama.'], 500);
|
||||
}
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'warning',
|
||||
// 'message' => 'Aksi belum tersedia.'
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\MediaMonitoringExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\MediaMonitoringRequest;
|
||||
use App\Models\MediaMonitoring;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class MediaMonitoringController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.media-monitorings.index', [
|
||||
'title' => 'Monitoring Media',
|
||||
'news_title' => $request->input('news_title', null),
|
||||
'channel' => $request->input('channel', null),
|
||||
'issue_status' => $request->input('issue_status', null),
|
||||
'keyword' => $request->input('keyword', null),
|
||||
'input_year' => $request->input('input_year', null),
|
||||
'input_month' => $request->input('input_month', null),
|
||||
'input_date' => $request->input('input_date', null),
|
||||
'release_year' => $request->input('release_year', null),
|
||||
'release_month' => $request->input('release_month', null),
|
||||
'release_date' => $request->input('release_date', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.media-monitorings.create', [
|
||||
'title' => 'Tambah Monitoring Media',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(MediaMonitoringRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$latestCode = MediaMonitoring::max('code');
|
||||
$lastNumber = $latestCode ? intval(substr($latestCode, 3)) : 0;
|
||||
$newNumber = str_pad($lastNumber + 1, 6, '0', STR_PAD_LEFT);
|
||||
$code = 'ADN'.$newNumber;
|
||||
|
||||
$validatedData['code'] = $code;
|
||||
$validatedData['image'] = store_file($validatedData['image'], 'uploads/media-monitorings')['randomFileName'];
|
||||
|
||||
MediaMonitoring::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan monitoring media.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan monitoring media.');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-monitorings.edit', [
|
||||
'title' => 'Ubah Monitoring Media',
|
||||
'mediaMonitoring' => $mediaMonitoring,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(MediaMonitoringRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
$validatedData['code'] = $mediaMonitoring->code;
|
||||
|
||||
if ($request->has('image')) {
|
||||
delete_file('app/public/uploads/media-monitorings/'.$mediaMonitoring->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-monitorings')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['image'] = $mediaMonitoring->image;
|
||||
}
|
||||
|
||||
$mediaMonitoring->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah monitoring media.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.monitorings.show', ['id' => encrypt_id($mediaMonitoring->id)])->with('success-status', 'Berhasil mengubah monitoring media.');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-monitorings.show', [
|
||||
'title' => 'Detail Monitoring Media',
|
||||
'mediaMonitoring' => $mediaMonitoring,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
delete_file('app/public/uploads/media-monitorings/'.$mediaMonitoring->image);
|
||||
$mediaMonitoring->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus monitoring media.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus monitoring media.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkLink(Request $request)
|
||||
{
|
||||
$linkExists = MediaMonitoring::where('link', $request->link)->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.media.monitorings.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$news_title = $request->input('news_title', null);
|
||||
$channel = $request->input('channel', 'all');
|
||||
$issue_status = $request->input('issue_status', 'all');
|
||||
$keyword = $request->input('keywords', 'all');
|
||||
$input_year = $request->input('input_year', null);
|
||||
$input_month = $request->input('input_month', null);
|
||||
$input_date = $request->input('input_date', null);
|
||||
$release_year = $request->input('release_year', null);
|
||||
$release_month = $request->input('release_month', null);
|
||||
$release_date = $request->input('release_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new MediaMonitoringExport($news_title, $channel, $issue_status, $keyword, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date), 'media-monitoring-'.$formattedNow.'.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$mediaMonitoring = MediaMonitoring::with(['enhancer', 'issue'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.media-monitorings.print', compact('mediaMonitoring'));
|
||||
|
||||
return $pdf->stream(slugify('monitoring media '.$mediaMonitoring->code).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,230 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\OrderRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\Media;
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MediaOrderController extends Controller
|
||||
{
|
||||
public function create($id)
|
||||
{
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$media = $cooperation->proposals->where('status', '1')->pluck('media_id');
|
||||
|
||||
return view('dashboard.media-orders.create', [
|
||||
'title' => 'Buat Media Order',
|
||||
'cooperation' => $cooperation,
|
||||
'media' => Media::all(),
|
||||
'acceptedMedia' => $media,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(OrderRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
if ($request->hasFile('image')) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $cooperation->id;
|
||||
|
||||
$createdOrder = DB::transaction(function () use ($validatedData, $cooperation) {
|
||||
$createdOrder = Order::create($validatedData);
|
||||
$createdOrder->media()->attach($validatedData['media_ids']);
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach ($validatedData['media_ids'] as $mediaId) {
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
|
||||
$announcementData = [
|
||||
'headline' => '<p>Admin telah menerbitkan media order kerja sama <u>'.$cooperation->name.'</u></p>',
|
||||
'content' => '<p>Admin telah menerbitkan media order kerja sama '.$cooperation->name.'</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
return $createdOrder;
|
||||
});
|
||||
|
||||
if ($createdOrder->media()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.process', ['id' => encrypt_id($cooperation->id), 'process' => 'media-order'])->with('success-status', 'Berhasil membuat media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat media order');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat media order');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
// $cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaOrder = Order::findOrFail(decrypt_id($id));
|
||||
$media = $mediaOrder->cooperation->proposals->where('status', '1')->pluck('media_id');
|
||||
|
||||
// dd($mediaOrder->media->pluck('id'));
|
||||
|
||||
return view('dashboard.media-orders.edit', [
|
||||
'title' => 'Buat Media Order',
|
||||
'cooperation' => $mediaOrder->cooperation,
|
||||
'mediaOrder' => $mediaOrder,
|
||||
'media' => Media::all(),
|
||||
'acceptedMedia' => $media,
|
||||
'acceptedMediaNow' => $mediaOrder->media->pluck('id'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(OrderRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$mediaOrder = Order::findOrFail(decrypt_id($id));
|
||||
|
||||
$validatedData['cooperation_id'] = $mediaOrder->cooperation_id;
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/media-orders/'.$mediaOrder->image);
|
||||
} else {
|
||||
$validatedData['image'] = $mediaOrder->image;
|
||||
}
|
||||
|
||||
$mediaOrder->update($validatedData);
|
||||
|
||||
if ($request->has('media_ids')) {
|
||||
$mediaOrder->media()->sync($validatedData['media_ids']);
|
||||
}
|
||||
|
||||
if ($mediaOrder->media()->exists()) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah media order');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah media order');
|
||||
}
|
||||
}
|
||||
|
||||
public function accept(Request $request, $id)
|
||||
{
|
||||
if (! Auth::check() || Auth::user()->role_id !== 3) {
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
$order = Order::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaOrder = $order->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (! $mediaOrder) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
if ($mediaOrder->pivot->status == '0') {
|
||||
$affectedRows = $order->media()->updateExistingPivot($mediaOrder->id, [
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.$mediaOrder->name.'</u> telah <span class="text-primary">menerima</span> media order kerja sama <b>'.$order->cooperation->name.'</b>',
|
||||
'content' => 'Media <u>'.$mediaOrder->name.'</u> telah <span class="text-primary">menerima</span> media order kerja sama <u>'.$order->cooperation->name.'</u>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menerima media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menerima media order.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja sama sudah diterima sebelumnya.');
|
||||
}
|
||||
}
|
||||
|
||||
public function reject(Request $request, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
$order = Order::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaOrder = $order->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (! $mediaOrder) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
if ($mediaOrder->pivot->status == '0') {
|
||||
$affectedRows = $order->media()->updateExistingPivot($mediaOrder->id, [
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.$mediaOrder->name.'</u> <span class="text-danger">menolak</span> media order kerja sama <u>'.$order->cooperation->name.'</u>',
|
||||
'content' => 'Media <u>'.$mediaOrder->name.'</u> <span class="text-danger">menolak</span> media order kerja sama <u>'.$order->cooperation->name.'</u>
|
||||
<p>Alasan: <br> '.$validatedData['rejection_reason'].'</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak media order.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja sama sudah diterima sebelumnya.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak media order.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,191 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\NewsExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\NewsRequest;
|
||||
use App\Models\News;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.news.index', [
|
||||
'title' => 'Data Berita',
|
||||
'category' => $request->input('category', null),
|
||||
'year' => $request->input('year', null),
|
||||
'month' => $request->input('month', null),
|
||||
'date' => $request->input('date', null),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.news.create', [
|
||||
'title' => 'Buat Berita Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(NewsRequest $request)
|
||||
{
|
||||
// dd('hai');
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$isNewsExists = News::withTrashed()->where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if ($isNewsExists) {
|
||||
return redirect()->back()->with('failed-status', 'Maaf, berita dengan judul tersebut sudah pernah ditambahkan.');
|
||||
}
|
||||
|
||||
try {
|
||||
if ($request->has('image')) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
}
|
||||
News::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat berita baru.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.news.index')->with('success-status', 'Berhasil membuat berita baru.');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.news.edit', [
|
||||
'title' => 'Ubah Berita',
|
||||
'news' => $news,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(NewsRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
if ($request->has('image')) {
|
||||
delete_file('uploads/news/'.$news->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
} else {
|
||||
$validatedData['image'] = $news->image;
|
||||
}
|
||||
|
||||
$isNewsExists = News::where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if ($isNewsExists && $isNewsExists->id !== $news->id) {
|
||||
return redirect()->back()->with('failed-status', 'Maaf, berita dengan judul tersebut sudah pernah ditambahkan.');
|
||||
}
|
||||
|
||||
$news->update($validatedData);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah berita.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah berita.');
|
||||
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.news.show', [
|
||||
'title' => 'Detail Berita',
|
||||
'news' => $news,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
DB::transaction(function () use ($news) {
|
||||
|
||||
$newSlug = Str::limit($news->slug.'-deleted-'.now()->timestamp, 191);
|
||||
|
||||
$news->update([
|
||||
'slug' => $newSlug,
|
||||
]);
|
||||
|
||||
$news->delete();
|
||||
});
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus berita.']);
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Berita tidak ditemukan.'], 404);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Gagal menghapus berita: '.$e->getMessage());
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus berita.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$category = $request->input('category', 'all');
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
return Excel::download(new NewsExport($category, $year, $month, $date), 'news.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.news.index', $filterField);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function printData($slug)
|
||||
{
|
||||
|
||||
try {
|
||||
$news = News::where('slug', $slug)->first();
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.news.print', compact('news'));
|
||||
|
||||
return $pdf->stream('berita-'.$news->slug.'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function checkLink(Request $request)
|
||||
{
|
||||
$linkExists = News::where('link', $request->link)->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,249 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ContentRecap;
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\CooperationCompletion;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Media;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\MediaOrder;
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class OverviewController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Ikhtisar',
|
||||
];
|
||||
|
||||
$year = $request->input('year') ? $request->input('year') : Carbon::now()->year;
|
||||
|
||||
if (is_role(['3'])) {
|
||||
// Statistik Isu
|
||||
$issues = IssueManagement::all();
|
||||
$issueCounts = $issues->groupBy('issue')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
|
||||
$data['crisisIssue'] = $issueCounts->get('krisis', 0);
|
||||
$data['negativeIssue'] = $issueCounts->get('negatif', 0);
|
||||
$data['neutralIssue'] = $issueCounts->get('netral', 0);
|
||||
$data['positiveIssue'] = $issueCounts->get('positif', 0);
|
||||
// Akhir Statistik Isu
|
||||
|
||||
// Statistik Monitoring Media
|
||||
$mediaMonitorings = MediaMonitoring::all();
|
||||
|
||||
$mediaMonitoringCount = $mediaMonitorings->groupBy('channel')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
|
||||
$data['facebookMediaMonitoring'] = $mediaMonitoringCount->get('facebook', 0);
|
||||
$data['twitterMediaMonitoring'] = $mediaMonitoringCount->get('twitter', 0);
|
||||
$data['websiteMediaMonitoring'] = $mediaMonitoringCount->get('website', 0);
|
||||
$data['youtubeMediaMonitoring'] = $mediaMonitoringCount->get('youtube', 0);
|
||||
$data['instagramMediaMonitoring'] = $mediaMonitoringCount->get('instagram', 0);
|
||||
$data['tiktokMediaMonitoring'] = $mediaMonitoringCount->get('tiktok', 0);
|
||||
$data['cetakMediaMonitoring'] = $mediaMonitoringCount->get('cetak', 0);
|
||||
// Akhir Statistik Monitoring Media
|
||||
|
||||
// Statistik Media Order
|
||||
$mediaOrder = MediaOrder::select('status', DB::raw('count(*) as total'))
|
||||
->groupBy('status')
|
||||
->pluck('total', 'status');
|
||||
|
||||
$data['waitingMediaOrder'] = $mediaOrder[0] ?? 0; // Status 0 = menunggu
|
||||
$data['acceptedMediaOrder'] = $mediaOrder[1] ?? 0; // Status 1 = diterima
|
||||
$data['rejectedMediaOrder'] = $mediaOrder[2] ?? 0; // Status 2 = ditolak
|
||||
// Akhir Statistik Media Order
|
||||
|
||||
// Statistik Rekap Konten
|
||||
$contentRecap = ContentRecap::all();
|
||||
$contentRecapCount = $contentRecap->groupBy('channel')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
$data['facebookContentRecap'] = $contentRecapCount->get('facebook', 0);
|
||||
$data['twitterContentRecap'] = $contentRecapCount->get('twitter', 0);
|
||||
$data['websiteContentRecap'] = $contentRecapCount->get('website', 0);
|
||||
$data['youtubeContentRecap'] = $contentRecapCount->get('youtube', 0);
|
||||
$data['instagramContentRecap'] = $contentRecapCount->get('instagram', 0);
|
||||
$data['tiktokContentRecap'] = $contentRecapCount->get('tiktok', 0);
|
||||
$data['cetakContentRecap'] = $contentRecapCount->get('cetak', 0);
|
||||
// Akhir Statistik Rekap Konten
|
||||
|
||||
// Inisialisasi array 12 bulan (0-11)
|
||||
$mediaMonitoringMonthly = array_fill(0, 12, 0);
|
||||
$issueManagementMonthly = array_fill(0, 12, 0);
|
||||
|
||||
// Media Monitoring
|
||||
$mediaMonitorings = DB::table('media_monitorings')
|
||||
->whereYear('created_at', $year)
|
||||
->selectRaw('MONTH(created_at) as month, COUNT(*) as total')
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
foreach ($mediaMonitorings as $month => $total) {
|
||||
$mediaMonitoringMonthly[$month - 1] = $total;
|
||||
}
|
||||
|
||||
// Issue Management
|
||||
$issueManagements = DB::table('issue_managements')
|
||||
->whereYear('created_at', $year)
|
||||
->selectRaw('MONTH(created_at) as month, COUNT(*) as total')
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
foreach ($issueManagements as $month => $total) {
|
||||
$issueManagementMonthly[$month - 1] = $total;
|
||||
}
|
||||
|
||||
$data['mediaMonitoringMonthly'] = $mediaMonitoringMonthly;
|
||||
$data['issueManagementMonthly'] = $issueManagementMonthly;
|
||||
|
||||
// Data kalender pengajuan kerja sama
|
||||
$data['cooperationRequests'] = Cooperation::all();
|
||||
|
||||
// Data kalender media order
|
||||
$data['mediaOrders'] = Order::with(['cooperation'])->get();
|
||||
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
$media = Media::with('cooperations')->findOrFail($mediaId);
|
||||
$user = User::with(['announcements'])->find(Auth::id());
|
||||
|
||||
// Data pengumuman
|
||||
$data['overview_announcements'] = $user->announcements()
|
||||
->where(function ($query) {
|
||||
$query->where('announcements_users.category', '=', 'general');
|
||||
})
|
||||
->get();
|
||||
|
||||
// Data pengajuan kerja sama
|
||||
$data['cooperationRequests'] = $media->cooperations()
|
||||
->where(function ($query) {
|
||||
$query->where('media_cooperations.status', '=', '0');
|
||||
})
|
||||
->get();
|
||||
|
||||
// Data kalender Kerja sama
|
||||
$data['cooperationMedia'] = $media->cooperations->filter(function ($cooperation) use ($mediaId) {
|
||||
return $cooperation->proposals->where('status', 1)->where('media_id', $mediaId)->isNotEmpty();
|
||||
});
|
||||
|
||||
// Data kalender media order
|
||||
$data['mediaOrders'] = $media->orders()
|
||||
->where(function ($query) {
|
||||
$query->where('media_orders.status', '=', '1');
|
||||
})
|
||||
->get();
|
||||
} elseif (is_role(['1'])) {
|
||||
// Statistik Isu
|
||||
$issues = IssueManagement::all();
|
||||
$issueCounts = $issues->groupBy('issue')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
|
||||
$data['crisisIssue'] = $issueCounts->get('krisis', 0);
|
||||
$data['negativeIssue'] = $issueCounts->get('negatif', 0);
|
||||
$data['neutralIssue'] = $issueCounts->get('netral', 0);
|
||||
$data['positiveIssue'] = $issueCounts->get('positif', 0);
|
||||
// Akhir Statistik Isu
|
||||
|
||||
// Statistik Monitoring Media
|
||||
$mediaMonitorings = MediaMonitoring::all();
|
||||
|
||||
$mediaMonitoringCount = $mediaMonitorings->groupBy('channel')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
|
||||
$data['facebookMediaMonitoring'] = $mediaMonitoringCount->get('facebook', 0);
|
||||
$data['twitterMediaMonitoring'] = $mediaMonitoringCount->get('twitter', 0);
|
||||
$data['websiteMediaMonitoring'] = $mediaMonitoringCount->get('website', 0);
|
||||
$data['youtubeMediaMonitoring'] = $mediaMonitoringCount->get('youtube', 0);
|
||||
$data['instagramMediaMonitoring'] = $mediaMonitoringCount->get('instagram', 0);
|
||||
$data['tiktokMediaMonitoring'] = $mediaMonitoringCount->get('tiktok', 0);
|
||||
$data['cetakMediaMonitoring'] = $mediaMonitoringCount->get('cetak', 0);
|
||||
// Akhir Statistik Monitoring Media
|
||||
|
||||
// Statistik Media Order
|
||||
$mediaOrder = MediaOrder::select('status', DB::raw('count(*) as total'))
|
||||
->groupBy('status')
|
||||
->pluck('total', 'status');
|
||||
|
||||
$data['waitingMediaOrder'] = $mediaOrder[0] ?? 0; // Status 0 = menunggu
|
||||
$data['acceptedMediaOrder'] = $mediaOrder[1] ?? 0; // Status 1 = diterima
|
||||
$data['rejectedMediaOrder'] = $mediaOrder[2] ?? 0; // Status 2 = ditolak
|
||||
// Akhir Statistik Media Order
|
||||
|
||||
// Statistik Rekap Konten
|
||||
$contentRecap = ContentRecap::all();
|
||||
$contentRecapCount = $contentRecap->groupBy('channel')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
$data['facebookContentRecap'] = $contentRecapCount->get('facebook', 0);
|
||||
$data['twitterContentRecap'] = $contentRecapCount->get('twitter', 0);
|
||||
$data['websiteContentRecap'] = $contentRecapCount->get('website', 0);
|
||||
$data['youtubeContentRecap'] = $contentRecapCount->get('youtube', 0);
|
||||
$data['instagramContentRecap'] = $contentRecapCount->get('instagram', 0);
|
||||
$data['tiktokContentRecap'] = $contentRecapCount->get('tiktok', 0);
|
||||
$data['cetakContentRecap'] = $contentRecapCount->get('cetak', 0);
|
||||
// Akhir Statistik Rekap Konten
|
||||
|
||||
// Inisialisasi array 12 bulan (0-11)
|
||||
$mediaMonitoringMonthly = array_fill(0, 12, 0);
|
||||
$issueManagementMonthly = array_fill(0, 12, 0);
|
||||
|
||||
// Media Monitoring
|
||||
$mediaMonitorings = DB::table('media_monitorings')
|
||||
->whereYear('created_at', $year)
|
||||
->selectRaw('MONTH(created_at) as month, COUNT(*) as total')
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
foreach ($mediaMonitorings as $month => $total) {
|
||||
$mediaMonitoringMonthly[$month - 1] = $total;
|
||||
}
|
||||
|
||||
// Issue Management
|
||||
$issueManagements = DB::table('issue_managements')
|
||||
->whereYear('created_at', $year)
|
||||
->selectRaw('MONTH(created_at) as month, COUNT(*) as total')
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
foreach ($issueManagements as $month => $total) {
|
||||
$issueManagementMonthly[$month - 1] = $total;
|
||||
}
|
||||
|
||||
$data['mediaMonitoringMonthly'] = $mediaMonitoringMonthly;
|
||||
$data['issueManagementMonthly'] = $issueManagementMonthly;
|
||||
|
||||
// Data kalender pengajuan kerja sama
|
||||
$data['cooperationRequests'] = Cooperation::all();
|
||||
|
||||
// Data kalender media order
|
||||
$data['mediaOrders'] = Order::with(['cooperation'])->get();
|
||||
} elseif (is_role(['5'])) {
|
||||
|
||||
// Statistik Penyelesaian Kerja sama
|
||||
$cooperationCompletion = CooperationCompletion::all();
|
||||
$cooperationCompletionCounts = $cooperationCompletion->groupBy('status')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
|
||||
$data['cooperationCompletionWaiting'] = $cooperationCompletionCounts->get('0', 0);
|
||||
$data['cooperationCompletionAccepted'] = $cooperationCompletionCounts->get('1', 0);
|
||||
$data['cooperationCompletionRejected'] = $cooperationCompletionCounts->get('2', 0);
|
||||
}
|
||||
|
||||
return view('dashboard.overview.index', $data);
|
||||
}
|
||||
}
|
||||
@ -1,345 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Exports\ReportExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ReportRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Media;
|
||||
use App\Models\Order;
|
||||
use App\Models\Report;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.reports.index', [
|
||||
'title' => 'Laporan Bukti Tayang',
|
||||
'mediaCollection' => Media::all(),
|
||||
'media' => $request->input('media', []),
|
||||
'status' => $request->input('status', null),
|
||||
'date' => $request->input('date', null),
|
||||
'from_month' => $request->input('from_month', null),
|
||||
'to_month' => $request->input('to_month', null),
|
||||
'year' => $request->input('year', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create($id)
|
||||
{
|
||||
return view('dashboard.reports.create', [
|
||||
'title' => 'Buat Laporan',
|
||||
'mediaOrderId' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ReportRequest $request, $id)
|
||||
{
|
||||
$order = Order::findOrFail(decrypt_id($id));
|
||||
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
Report::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan laporan.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.cooperations.process', ['id' => encrypt_id($order->cooperation_id), 'process' => 'reports'])->with('success-status', 'Berhasil menambahkan laporan.');
|
||||
}
|
||||
|
||||
public function edit($mediaOrderId, $id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.edit', [
|
||||
'title' => 'Buat Laporan',
|
||||
'report' => $report,
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ReportRequest $request, $mediaOrderId, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['order_id'] = decrypt_id($mediaOrderId);
|
||||
$validatedData['status'] = '0';
|
||||
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/reports/'.$report->proof);
|
||||
} else {
|
||||
$validatedData['proof'] = $report->proof;
|
||||
}
|
||||
|
||||
$updatedReport = $report->update($validatedData);
|
||||
|
||||
if ($updatedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah laporan.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah laporan.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah laporan.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($mediaOrderId, $id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.show', [
|
||||
'title' => 'Detail Laporan',
|
||||
'report' => $report,
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function showIndex($id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.index.show', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'report' => $report,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processIndex($id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.index.process', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'report' => $report,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accept($id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$acceptedReport = $report->update([
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Laporan bukti tayang kerja sama <u>'.$report->order->cooperation->name.'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui laporan bukti tayang Anda.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($acceptedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui laporan bukti tayang.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui laporan bukti tayang');
|
||||
}
|
||||
}
|
||||
|
||||
public function reject($mediaOrderId, $id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.reject', [
|
||||
'title' => 'Tolak Laporan',
|
||||
'report' => $report,
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$rejectedReport = $report->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Laporan bukti tayang kerja sama <u>'.$report->order->cooperation->name.'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan bukti tayang Anda.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($rejectedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak laporan bukti tayang.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}
|
||||
|
||||
public function rejectActionIndex(Request $request, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$rejectedReport = $report->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Laporan bukti tayang kerja sama <u>'.$report->order->cooperation->name.'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan bukti tayang Anda.</p>',
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($rejectedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak laporan bukti tayang.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
delete_file('app/public/uploads/reports/'.$report->proof);
|
||||
$report->forceDelete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus laporan bukti tayang.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus laporan bukti tayang.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkLink(Request $request)
|
||||
{
|
||||
$linkExists = Report::where('link', $request->link)
|
||||
->where('media_id', Auth::user()->company->media->id)
|
||||
->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try {
|
||||
$export_type = $request->input('export_type', 'excel');
|
||||
|
||||
$media = $request->input('media', null);
|
||||
$status = $request->input('status', null);
|
||||
$year = $request->input('year', null);
|
||||
$from_month = $request->input('from_month', null);
|
||||
$to_month = $request->input('to_month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
if ($export_type === 'excel') {
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new ReportExport($media, $status, $year, $from_month, $to_month, $date), 'reports-'.$formattedNow.'.xlsx');
|
||||
} elseif ($export_type === 'pdf') {
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = Report::with(['media.company', 'order.cooperation']);
|
||||
} elseif (is_role(['3'])) {
|
||||
$mediaId = Auth::user()->company->media->id;
|
||||
$query = Report::with(['media.company', 'order.cooperation'])->where('media_id', '=', $mediaId);
|
||||
}
|
||||
|
||||
if (! empty($media) && is_array($media)) {
|
||||
$query->whereIn('media_id', $media);
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
switch ($status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
case 'accepted':
|
||||
$query->where('status', '1');
|
||||
break;
|
||||
case 'rejected':
|
||||
$query->where('status', '2');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
}
|
||||
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
|
||||
if ($date) {
|
||||
$query->whereDate('created_at', $date);
|
||||
}
|
||||
|
||||
$reports = $query->get();
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.reports.prints.collection', compact('reports'));
|
||||
|
||||
return $pdf->stream(slugify('laporan bukti tayang ').'.pdf');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function singlePrint()
|
||||
{
|
||||
try {
|
||||
$report = Report::with(['media.company', 'order.cooperation'])->first();
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.reports.prints.single', compact('report'));
|
||||
|
||||
return $pdf->stream(slugify('laporan bukti tayang '.$report->title.' '.$report->media->name).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.role.index', [
|
||||
'title' => 'Role Pengguna',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SettingRequest;
|
||||
use App\Settings\AppSettings;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.setting.index', [
|
||||
'title' => 'Pengaturan Aplikasi',
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(SettingRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$settings = app(AppSettings::class);
|
||||
|
||||
$files = ['app_icon', 'app_logo'];
|
||||
$validFile = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$savedFile = store_file($request->file($file), 'uploads/settings');
|
||||
$validFile[$file] = $savedFile['randomFileName'];
|
||||
} else {
|
||||
$validFile[$file] = $settings->$file;
|
||||
}
|
||||
}
|
||||
|
||||
$settings->fill([
|
||||
'app_name' => $validatedData['app_name'] ?? $settings->app_name,
|
||||
'app_title' => $validatedData['app_title'] ?? $settings->app_title,
|
||||
'app_description' => $validatedData['app_description'] ?? $settings->app_description,
|
||||
'app_keywords' => $validatedData['app_keywords'] ?? $settings->app_keywords,
|
||||
'app_icon' => $validFile['app_icon'] ?? $settings->app_icon,
|
||||
'app_logo' => $validFile['app_logo'] ?? $settings->app_logo,
|
||||
'contact_address' => $validatedData['contact_address'] ?? $settings->contact_address,
|
||||
'contact_address_link' => $validatedData['contact_address_link'] ?? $settings->contact_address_link,
|
||||
'contact_phone' => $validatedData['contact_phone'] ?? $settings->contact_phone,
|
||||
'contact_email' => $validatedData['contact_email'] ?? $settings->contact_email,
|
||||
'contact_facebook' => $validatedData['contact_facebook'] ?? $settings->contact_facebook,
|
||||
'contact_twitter' => $validatedData['contact_twitter'] ?? $settings->contact_twitter,
|
||||
'contact_instagram' => $validatedData['contact_instagram'] ?? $settings->contact_instagram,
|
||||
'contact_youtube' => $validatedData['contact_youtube'] ?? $settings->contact_youtube,
|
||||
'contact_whatsapp' => $validatedData['contact_whatsapp'] ?? $settings->contact_whatsapp,
|
||||
'contact_telegram' => $validatedData['contact_telegram'] ?? $settings->contact_telegram,
|
||||
'about_us' => $validatedData['about_us'] ?? $settings->about_us,
|
||||
]);
|
||||
|
||||
if ($settings->save()) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah informasi aplikasi.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah informasi aplikasi.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SubClassificationRequest;
|
||||
use App\Models\Classification;
|
||||
use App\Models\SubClassification;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SubClassificationController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Data Sub Klasifikasi',
|
||||
'classification' => $request->input('classification', null),
|
||||
'filter' => $request->input('filter', null),
|
||||
'new_data' => session()->get('new_data', null),
|
||||
];
|
||||
|
||||
return view('dashboard.sub-classifications.index', $viewData);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Buat Sub Klasifikasi Baru',
|
||||
'fromClassification' => false,
|
||||
];
|
||||
|
||||
if ($request->has('classification')) {
|
||||
$classificationId = decrypt_id($request->query('classification'));
|
||||
$viewData['classification'] = Classification::findOrFail($classificationId);
|
||||
$viewData['fromClassification'] = true;
|
||||
} else {
|
||||
$viewData['classifications'] = Classification::all();
|
||||
}
|
||||
|
||||
return view('dashboard.sub-classifications.create', $viewData);
|
||||
}
|
||||
|
||||
public function store(SubClassificationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$createdSubClassification = SubClassification::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.sub.classifications.index')->with('success-status', 'Berhasil membuat sub klasifikasi baru.')
|
||||
->with('new_data', encrypt_id($createdSubClassification->id));
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat sub klasifikasi baru.');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$subClassification = SubClassification::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.sub-classifications.edit', [
|
||||
'title' => 'Ubah Sub Klasifikasi',
|
||||
'subClassification' => $subClassification,
|
||||
'classifications' => Classification::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(SubClassificationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$subClassification = SubClassification::findOrFail(decrypt_id($id));
|
||||
$subClassification->update($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.sub.classifications.show', ['id' => encrypt_id($subClassification->id)])->with('success-status', 'Berhasil mengubah sub klasifikasi.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah sub klasifikasi.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$subClassification = SubClassification::with(['classification'])->withTrashed()->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.sub-classifications.show', [
|
||||
'title' => 'Detail Sub Klasifikasi',
|
||||
'subClassification' => $subClassification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$subClassification = SubClassification::findOrFail(decrypt_id($id));
|
||||
$subClassification->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus sub klasifikasi.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus sub klasifikasi.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SubLocationRequest;
|
||||
use App\Models\Location;
|
||||
use App\Models\SubLocation;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SubLocationController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Data Sub Lokus',
|
||||
'location' => $request->input('location', null),
|
||||
'new_data' => session()->get('new_data', null),
|
||||
];
|
||||
|
||||
return view('dashboard.sub-locations.index', $viewData);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Buat Sub Lokus Baru',
|
||||
'fromLocation' => false,
|
||||
];
|
||||
|
||||
if ($request->has('location')) {
|
||||
$locationId = decrypt_id($request->query('location'));
|
||||
$viewData['location'] = Location::findOrFail($locationId);
|
||||
$viewData['fromLocation'] = true;
|
||||
} else {
|
||||
$viewData['locations'] = Location::all();
|
||||
}
|
||||
|
||||
return view('dashboard.sub-locations.create', $viewData);
|
||||
}
|
||||
|
||||
public function store(SubLocationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$createdSubLocation = SubLocation::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.sub.locations.index')->with('success-status', 'Berhasil membuat sub lokus baru.')
|
||||
->with('new_data', encrypt_id($createdSubLocation->id));
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan sub lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$subLocation = SubLocation::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.sub-locations.edit', [
|
||||
'title' => 'Ubah Sub Lokus',
|
||||
'subLocation' => $subLocation,
|
||||
'locations' => Location::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(SubLocationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$subLocation = SubLocation::findOrFail(decrypt_id($id));
|
||||
$subLocation->update($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.sub.locations.show', ['id' => encrypt_id($subLocation->id)])->with('success-status', 'Berhasil mengubah sub lokus.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah sub lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$subLocation = SubLocation::with(['location'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.sub-locations.show', [
|
||||
'title' => 'Detail Sub Lokus',
|
||||
'subLocation' => $subLocation,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$subLocation = SubLocation::findOrFail(decrypt_id($id));
|
||||
$subLocation->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus sub lokus.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus sub lokus.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,351 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AccountSettingRequest;
|
||||
use App\Http\Requests\ChangePasswordRequest;
|
||||
use App\Http\Requests\ResetPasswordRequest;
|
||||
use App\Http\Requests\UserRequest;
|
||||
use App\Mail\AccountVerification;
|
||||
use App\Models\LoginHistory;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.users.index', [
|
||||
'title' => 'Data Pengguna',
|
||||
'role' => $request->input('role', null),
|
||||
'status' => $request->input('status', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.users.create', [
|
||||
'title' => 'Buat Pengguna Baru',
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(UserRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
User::create($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat pengguna baru.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil membuat pengguna baru.');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$user = User::with(['role'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.users.edit', [
|
||||
'title' => 'Ubah Pengguna',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(UserRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$user = User::findOrFail(decrypt_id($id));
|
||||
$user->update($validatedData);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengguna.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengguna.');
|
||||
}
|
||||
|
||||
public function show($id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
'title' => 'Profile Pengguna',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'show-user',
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function resetPassword($id)
|
||||
{
|
||||
$user = User::with(['role'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.users.reset-password', [
|
||||
'title' => 'Reset Password',
|
||||
'page' => 'reset',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetPasswordAction(ResetPasswordRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
User::findOrFail(decrypt_id($id))->update([
|
||||
'password' => $validatedData['password'],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mereset password pengguna.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mereset password pengguna.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$user = User::with(['company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if ($user->role_id == '3') {
|
||||
if ($user->company) {
|
||||
$company = $user->company;
|
||||
|
||||
if ($company->media) {
|
||||
$media = $company->media;
|
||||
|
||||
if ($media->journalists) {
|
||||
$media->journalists->delete();
|
||||
}
|
||||
|
||||
$media->delete();
|
||||
}
|
||||
|
||||
$company->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus user beserta data terkait.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus user atau data terkait.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function profile($type)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => 'Detail Akun',
|
||||
'user' => Auth::user(),
|
||||
'roles' => Role::all(),
|
||||
'page' => 'profile',
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', Auth::user()->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // atau bisa redirect atau handling lainnya jika tipe tidak dikenali
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.users.index', $filterField);
|
||||
}
|
||||
|
||||
public function process($id, $type, $process)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
'title' => 'Profile Pengguna',
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'process',
|
||||
'type' => $type,
|
||||
'process' => $process,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // untuk menangani tipe yang tidak dikenal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function statusAction(Request $request, $id, $action)
|
||||
{
|
||||
$user = User::findOrFail(decrypt_id($id));
|
||||
|
||||
try {
|
||||
if ($user->status === '0' && Auth::check() && is_role(['1'])) {
|
||||
if ($action == 'accept') {
|
||||
$user->update([
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'accepted'));
|
||||
|
||||
return response()->json(['message' => 'Berhasil menyetujui pengguna.']);
|
||||
} elseif ($action == 'reject') {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$user->update([
|
||||
'status' => '3',
|
||||
]);
|
||||
|
||||
$user->company->update([
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'rejected', strip_tags($validatedData['rejection_reason'])));
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak pengguna.');
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setting()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
return view('dashboard.users.setting', [
|
||||
'title' => 'Pengaturan Akun',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function settingAction(AccountSettingRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$user->update([
|
||||
'name' => $validatedData['name'],
|
||||
'email' => $validatedData['email'],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah data akun.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah data akun.');
|
||||
}
|
||||
|
||||
public function changePassword()
|
||||
{
|
||||
$user = User::with(['role'])->findOrFail(Auth::id());
|
||||
|
||||
return view('dashboard.users.reset-password', [
|
||||
'title' => 'Ubah Password',
|
||||
'page' => 'change',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function changePasswordAction(ChangePasswordRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try {
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$user->update([
|
||||
'password' => $validatedData['password'],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah password.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.users.setting')->with('success-status', 'Berhasil mengubah password.');
|
||||
}
|
||||
}
|
||||
@ -1,219 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ReceiveMessageContactRequest;
|
||||
use App\Models\Contact;
|
||||
use App\Models\News;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class HomepageController extends Controller
|
||||
{
|
||||
protected $yesterdayVisitor;
|
||||
|
||||
protected $todayVisitor;
|
||||
|
||||
protected $thisMonthVisitor;
|
||||
|
||||
protected $thisYearVisitor;
|
||||
|
||||
protected $totalVisitor;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$today = Carbon::today();
|
||||
$yesterday = Carbon::yesterday();
|
||||
$thisMonth = Carbon::now()->startOfMonth();
|
||||
$thisYear = Carbon::now()->startOfYear();
|
||||
|
||||
$this->yesterdayVisitor = DB::table('visitors')
|
||||
->whereDate('date', '=', $yesterday->toDateString())
|
||||
->value('visitors');
|
||||
|
||||
$this->todayVisitor = DB::table('visitors')
|
||||
->whereDate('date', '=', $today->toDateString())
|
||||
->value('visitors');
|
||||
|
||||
$this->thisMonthVisitor = DB::table('visitors')
|
||||
->whereBetween('date', [$thisMonth, Carbon::now()])
|
||||
->sum('visitors');
|
||||
|
||||
$this->thisYearVisitor = DB::table('visitors')
|
||||
->whereBetween('date', [$thisYear, Carbon::now()])
|
||||
->sum('visitors');
|
||||
|
||||
$this->totalVisitor = DB::table('visitors')->sum('visitors');
|
||||
|
||||
View::share('yesterdayVisitor', $this->yesterdayVisitor);
|
||||
View::share('todayVisitor', $this->todayVisitor);
|
||||
View::share('thisMonthVisitor', $this->thisMonthVisitor);
|
||||
View::share('thisYearVisitor', $this->thisYearVisitor);
|
||||
View::share('totalVisitor', $this->totalVisitor);
|
||||
}
|
||||
|
||||
public function landing()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Beranda',
|
||||
'page' => 'landing',
|
||||
'news' => News::whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])
|
||||
->where('category', '=', '0')
|
||||
->latest()
|
||||
->get(),
|
||||
'announcements' => News::whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])
|
||||
->where('category', '=', '1')
|
||||
->latest()
|
||||
->get(),
|
||||
];
|
||||
|
||||
return view('homepage.index', $data);
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'search' => 'nullable|string|max:255|regex:/^[a-zA-Z0-9\s]+$/',
|
||||
], [
|
||||
'search.string' => 'Pencarian harus berupa teks.',
|
||||
'search.max' => 'Pencarian tidak boleh lebih dari 255 karakter.',
|
||||
'search.regex' => 'Pencarian hanya boleh mengandung huruf, angka, dan spasi.',
|
||||
]);
|
||||
|
||||
$search = trim($request->input('search'));
|
||||
|
||||
$data = [
|
||||
'title' => 'Pencarian',
|
||||
'page' => 'search',
|
||||
'data' => News::query()
|
||||
->when($search, function ($query, $search) {
|
||||
return $query->where('title', 'LIKE', '%'.$search.'%');
|
||||
})
|
||||
->latest()
|
||||
->simplePaginate(12)
|
||||
->appends(['search' => $search]),
|
||||
'search' => $search,
|
||||
];
|
||||
|
||||
return view('homepage.search', $data);
|
||||
}
|
||||
|
||||
public function news(Request $request)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => 'Berita',
|
||||
'page' => 'news',
|
||||
];
|
||||
|
||||
$search = $request->input('search', null);
|
||||
|
||||
if ($search) {
|
||||
$data['news'] = News::where('title', 'LIKE', "%{$search}%")
|
||||
->where('category', '0')
|
||||
->latest()
|
||||
->simplePaginate(12);
|
||||
} else {
|
||||
$data['news'] = News::where('category', '0')->latest()->simplePaginate(12);
|
||||
}
|
||||
|
||||
return view('homepage.news.index', $data);
|
||||
}
|
||||
|
||||
public function readNews($slug)
|
||||
{
|
||||
$news = News::where('slug', $slug)->first();
|
||||
$news->increment('views', 1);
|
||||
|
||||
$data = [
|
||||
'title' => 'Berita',
|
||||
'page' => 'news',
|
||||
'news' => $news,
|
||||
'popularNews' => News::where('category', '0')->orderBy('views', 'desc')->take(5)->get(),
|
||||
'otherNews' => News::where('category', '0')->orderByDesc('id')->where('id', '!=', $news->id)->take(3)->get(),
|
||||
];
|
||||
|
||||
return view('homepage.news.read', $data);
|
||||
|
||||
}
|
||||
|
||||
public function announcement(Request $request)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => 'Pengumuman',
|
||||
'page' => 'announcements',
|
||||
];
|
||||
|
||||
$search = $request->input('search', null);
|
||||
|
||||
if ($search) {
|
||||
$data['announcements'] = News::where('category', '1')->where('title', 'LIKE', "%{$search}%")
|
||||
// ->orWhere('content', 'LIKE', "%{$search}%")
|
||||
->latest()
|
||||
->simplePaginate(6);
|
||||
} else {
|
||||
$data['announcements'] = News::where('category', '1')->latest()->simplePaginate(6);
|
||||
}
|
||||
|
||||
return view('homepage.announcements.index', $data);
|
||||
}
|
||||
|
||||
public function readAnnouncement($slug)
|
||||
{
|
||||
$announcement = News::where('slug', $slug)->first();
|
||||
$announcement->increment('views', 1);
|
||||
|
||||
$data = [
|
||||
'title' => 'Pengumuman',
|
||||
'page' => 'announcements',
|
||||
'announcement' => $announcement,
|
||||
'otherAnnouncements' => News::where('category', '1')->orderByDesc('id')->where('id', '!=', $announcement->id)->take(4)->get(),
|
||||
];
|
||||
|
||||
return view('homepage.announcements.read', $data);
|
||||
|
||||
}
|
||||
|
||||
public function aboutUs()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Tentang Kami',
|
||||
'page' => 'about_us',
|
||||
];
|
||||
|
||||
return view('homepage.about-us.index', $data);
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Kontak',
|
||||
'page' => 'contacts',
|
||||
];
|
||||
|
||||
return view('homepage.contacts.index', $data);
|
||||
}
|
||||
|
||||
public function receiveMessage(ReceiveMessageContactRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['ip_address'] = $request->ip();
|
||||
|
||||
$createdMessage = Contact::create($validatedData);
|
||||
|
||||
if ($createdMessage) {
|
||||
return 'Berhasil mengirim pesan';
|
||||
} else {
|
||||
return 'Gagal mengirim pesan';
|
||||
}
|
||||
}
|
||||
|
||||
public function customError($code)
|
||||
{
|
||||
abort($code);
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class AnnouncementMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$user = User::with(['announcements' => function ($query) {
|
||||
$query->orderBy('id', 'desc');
|
||||
}])->find(Auth::user()->id);
|
||||
|
||||
$announcements = $user->announcements;
|
||||
$hasUnread = $announcements->some(fn ($a) => $a->pivot->status == 0);
|
||||
|
||||
View::share([
|
||||
'announcements' => $announcements,
|
||||
'hasUnread' => $hasUnread,
|
||||
]);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Settings\AppSettings;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class AppSettingsMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
View::share('app', app(AppSettings::class));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class AuthenticatedMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
|
||||
if (Auth::check()) {
|
||||
return redirect()->route('dashboard.overview');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RoleMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$roles): Response
|
||||
{
|
||||
if (! Auth::check()) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
if (! in_array(Auth::user()->role_id, $roles)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Visitor;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class VisitorCounterMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$ipAddress = $request->ip();
|
||||
|
||||
if (! RateLimiter::tooManyAttempts('visitor:'.$ipAddress, 1)) {
|
||||
RateLimiter::hit('visitor:'.$ipAddress, 900);
|
||||
|
||||
$today = now()->format('Y-m-d');
|
||||
|
||||
$visitor = Visitor::firstOrCreate(['date' => $today]);
|
||||
$visitor->increment('visitors');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AccountSettingRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'email' => ['required', 'email', 'max:100'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama wajib diisi.',
|
||||
'name.max' => 'Nama tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Email harus menggunakan format email yang valid.',
|
||||
'email.max' => 'Email tidak boleh lebih dari 100 karakter.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AiringProofThemeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'year' => ['required', 'max:5'],
|
||||
'description' => ['nullable'],
|
||||
'slug' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama harus diisi.',
|
||||
'name.max' => 'Nama tidak boleh lebih dari 100 karakter.',
|
||||
'year.required' => 'Tahun harus diisi.',
|
||||
'year.max' => 'Tahun tidak boleh lebih dari 5 karakter.',
|
||||
'description.nullable' => 'Deskripsi bersifat opsional.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'slug' => filled($this->name) && filled($this->year) ? \Illuminate\Support\Str::slug($this->name.' '.$this->year) : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AnnouncementRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'headline' => ['required'],
|
||||
'user_ids' => ['required', 'array'],
|
||||
'user_ids.*' => ['required', 'exists:users,id'],
|
||||
'content' => ['required'],
|
||||
'link' => ['nullable', 'url'],
|
||||
'attachment' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'headline.required' => 'Judul pengumuman harus diisi.',
|
||||
'user_ids.required' => 'Pilih setidaknya satu media untuk pengumuman.',
|
||||
'user_ids.array' => 'Media harus dalam format array.',
|
||||
'user_ids.*.required' => 'Media yang dipilih tidak boleh kosong.',
|
||||
'user_ids.*.exists' => 'Salah satu media yang dipilih tidak ditemukan.',
|
||||
'content.required' => 'Konten pengumuman harus diisi.',
|
||||
'link.url' => 'Format tautan/link tidak valid. Pastikan menggunakan format lengkap, misal: https://example.com.',
|
||||
'attachment.file' => 'Lampiran harus berupa file.',
|
||||
'attachment.mimes' => 'Lampiran hanya boleh berupa file PDF.',
|
||||
'attachment.max' => 'Ukuran lampiran maksimal 2MB.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\MatchCurrentPasswordRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class ChangePasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' => ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
'my_password' => ['required', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols(), new MatchCurrentPasswordRule],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'password.required' => 'Password baru wajib diisi.',
|
||||
'password.confirmed' => 'Konfirmasi password baru tidak cocok.',
|
||||
'password.min' => 'Password baru harus memiliki minimal 8 karakter.',
|
||||
'password.mixedCase' => 'Password baru harus mengandung huruf besar dan huruf kecil.',
|
||||
'password.numbers' => 'Password baru harus mengandung angka.',
|
||||
'password.symbols' => 'Password baru harus mengandung simbol.',
|
||||
|
||||
'my_password.required' => 'Password Anda wajib diisi.',
|
||||
'my_password.confirmed' => 'Konfirmasi password Anda tidak cocok.',
|
||||
'my_password.min' => 'Password Anda harus memiliki minimal 8 karakter.',
|
||||
'my_password.mixedCase' => 'Password Anda harus mengandung huruf besar dan huruf kecil.',
|
||||
'my_password.numbers' => 'Password Anda harus mengandung angka.',
|
||||
'my_password.symbols' => 'Password Anda harus mengandung simbol.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ClassificationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'status' => ['required', 'in:0,1'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama klasifikasi harus diisi.',
|
||||
'name.max' => 'Nama klasifikasi tidak boleh lebih dari 100 karakter.',
|
||||
'status.required' => 'Status harus dipilih.',
|
||||
'status.in' => 'Status harus memiliki nilai aktif atau tidak aktif.',
|
||||
'description.nullable' => 'Deskripsi boleh kosong jika tidak diperlukan.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CompanyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'company_name' => ['required', 'max:100'],
|
||||
'company_email' => ['required', 'max:100', 'email'],
|
||||
'company_phone_number' => ['required', 'max:15'],
|
||||
'company_address' => ['required'],
|
||||
'company_director_name' => ['required', 'max:100'],
|
||||
'company_director_nik' => ['required', 'max:100'],
|
||||
'company_director_nik_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_deed_incorporation' => ['nullable', 'max:100'],
|
||||
'company_deed_incorporation_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_trade_license' => ['nullable', 'max:100'],
|
||||
'company_trade_license_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_tax_id_number' => ['nullable', 'max:100'],
|
||||
'company_tax_id_number_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_taxable_enterprise' => ['nullable', 'max:100'],
|
||||
'company_taxable_enterprise_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_annual_tax_return' => ['nullable', 'max:100'],
|
||||
'company_annual_tax_return_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_domicile_certificate' => ['nullable', 'max:100'],
|
||||
'company_domicile_certificate_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
'company_profile' => ['nullable', 'max:100'],
|
||||
'company_profile_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
// Company
|
||||
'company_name.required' => 'Nama perusahaan wajib diisi.',
|
||||
'company_name.max' => 'Nama perusahaan maksimal 100 karakter.',
|
||||
'company_email.required' => 'Email perusahaan wajib diisi.',
|
||||
'company_email.email' => 'Email perusahaan tidak valid.',
|
||||
'company_email.max' => 'Email perusahaan maksimal 100 karakter.',
|
||||
'company_phone_number.required' => 'Nomor telepon perusahaan wajib diisi.',
|
||||
'company_phone_number.max' => 'Nomor telepon perusahaan maksimal 15 karakter.',
|
||||
'company_address.required' => 'Alamat perusahaan wajib diisi.',
|
||||
'company_director_name.required' => 'Nama direktur perusahaan wajib diisi.',
|
||||
'company_director_name.max' => 'Nama direktur perusahaan maksimal 100 karakter.',
|
||||
'company_director_nik.required' => 'NIK direktur perusahaan wajib diisi.',
|
||||
'company_director_nik.max' => 'NIK direktur perusahaan maksimal 100 karakter.',
|
||||
'company_director_nik_doc.required' => 'Dokumen NIK direktur perusahaan wajib diunggah.',
|
||||
'company_director_nik_doc.file' => 'Dokumen NIK direktur perusahaan harus berupa file.',
|
||||
'company_director_nik_doc.mimes' => 'Dokumen NIK direktur perusahaan harus dalam format PDF.',
|
||||
'company_director_nik_doc.max' => 'Ukuran dokumen NIK direktur perusahaan maksimal 2 MB.',
|
||||
|
||||
// Documents
|
||||
'company_deed_incorporation.max' => 'Akta pendirian perusahaan maksimal 100 karakter.',
|
||||
'company_deed_incorporation_doc.file' => 'Dokumen akta pendirian perusahaan harus berupa file.',
|
||||
'company_deed_incorporation_doc.mimes' => 'Dokumen akta pendirian perusahaan harus dalam format PDF.',
|
||||
'company_deed_incorporation_doc.max' => 'Ukuran dokumen akta pendirian perusahaan maksimal 2 MB.',
|
||||
'company_trade_license.max' => 'Lisensi perdagangan perusahaan maksimal 100 karakter.',
|
||||
'company_trade_license_doc.file' => 'Dokumen lisensi perdagangan perusahaan harus berupa file.',
|
||||
'company_trade_license_doc.mimes' => 'Dokumen lisensi perdagangan perusahaan harus dalam format PDF.',
|
||||
'company_trade_license_doc.max' => 'Ukuran dokumen lisensi perdagangan perusahaan maksimal 2 MB.',
|
||||
'company_tax_id_number.max' => 'Nomor NPWP perusahaan maksimal 100 karakter.',
|
||||
'company_tax_id_number_doc.file' => 'Dokumen NPWP perusahaan harus berupa file.',
|
||||
'company_tax_id_number_doc.mimes' => 'Dokumen NPWP perusahaan harus dalam format PDF.',
|
||||
'company_tax_id_number_doc.max' => 'Ukuran dokumen NPWP perusahaan maksimal 2 MB.',
|
||||
'company_taxable_enterprise.max' => 'Nomor PKP perusahaan maksimal 100 karakter.',
|
||||
'company_taxable_enterprise_doc.file' => 'Dokumen PKP perusahaan harus berupa file.',
|
||||
'company_taxable_enterprise_doc.mimes' => 'Dokumen PKP perusahaan harus dalam format PDF.',
|
||||
'company_taxable_enterprise_doc.max' => 'Ukuran dokumen PKP perusahaan maksimal 2 MB.',
|
||||
'company_annual_tax_return.max' => 'Laporan SPT tahunan perusahaan maksimal 100 karakter.',
|
||||
'company_annual_tax_return_doc.file' => 'Dokumen SPT tahunan perusahaan harus berupa file.',
|
||||
'company_annual_tax_return_doc.mimes' => 'Dokumen SPT tahunan perusahaan harus dalam format PDF.',
|
||||
'company_annual_tax_return_doc.max' => 'Ukuran dokumen SPT tahunan perusahaan maksimal 2 MB.',
|
||||
'company_domicile_certificate.max' => 'Sertifikat domisili perusahaan maksimal 100 karakter.',
|
||||
'company_domicile_certificate_doc.file' => 'Dokumen sertifikat domisili perusahaan harus berupa file.',
|
||||
'company_domicile_certificate_doc.mimes' => 'Dokumen sertifikat domisili perusahaan harus dalam format PDF.',
|
||||
'company_domicile_certificate_doc.max' => 'Ukuran dokumen sertifikat domisili perusahaan maksimal 2 MB.',
|
||||
'company_profile.max' => 'Profil perusahaan maksimal 100 karakter.',
|
||||
'company_profile_doc.file' => 'Dokumen profil perusahaan harus berupa file.',
|
||||
'company_profile_doc.mimes' => 'Dokumen profil perusahaan harus dalam format PDF.',
|
||||
'company_profile_doc.max' => 'Ukuran dokumen profil perusahaan maksimal 2 MB.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'company_deed_incorporation' => filled($this->company_deed_incorporation) ? $this->company_deed_incorporation : null,
|
||||
'company_deed_incorporation_doc' => filled($this->company_deed_incorporation_doc) ? $this->company_deed_incorporation_doc : null,
|
||||
'company_trade_license' => filled($this->company_trade_license) ? $this->company_trade_license : null,
|
||||
'company_trade_license_doc' => filled($this->company_trade_license_doc) ? $this->company_trade_license_doc : null,
|
||||
'company_tax_id_number' => filled($this->company_tax_id_number) ? $this->company_tax_id_number : null,
|
||||
'company_tax_id_number_doc' => filled($this->company_tax_id_number_doc) ? $this->company_tax_id_number_doc : null,
|
||||
'company_taxable_enterprise' => filled($this->company_taxable_enterprise) ? $this->company_taxable_enterprise : null,
|
||||
'company_taxable_enterprise_doc' => filled($this->company_taxable_enterprise_doc) ? $this->company_taxable_enterprise_doc : null,
|
||||
'company_annual_tax_return' => filled($this->company_annual_tax_return) ? $this->company_annual_tax_return : null,
|
||||
'company_annual_tax_return_doc' => filled($this->company_annual_tax_return_doc) ? $this->company_annual_tax_return_doc : null,
|
||||
'company_domicile_certificate' => filled($this->company_domicile_certificate) ? $this->company_domicile_certificate : null,
|
||||
'company_domicile_certificate_doc' => filled($this->company_domicile_certificate_doc) ? $this->company_domicile_certificate_doc : null,
|
||||
'company_profile' => filled($this->company_profile) ? $this->company_profile : null,
|
||||
'company_profile_doc' => filled($this->company_profile_doc) ? $this->company_profile_doc : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ContentRecapClassificationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'description' => ['nullable'],
|
||||
'year' => ['required'],
|
||||
'slug' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama harus diisi.',
|
||||
'name.max' => 'Nama tidak boleh lebih dari 100 karakter.',
|
||||
'year.required' => 'Tahun harus diisi.',
|
||||
'description.nullable' => 'Deskripsi bersifat opsional.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'slug' => filled($this->name) ? Str::slug($this->name) : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ContentRecapRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1', '2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'content_theme' => ['required'],
|
||||
'posted_date' => ['required', 'date'],
|
||||
'channel' => ['required', 'in:website,tiktok,youtube,instagram,facebook,twitter,cetak', 'not_in:placeholder'],
|
||||
'link' => ['required', 'url'],
|
||||
'classification_id' => ['required', 'exists:content_recap_classifications,id', 'not_in:placeholder'],
|
||||
'social_media' => ['required', 'not_in:placeholder'],
|
||||
'content_type' => ['required'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['image'] = ['required', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
} elseif ($this->isMethod('put')) {
|
||||
$rules['image'] = ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'image' => filled($this->image) ? $this->image : null,
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'content_theme.required' => 'Tema konten wajib diisi.',
|
||||
'content_theme.max' => 'Tema konten tidak boleh lebih dari 200 karakter.',
|
||||
'posted_date.required' => 'Tanggal posting wajib diisi.',
|
||||
'posted_date.date' => 'Tanggal posting harus berupa format tanggal yang valid.',
|
||||
'channel.required' => 'Kanal wajib dipilih.',
|
||||
'channel.in' => 'Kanal harus salah satu dari: website, tiktok, youtube, instagram, facebook, twitter, atau cetak.',
|
||||
'link.required' => 'Link wajib diisi.',
|
||||
'link.url' => 'Link harus berupa URL yang valid.',
|
||||
'classification_id.required' => 'Klasifikasi wajib dipilih.',
|
||||
'classification_id.exists' => 'Klasifikasi tidak ditemukan dalam data yang tersedia.',
|
||||
'social_media.required' => 'Media sosial wajib diisi.',
|
||||
'image.required' => 'Gambar wajib diunggah.',
|
||||
'image.image' => 'File yang diunggah harus berupa gambar.',
|
||||
'image.mimes' => 'Format gambar harus PNG, JPG, atau JPEG.',
|
||||
'image.max' => 'Ukuran gambar maksimal 2MB.',
|
||||
'description.nullable' => 'Deskripsi bersifat opsional.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CooperationCompletionRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['3']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'payment_request_letter' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'invoice' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'bank_reference' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'electronic_tax_invoice' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'other_document' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'description' => ['nullable'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'payment_request_letter.required' => 'Surat permohonan pembayaran wajib diunggah.',
|
||||
'payment_request_letter.file' => 'Surat permohonan pembayaran harus berupa file yang valid.',
|
||||
'payment_request_letter.mimes' => 'Surat permohonan pembayaran harus berformat PDF.',
|
||||
'payment_request_letter.max' => 'Ukuran surat permohonan pembayaran tidak boleh lebih dari 2MB.',
|
||||
|
||||
'invoice.required' => 'Invoice/Tagihan wajib diunggah.',
|
||||
'invoice.file' => 'Invoice/Tagihan harus berupa file yang valid.',
|
||||
'invoice.mimes' => 'Invoice/Tagihan harus berformat PDF.',
|
||||
'invoice.max' => 'Ukuran Invoice/Tagihan tidak boleh lebih dari 2MB.',
|
||||
|
||||
'bank_reference.required' => 'Referensi Bank wajib diunggah.',
|
||||
'bank_reference.file' => 'Referensi Bank harus berupa file yang valid.',
|
||||
'bank_reference.mimes' => 'Referensi Bank harus berformat PDF.',
|
||||
'bank_reference.max' => 'Ukuran Referensi Bank tidak boleh lebih dari 2MB.',
|
||||
|
||||
'electronic_tax_invoice.required' => 'E-Faktur wajib diunggah.',
|
||||
'electronic_tax_invoice.file' => 'E-Faktur harus berupa file yang valid.',
|
||||
'electronic_tax_invoice.mimes' => 'E-Faktur harus berformat PDF.',
|
||||
'electronic_tax_invoice.max' => 'Ukuran E-Faktur tidak boleh lebih dari 2MB.',
|
||||
|
||||
'other_document.required' => 'Dokumen lainnya wajib diunggah.',
|
||||
'other_document.file' => 'Dokumen lainnya harus berupa file yang valid.',
|
||||
'other_document.mimes' => 'Dokumen lainnya harus berformat PDF.',
|
||||
'other_document.max' => 'Ukuran dokumen lainnya tidak boleh lebih dari 2MB.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CooperationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['required'],
|
||||
'start_date' => ['required', 'date'],
|
||||
'end_date' => ['required', 'date'],
|
||||
'media_ids' => ['required', 'array'],
|
||||
'media_ids.*' => ['required'],
|
||||
'banner' => ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'],
|
||||
'description' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['offer_file_template'] = ['required', 'file', 'mimes:pdf', 'max:2048'];
|
||||
} else {
|
||||
$rules['offer_file_template'] = ['nullable', 'file', 'mimes:pdf', 'max:2048'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama kegiatan wajib diisi.',
|
||||
'start_date.required' => 'Tanggal mulai wajib diisi.',
|
||||
'start_date.date' => 'Format tanggal mulai tidak valid.',
|
||||
'end_date.required' => 'Tanggal selesai wajib diisi.',
|
||||
'end_date.date' => 'Format tanggal selesai tidak valid.',
|
||||
|
||||
'media_ids.required' => 'Media wajib dipilih.',
|
||||
'media_ids.array' => 'Format media tidak valid.',
|
||||
'media_ids.*.required' => 'Setiap media harus dipilih.',
|
||||
'media_ids.*.exists' => 'Media yang dipilih tidak valid.',
|
||||
|
||||
'banner.image' => 'File banner harus berupa gambar.',
|
||||
'banner.mimes' => 'Format banner harus PNG, JPG, atau JPEG.',
|
||||
'banner.max' => 'Ukuran banner maksimal 2MB.',
|
||||
|
||||
'offer_file_template.required' => 'File wajib diisi.',
|
||||
'offer_file_template.file' => 'File template harus berupa file yang valid.',
|
||||
'offer_file_template.mimes' => 'Format file template harus PDF.',
|
||||
'offer_file_template.max' => 'Ukuran file template maksimal 2MB.',
|
||||
|
||||
'description.required' => 'Deskripsi kerja sama wajib diisi.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GovernmentAgencyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'short_name' => ['nullable', 'max:100'],
|
||||
'location' => ['nullable'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'short_name' => filled($this->short_name) ? $this->short_name : null,
|
||||
'location' => filled($this->location) ? $this->location : null,
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama OPD harus diisi.',
|
||||
'name.max' => 'Nama OPD tidak boleh lebih dari 100 karakter.',
|
||||
'short_name.nullable' => 'Singkatan nama boleh kosong jika tidak diperlukan.',
|
||||
'short_name.max' => 'Singkatan nama tidak boleh lebih dari 100 karakter.',
|
||||
'location.nullable' => 'Lokasi boleh kosong jika tidak diperlukan.',
|
||||
'description.nullable' => 'Deskripsi boleh kosong jika tidak diperlukan.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class IssueManagementRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1', '2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'location_id' => ['required', 'exists:locations,id'],
|
||||
'sub_location_id' => ['required', 'exists:sub_locations,id'],
|
||||
'classification_id' => ['required', 'exists:classifications,id'],
|
||||
'sub_classification_id' => ['required', 'exists:sub_classifications,id'],
|
||||
'issue' => ['required'],
|
||||
'response' => ['required'],
|
||||
'description' => ['required'],
|
||||
'government_agencies' => ['required', 'array'],
|
||||
'government_agencies.*' => ['required', 'exists:government_agencies,id'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'location_id.required' => 'Lokus harus dipilih.',
|
||||
'location_id.exists' => 'Lokus yang dipilih tidak valid.',
|
||||
|
||||
'sub_location_id.required' => 'Sub Lokus harus dipilih.',
|
||||
'sub_location_id.exists' => 'Sub Lokus yang dipilih tidak valid.',
|
||||
|
||||
'classification_id.required' => 'Klasifikasi harus dipilih.',
|
||||
'classification_id.exists' => 'Klasifikasi yang dipilih tidak valid.',
|
||||
|
||||
'sub_classification_id.required' => 'Sub Klasifikasi harus dipilih.',
|
||||
'sub_classification_id.exists' => 'Sub Klasifikasi yang dipilih tidak valid.',
|
||||
|
||||
'issue.required' => 'Masalah harus diisi.',
|
||||
'response.required' => 'Tanggapan harus diisi.',
|
||||
'description.required' => 'Deskripsi harus diisi.',
|
||||
|
||||
'government_agencies.required' => 'Agensi pemerintah harus dipilih.',
|
||||
'government_agencies.array' => 'Agensi pemerintah harus dalam bentuk array.',
|
||||
'government_agencies.*.required' => 'Agensi pemerintah pada setiap item harus dipilih.',
|
||||
'government_agencies.*.exists' => 'Agensi pemerintah yang dipilih tidak valid.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class JournalistCooperationProposalRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['3']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'journalist_ids' => ['required', 'array'],
|
||||
'journalist_ids.*' => ['required', 'exists:journalists,id'],
|
||||
'e_catalog' => ['nullable'],
|
||||
'description' => ['nullable'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['attachment'] = ['required', 'file', 'mimes:pdf', 'max:2048'];
|
||||
} else {
|
||||
$rules['attachment'] = ['nullable', 'file', 'mimes:pdf', 'max:2048'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'journalist_ids.required' => 'Pilih setidaknya satu jurnalis.',
|
||||
'journalist_ids.array' => 'Jurnalis yang dipilih tidak valid.',
|
||||
'journalist_ids.*.required' => 'Setiap jurnalis yang dipilih harus valid.',
|
||||
'journalist_ids.*.exists' => 'Jurnalis yang dipilih tidak ditemukan di database.',
|
||||
'attachment.required' => 'File pengajuan wajib diunggah.',
|
||||
'attachment.file' => 'File yang diunggah tidak valid.',
|
||||
'attachment.mimes' => 'File harus berformat PDF.',
|
||||
'attachment.max' => 'Ukuran file maksimal 2 MB.',
|
||||
'e_catalog.nullable' => 'E-Katalog boleh kosong.',
|
||||
'description.nullable' => 'Deskripsi boleh kosong.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class JournalistRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['3']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'journalist_name' => ['required', 'max:100'],
|
||||
'journalist_email' => ['required', 'max:100', 'email'],
|
||||
'journalist_phone_number' => ['required', 'max:100'],
|
||||
'journalist_press_card' => ['nullable', 'max:100'],
|
||||
'journalist_press_card_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'journalist_ukw_sertificate' => ['nullable', 'max:100'],
|
||||
'journalist_ukw_sertificate_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'journalist_name.required' => 'Nama jurnalis wajib diisi.',
|
||||
'journalist_name.max' => 'Nama jurnalis maksimal 100 karakter.',
|
||||
'journalist_email.required' => 'Email jurnalis wajib diisi.',
|
||||
'journalist_email.max' => 'Email jurnalis maksimal 100 karakter.',
|
||||
'journalist_email.email' => 'Email jurnalis tidak valid.',
|
||||
'journalist_phone_number.required' => 'Nomor telepon jurnalis wajib diisi.',
|
||||
'journalist_phone_number.max' => 'Nomor telepon jurnalis maksimal 100 karakter.',
|
||||
'journalist_press_card.max' => 'Kartu pers jurnalis maksimal 100 karakter.',
|
||||
'journalist_press_card_doc.file' => 'Dokumen kartu pers jurnalis harus berupa file.',
|
||||
'journalist_press_card_doc.mimes' => 'Dokumen kartu pers jurnalis harus dalam format PDF.',
|
||||
'journalist_press_card_doc.max' => 'Ukuran dokumen kartu pers jurnalis maksimal 2 MB.',
|
||||
'journalist_ukw_sertificate.max' => 'Sertifikat UKW jurnalis maksimal 100 karakter.',
|
||||
'journalist_ukw_sertificate_doc.file' => 'Dokumen sertifikat UKW jurnalis harus berupa file.',
|
||||
'journalist_ukw_sertificate_doc.mimes' => 'Dokumen sertifikat UKW jurnalis harus dalam format PDF.',
|
||||
'journalist_ukw_sertificate_doc.max' => 'Ukuran dokumen sertifikat UKW jurnalis maksimal 2 MB.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'journalist_press_card' => filled($this->journalist_press_card) ? $this->journalist_press_card : null,
|
||||
'journalist_press_card_doc' => filled($this->journalist_press_card_doc) ? $this->journalist_press_card_doc : null,
|
||||
'journalist_ukw_sertificate' => filled($this->journalist_ukw_sertificate) ? $this->journalist_ukw_sertificate : null,
|
||||
'journalist_ukw_sertificate_doc' => filled($this->journalist_ukw_sertificate_doc) ? $this->journalist_ukw_sertificate_doc : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LocationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'status' => ['required', 'in:0,1'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama lokus harus diisi.',
|
||||
'name.max' => 'Nama lokus tidak boleh lebih dari 100 karakter.',
|
||||
'status.required' => 'Status harus dipilih.',
|
||||
'status.in' => 'Status harus memiliki nilai aktif atau tidak aktif.',
|
||||
'description.nullable' => 'Deskripsi boleh kosong jika tidak diperlukan.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return ! Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required' => Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
'g-recaptcha-response' => 'recaptcha',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email.required' => 'Email wajib diisi!',
|
||||
'email.email' => 'Format email yang dimasukkan tidak valid!',
|
||||
'password.required' => 'Password wajib diisi!',
|
||||
'password.string' => 'Password harus berupa teks (string)!',
|
||||
'password.min' => 'Password harus memiliki minimal 8 karakter!',
|
||||
'password.mixedCase' => 'Password harus mengandung huruf besar dan huruf kecil!',
|
||||
'password.numbers' => 'Password harus mengandung angka!',
|
||||
'password.symbols' => 'Password harus mengandung simbol!',
|
||||
'g-recaptcha-response.recaptcha' => 'reCaptcha wajib diisi!',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MediaMonitoringRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1', '2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'media_name' => ['required', 'max:100'],
|
||||
'theme' => ['required', 'max:100'],
|
||||
'title' => ['required'],
|
||||
'link' => ['nullable', 'url'],
|
||||
'news_page' => ['nullable'],
|
||||
'writter' => ['required', 'max:100'],
|
||||
'channel' => ['required', 'in:website,tiktok,youtube,instagram,facebook,twitter,cetak'],
|
||||
'content' => ['required'],
|
||||
'influencer' => ['nullable', 'max:100'],
|
||||
'keyword' => ['required', 'max:100'],
|
||||
'quote' => ['nullable'],
|
||||
'release_date' => ['required', 'date'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['image'] = ['required', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
} elseif ($this->isMethod('put')) {
|
||||
$rules['image'] = ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'link' => filled($this->link) ? $this->link : null,
|
||||
'influencer' => filled($this->influencer) ? $this->influencer : null,
|
||||
'quote' => filled($this->quote) ? $this->quote : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'media_name.required' => 'Nama media wajib diisi.',
|
||||
'media_name.max' => 'Nama media tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'theme.required' => 'Tema wajib diisi.',
|
||||
'theme.max' => 'Tema tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'title.required' => 'Judul wajib diisi.',
|
||||
|
||||
'link.url' => 'Link harus berupa URL yang valid.',
|
||||
|
||||
'writter.required' => 'Nama penulis wajib diisi.',
|
||||
'writter.max' => 'Nama penulis tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'channel.required' => 'Channel wajib dipilih.',
|
||||
'channel.in' => 'Channel yang dipilih tidak valid. Pilih salah satu dari: website, tiktok, youtube, instagram, facebook, twitter, atau cetak.',
|
||||
|
||||
'content.required' => 'Konten wajib diisi.',
|
||||
|
||||
'influencer.max' => 'Nama influencer tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'keyword.required' => 'Keyword wajib diisi.',
|
||||
'keyword.max' => 'Keyword tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'release_date.required' => 'Tanggal rilis wajib diisi.',
|
||||
'release_date.date' => 'Tanggal rilis harus dalam format tanggal yang valid.',
|
||||
|
||||
'image.required' => 'Gambar wajib diunggah.',
|
||||
'image.image' => 'File yang diunggah harus berupa gambar.',
|
||||
'image.mimes' => 'Gambar hanya boleh berformat PNG, JPG, atau JPEG.',
|
||||
'image.max' => 'Ukuran gambar tidak boleh lebih dari 2MB.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MediaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'media_name' => ['required', 'max:100'],
|
||||
'media_address' => ['required'],
|
||||
'media_link' => ['required'],
|
||||
'media_type' => ['required', 'in:online,cetak,radio,televisi'],
|
||||
'media_classification' => ['required', 'in:lokal,regional,nasional'],
|
||||
'media_journalism_organization' => ['nullable', 'max:100'],
|
||||
'media_journalism_organization_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'media_press_council_certificate' => ['nullable', 'max:100'],
|
||||
'media_press_council_certificate_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'media_name.required' => 'Nama media wajib diisi.',
|
||||
'media_name.max' => 'Nama media maksimal 100 karakter.',
|
||||
'media_address.required' => 'Alamat media wajib diisi.',
|
||||
'media_link.required' => 'Link media wajib diisi.',
|
||||
'media_type.required' => 'Tipe media wajib dipilih.',
|
||||
'media_type.in' => 'Tipe media tidak valid.',
|
||||
'media_classification.required' => 'Klasifikasi media wajib dipilih.',
|
||||
'media_classification.in' => 'Klasifikasi media tidak valid.',
|
||||
'media_journalism_organization.max' => 'Organisasi jurnalistik media maksimal 100 karakter.',
|
||||
'media_journalism_organization_doc.file' => 'Dokumen organisasi jurnalistik media harus berupa file.',
|
||||
'media_journalism_organization_doc.mimes' => 'Dokumen organisasi jurnalistik media harus dalam format PDF.',
|
||||
'media_journalism_organization_doc.max' => 'Ukuran dokumen organisasi jurnalistik media maksimal 2 MB.',
|
||||
'media_press_council_certificate.max' => 'Sertifikat Dewan Pers media maksimal 100 karakter.',
|
||||
'media_press_council_certificate_doc.file' => 'Dokumen sertifikat Dewan Pers media harus berupa file.',
|
||||
'media_press_council_certificate_doc.mimes' => 'Dokumen sertifikat Dewan Pers media harus dalam format PDF.',
|
||||
'media_press_council_certificate_doc.max' => 'Ukuran dokumen sertifikat Dewan Pers media maksimal 2 MB.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'media_journalism_organization' => filled($this->media_journalism_organization) ? $this->media_journalism_organization : null,
|
||||
'media_journalism_organization_doc' => filled($this->media_journalism_organization_doc) ? $this->media_journalism_organization_doc : null,
|
||||
'media_press_council_certificate' => filled($this->media_press_council_certificate) ? $this->media_press_council_certificate : null,
|
||||
'media_press_council_certificate_doc' => filled($this->media_press_council_certificate_doc) ? $this->media_press_council_certificate_doc : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NewsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'title' => ['required', 'max:200'],
|
||||
'content' => ['required'],
|
||||
'link' => ['nullable', 'url'],
|
||||
'tag' => ['nullable'],
|
||||
'category' => ['required', 'in:0,1'],
|
||||
'image' => ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'],
|
||||
'slug' => ['required'],
|
||||
'author_id' => ['required'],
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => 'Judul harus diisi.',
|
||||
'title.max' => 'Judul tidak boleh lebih dari 200 karakter.',
|
||||
'content.required' => 'Konten harus diisi.',
|
||||
'link.url' => 'Harus link valid.',
|
||||
'category.required' => 'Kategori harus dipilih.',
|
||||
'category.in' => 'Kategori harus bernilai berita atau pengumuman.',
|
||||
|
||||
'image.required' => 'Gambar wajib diunggah.',
|
||||
'image.image' => 'File yang diunggah harus berupa gambar.',
|
||||
'image.mimes' => 'Format gambar yang diperbolehkan adalah PNG, JPG, atau JPEG.',
|
||||
'image.max' => 'Ukuran gambar tidak boleh lebih dari 4MB.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'slug' => filled($this->title) ? Str::slug($this->title) : null,
|
||||
'author_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class OrderRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => ['required', 'date'],
|
||||
'end_date' => ['required', 'date'],
|
||||
'media_ids' => ['required', 'array'],
|
||||
'media_ids.*' => ['required', 'exists:media,id'],
|
||||
'image' => ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'],
|
||||
'required_reports' => ['required', 'numeric', 'min:1', 'max:100'],
|
||||
'task_description' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'start_date.required' => 'Tanggal mulai harus diisi.',
|
||||
'start_date.date' => 'Format tanggal mulai tidak valid.',
|
||||
|
||||
'end_date.required' => 'Tanggal selesai harus diisi.',
|
||||
'end_date.date' => 'Format tanggal selesai tidak valid.',
|
||||
|
||||
'media_ids.required' => 'Media harus dipilih.',
|
||||
'media_ids.array' => 'Format media tidak valid.',
|
||||
'media_ids.*.required' => 'Media yang dipilih tidak boleh kosong.',
|
||||
'media_ids.*.exists' => 'Media yang dipilih tidak ditemukan dalam sistem.',
|
||||
|
||||
'image.image' => 'File yang diunggah harus berupa gambar.',
|
||||
'image.mimes' => 'Gambar harus berformat PNG, JPG, atau JPEG.',
|
||||
'image.max' => 'Ukuran gambar maksimal adalah 2MB.',
|
||||
|
||||
'required_reports.required' => 'Jumlah laporan yang dibutuhkan harus diisi.',
|
||||
'required_reports.numeric' => 'Jumlah laporan harus berupa angka.',
|
||||
'required_reports.min' => 'Jumlah laporan minimal adalah 1.',
|
||||
'required_reports.max' => 'Jumlah laporan maksimal adalah 100.',
|
||||
|
||||
'task_description.required' => 'Deskripsi tugas harus diisi.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReceiveMessageContactRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:25'],
|
||||
'email' => ['required', 'max:25'],
|
||||
'phone_number' => ['required', 'max:15'],
|
||||
'message' => ['required'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,203 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class RegisterRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return ! Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// Login credential
|
||||
'name' => ['required'],
|
||||
'email' => ['required', 'email', 'unique:users,email'],
|
||||
'password' => ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
// Company
|
||||
'company_name' => ['required', 'max:100'],
|
||||
'company_email' => ['required', 'max:100', 'email'],
|
||||
'company_address' => ['required'],
|
||||
'company_director_name' => ['required', 'max:100'],
|
||||
'company_director_nik' => ['required', 'max:100'],
|
||||
'company_director_nik_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_deed_incorporation' => ['required', 'max:100'],
|
||||
'company_deed_incorporation_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_trade_license' => ['required', 'max:100'],
|
||||
'company_trade_license_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_tax_id_number' => ['required', 'max:100'],
|
||||
'company_tax_id_number_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_taxable_enterprise' => ['required', 'max:100'],
|
||||
'company_taxable_enterprise_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_annual_tax_return' => ['required', 'max:100'],
|
||||
'company_annual_tax_return_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_domicile_certificate' => ['required', 'max:100'],
|
||||
'company_domicile_certificate_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'company_profile' => ['required', 'max:100'],
|
||||
'company_profile_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
// Media
|
||||
'media_name' => ['required', 'max:100'],
|
||||
'media_address' => ['required'],
|
||||
'media_link' => ['required'],
|
||||
'media_type' => ['required', 'in:online,cetak,radio,televisi'],
|
||||
'media_classification' => ['required', 'in:lokal,regional,nasional'],
|
||||
'media_journalism_organization' => ['nullable', 'max:100'],
|
||||
'media_journalism_organization_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'media_press_council_certificate' => ['nullable', 'max:100'],
|
||||
'media_press_council_certificate_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
|
||||
// Journalist
|
||||
'journalist_name' => ['required', 'max:100'],
|
||||
'journalist_email' => ['required', 'max:100', 'email'],
|
||||
'journalist_phone_number' => ['required', 'max:100'],
|
||||
'journalist_press_card' => ['required', 'max:100'],
|
||||
'journalist_press_card_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
'journalist_ukw_sertificate' => ['required', 'max:100'],
|
||||
'journalist_ukw_sertificate_doc' => ['required', 'file', 'mimes:pdf', 'max:2048'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// Login credential
|
||||
'name.required' => 'Nama wajib diisi.',
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Email tidak valid.',
|
||||
'email.unique' => 'Email sudah terdaftar.',
|
||||
'password.required' => 'Password wajib diisi.',
|
||||
'password.confirmed' => 'Konfirmasi password tidak cocok.',
|
||||
'password.min' => 'Password harus memiliki minimal 8 karakter.',
|
||||
'password.mixedCase' => 'Password harus mengandung huruf besar dan kecil.',
|
||||
'password.numbers' => 'Password harus mengandung angka.',
|
||||
'password.symbols' => 'Password harus mengandung simbol.',
|
||||
|
||||
// Company
|
||||
'company_name.required' => 'Nama perusahaan wajib diisi.',
|
||||
'company_name.max' => 'Nama perusahaan maksimal 100 karakter.',
|
||||
'company_email.required' => 'Email perusahaan wajib diisi.',
|
||||
'company_email.email' => 'Email perusahaan tidak valid.',
|
||||
'company_email.max' => 'Email perusahaan maksimal 100 karakter.',
|
||||
'company_address.required' => 'Alamat perusahaan wajib diisi.',
|
||||
'company_director_name.required' => 'Nama direktur perusahaan wajib diisi.',
|
||||
'company_director_name.max' => 'Nama direktur perusahaan maksimal 100 karakter.',
|
||||
'company_director_nik.required' => 'NIK direktur perusahaan wajib diisi.',
|
||||
'company_director_nik.max' => 'NIK direktur perusahaan maksimal 100 karakter.',
|
||||
'company_director_nik_doc.required' => 'Dokumen NIK direktur perusahaan wajib diunggah.',
|
||||
'company_director_nik_doc.file' => 'Dokumen NIK direktur perusahaan harus berupa file.',
|
||||
'company_director_nik_doc.mimes' => 'Dokumen NIK direktur perusahaan harus dalam format PDF.',
|
||||
'company_director_nik_doc.max' => 'Ukuran dokumen NIK direktur perusahaan maksimal 2 MB.',
|
||||
|
||||
// Documents
|
||||
'company_deed_incorporation.max' => 'Akta pendirian perusahaan maksimal 100 karakter.',
|
||||
'company_deed_incorporation_doc.file' => 'Dokumen akta pendirian perusahaan harus berupa file.',
|
||||
'company_deed_incorporation_doc.mimes' => 'Dokumen akta pendirian perusahaan harus dalam format PDF.',
|
||||
'company_deed_incorporation_doc.max' => 'Ukuran dokumen akta pendirian perusahaan maksimal 2 MB.',
|
||||
'company_trade_license.max' => 'Lisensi perdagangan perusahaan maksimal 100 karakter.',
|
||||
'company_trade_license_doc.file' => 'Dokumen lisensi perdagangan perusahaan harus berupa file.',
|
||||
'company_trade_license_doc.mimes' => 'Dokumen lisensi perdagangan perusahaan harus dalam format PDF.',
|
||||
'company_trade_license_doc.max' => 'Ukuran dokumen lisensi perdagangan perusahaan maksimal 2 MB.',
|
||||
'company_tax_id_number.max' => 'Nomor NPWP perusahaan maksimal 100 karakter.',
|
||||
'company_tax_id_number_doc.file' => 'Dokumen NPWP perusahaan harus berupa file.',
|
||||
'company_tax_id_number_doc.mimes' => 'Dokumen NPWP perusahaan harus dalam format PDF.',
|
||||
'company_tax_id_number_doc.max' => 'Ukuran dokumen NPWP perusahaan maksimal 2 MB.',
|
||||
'company_taxable_enterprise.max' => 'Nomor PKP perusahaan maksimal 100 karakter.',
|
||||
'company_taxable_enterprise_doc.file' => 'Dokumen PKP perusahaan harus berupa file.',
|
||||
'company_taxable_enterprise_doc.mimes' => 'Dokumen PKP perusahaan harus dalam format PDF.',
|
||||
'company_taxable_enterprise_doc.max' => 'Ukuran dokumen PKP perusahaan maksimal 2 MB.',
|
||||
'company_annual_tax_return.max' => 'Laporan SPT tahunan perusahaan maksimal 100 karakter.',
|
||||
'company_annual_tax_return_doc.file' => 'Dokumen SPT tahunan perusahaan harus berupa file.',
|
||||
'company_annual_tax_return_doc.mimes' => 'Dokumen SPT tahunan perusahaan harus dalam format PDF.',
|
||||
'company_annual_tax_return_doc.max' => 'Ukuran dokumen SPT tahunan perusahaan maksimal 2 MB.',
|
||||
'company_domicile_certificate.max' => 'Sertifikat domisili perusahaan maksimal 100 karakter.',
|
||||
'company_domicile_certificate_doc.file' => 'Dokumen sertifikat domisili perusahaan harus berupa file.',
|
||||
'company_domicile_certificate_doc.mimes' => 'Dokumen sertifikat domisili perusahaan harus dalam format PDF.',
|
||||
'company_domicile_certificate_doc.max' => 'Ukuran dokumen sertifikat domisili perusahaan maksimal 2 MB.',
|
||||
'company_profile.max' => 'Profil perusahaan maksimal 100 karakter.',
|
||||
'company_profile_doc.file' => 'Dokumen profil perusahaan harus berupa file.',
|
||||
'company_profile_doc.mimes' => 'Dokumen profil perusahaan harus dalam format PDF.',
|
||||
'company_profile_doc.max' => 'Ukuran dokumen profil perusahaan maksimal 2 MB.',
|
||||
|
||||
// Media
|
||||
'media_name.required' => 'Nama media wajib diisi.',
|
||||
'media_name.max' => 'Nama media maksimal 100 karakter.',
|
||||
'media_address.required' => 'Alamat media wajib diisi.',
|
||||
'media_link.required' => 'Link media wajib diisi.',
|
||||
'media_type.required' => 'Tipe media wajib dipilih.',
|
||||
'media_type.in' => 'Tipe media tidak valid.',
|
||||
'media_classification.required' => 'Klasifikasi media wajib dipilih.',
|
||||
'media_classification.in' => 'Klasifikasi media tidak valid.',
|
||||
'media_journalism_organization.max' => 'Organisasi jurnalistik media maksimal 100 karakter.',
|
||||
'media_journalism_organization_doc.file' => 'Dokumen organisasi jurnalistik media harus berupa file.',
|
||||
'media_journalism_organization_doc.mimes' => 'Dokumen organisasi jurnalistik media harus dalam format PDF.',
|
||||
'media_journalism_organization_doc.max' => 'Ukuran dokumen organisasi jurnalistik media maksimal 2 MB.',
|
||||
'media_press_council_certificate.max' => 'Sertifikat Dewan Pers media maksimal 100 karakter.',
|
||||
'media_press_council_certificate_doc.file' => 'Dokumen sertifikat Dewan Pers media harus berupa file.',
|
||||
'media_press_council_certificate_doc.mimes' => 'Dokumen sertifikat Dewan Pers media harus dalam format PDF.',
|
||||
'media_press_council_certificate_doc.max' => 'Ukuran dokumen sertifikat Dewan Pers media maksimal 2 MB.',
|
||||
|
||||
// Journalist
|
||||
'journalist_name.required' => 'Nama jurnalis wajib diisi.',
|
||||
'journalist_name.max' => 'Nama jurnalis maksimal 100 karakter.',
|
||||
'journalist_email.required' => 'Email jurnalis wajib diisi.',
|
||||
'journalist_email.max' => 'Email jurnalis maksimal 100 karakter.',
|
||||
'journalist_email.email' => 'Email jurnalis tidak valid.',
|
||||
'journalist_phone_number.required' => 'Nomor telepon jurnalis wajib diisi.',
|
||||
'journalist_phone_number.max' => 'Nomor telepon jurnalis maksimal 100 karakter.',
|
||||
'journalist_press_card.max' => 'Kartu pers jurnalis maksimal 100 karakter.',
|
||||
'journalist_press_card_doc.file' => 'Dokumen kartu pers jurnalis harus berupa file.',
|
||||
'journalist_press_card_doc.mimes' => 'Dokumen kartu pers jurnalis harus dalam format PDF.',
|
||||
'journalist_press_card_doc.max' => 'Ukuran dokumen kartu pers jurnalis maksimal 2 MB.',
|
||||
'journalist_ukw_sertificate.max' => 'Sertifikat UKW jurnalis maksimal 100 karakter.',
|
||||
'journalist_ukw_sertificate_doc.file' => 'Dokumen sertifikat UKW jurnalis harus berupa file.',
|
||||
'journalist_ukw_sertificate_doc.mimes' => 'Dokumen sertifikat UKW jurnalis harus dalam format PDF.',
|
||||
'journalist_ukw_sertificate_doc.max' => 'Ukuran dokumen sertifikat UKW jurnalis maksimal 2 MB.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'company_deed_incorporation' => filled($this->company_deed_incorporation) ? $this->company_deed_incorporation : null,
|
||||
'company_deed_incorporation_doc' => filled($this->company_deed_incorporation_doc) ? $this->company_deed_incorporation_doc : null,
|
||||
'company_trade_license' => filled($this->company_trade_license) ? $this->company_trade_license : null,
|
||||
'company_trade_license_doc' => filled($this->company_trade_license_doc) ? $this->company_trade_license_doc : null,
|
||||
'company_tax_id_number' => filled($this->company_tax_id_number) ? $this->company_tax_id_number : null,
|
||||
'company_tax_id_number_doc' => filled($this->company_tax_id_number_doc) ? $this->company_tax_id_number_doc : null,
|
||||
'company_taxable_enterprise' => filled($this->company_taxable_enterprise) ? $this->company_taxable_enterprise : null,
|
||||
'company_taxable_enterprise_doc' => filled($this->company_taxable_enterprise_doc) ? $this->company_taxable_enterprise_doc : null,
|
||||
'company_annual_tax_return' => filled($this->company_annual_tax_return) ? $this->company_annual_tax_return : null,
|
||||
'company_annual_tax_return_doc' => filled($this->company_annual_tax_return_doc) ? $this->company_annual_tax_return_doc : null,
|
||||
'company_domicile_certificate' => filled($this->company_domicile_certificate) ? $this->company_domicile_certificate : null,
|
||||
'company_domicile_certificate_doc' => filled($this->company_domicile_certificate_doc) ? $this->company_domicile_certificate_doc : null,
|
||||
'company_profile' => filled($this->company_profile) ? $this->company_profile : null,
|
||||
'company_profile_doc' => filled($this->company_profile_doc) ? $this->company_profile_doc : null,
|
||||
// Media
|
||||
'media_journalism_organization' => filled($this->media_journalism_organization) ? $this->media_journalism_organization : null,
|
||||
'media_journalism_organization_doc' => filled($this->media_journalism_organization_doc) ? $this->media_journalism_organization_doc : null,
|
||||
'media_press_council_certificate' => filled($this->media_press_council_certificate) ? $this->media_press_council_certificate : null,
|
||||
'media_press_council_certificate_doc' => filled($this->media_press_council_certificate_doc) ? $this->media_press_council_certificate_doc : null,
|
||||
// Journalist
|
||||
'journalist_press_card' => filled($this->journalist_press_card) ? $this->journalist_press_card : null,
|
||||
'journalist_press_card_doc' => filled($this->journalist_press_card_doc) ? $this->journalist_press_card_doc : null,
|
||||
'journalist_ukw_sertificate' => filled($this->journalist_ukw_sertificate) ? $this->journalist_ukw_sertificate : null,
|
||||
'journalist_ukw_sertificate_doc' => filled($this->journalist_ukw_sertificate_doc) ? $this->journalist_ukw_sertificate_doc : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ReportRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['3']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'title' => ['required'],
|
||||
'publication_date' => ['required', 'date'],
|
||||
'link' => ['required', 'url'],
|
||||
'description' => ['nullable'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['proof'] = ['required', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
} else {
|
||||
$rules['proof'] = ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => 'Judul wajib diisi.',
|
||||
'publication_date.required' => 'Tanggal publikasi wajib diisi.',
|
||||
'publication_date.date' => 'Tanggal publikasi harus berupa format tanggal yang valid.',
|
||||
'link.required' => 'Link wajib diisi.',
|
||||
'link.url' => 'Format link tidak valid.',
|
||||
'proof.required' => 'Bukti tayang wajib diunggah.',
|
||||
'proof.image' => 'Bukti tayang harus berupa gambar.',
|
||||
'proof.mimes' => 'Format gambar harus PNG, JPG, atau JPEG.',
|
||||
'proof.max' => 'Ukuran gambar tidak boleh lebih dari 2MB.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\MatchCurrentPasswordRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class ResetPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' => ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
'my_password' => ['required', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols(), new MatchCurrentPasswordRule],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'password.required' => 'Password baru wajib diisi.',
|
||||
'password.confirmed' => 'Konfirmasi password baru tidak cocok.',
|
||||
'password.min' => 'Password baru harus memiliki minimal 8 karakter.',
|
||||
'password.mixedCase' => 'Password baru harus mengandung huruf besar dan huruf kecil.',
|
||||
'password.numbers' => 'Password baru harus mengandung angka.',
|
||||
'password.symbols' => 'Password baru harus mengandung simbol.',
|
||||
|
||||
'my_password.required' => 'Password Anda wajib diisi.',
|
||||
'my_password.confirmed' => 'Konfirmasi password Anda tidak cocok.',
|
||||
'my_password.min' => 'Password Anda harus memiliki minimal 8 karakter.',
|
||||
'my_password.mixedCase' => 'Password Anda harus mengandung huruf besar dan huruf kecil.',
|
||||
'my_password.numbers' => 'Password Anda harus mengandung angka.',
|
||||
'my_password.symbols' => 'Password Anda harus mengandung simbol.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SettingRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'app_name' => ['required', 'string', 'max:255'],
|
||||
'app_title' => ['required', 'string', 'max:255'],
|
||||
'app_description' => ['required', 'string'],
|
||||
'app_keywords' => ['required'],
|
||||
'app_icon' => ['nullable', 'file', 'mimes:png,jpg,jpeg', 'max:4096'],
|
||||
'app_logo' => ['nullable', 'file', 'mimes:png,jpg,jpeg', 'max:4096'],
|
||||
'contact_address' => ['nullable'],
|
||||
'contact_address_link' => ['nullable'],
|
||||
'contact_phone' => ['nullable', 'regex:/^[0-9+\s-]+$/'],
|
||||
'contact_email' => ['nullable', 'email', 'max:255'],
|
||||
'contact_facebook' => ['nullable', 'max:100'],
|
||||
'contact_twitter' => ['nullable', 'max:100'],
|
||||
'contact_instagram' => ['nullable', 'max:100'],
|
||||
'contact_youtube' => ['nullable', 'max:100'],
|
||||
'contact_whatsapp' => ['nullable', 'max:100'],
|
||||
'contact_telegram' => ['nullable', 'max:100'],
|
||||
'about_us' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'app_icon' => filled($this->app_icon) ? $this->app_icon : null,
|
||||
'app_logo' => filled($this->app_logo) ? $this->app_logo : null,
|
||||
'contact_address' => filled($this->contact_address) ? $this->contact_address : null,
|
||||
'contact_address_link' => filled($this->contact_address_link) ? $this->contact_address_link : null,
|
||||
'contact_phone' => filled($this->contact_phone) ? $this->contact_phone : null,
|
||||
'contact_email' => filled($this->contact_email) ? $this->contact_email : null,
|
||||
'contact_facebook' => filled($this->contact_facebook) ? $this->contact_facebook : null,
|
||||
'contact_twitter' => filled($this->contact_twitter) ? $this->contact_twitter : null,
|
||||
'contact_instagram' => filled($this->contact_instagram) ? $this->contact_instagram : null,
|
||||
'contact_youtube' => filled($this->contact_youtube) ? $this->contact_youtube : null,
|
||||
'contact_whatsapp' => filled($this->contact_whatsapp) ? $this->contact_whatsapp : null,
|
||||
'contact_telegram' => filled($this->contact_telegram) ? $this->contact_telegram : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SubClassificationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'classification_id' => ['required', 'exists:classifications,id'],
|
||||
'status' => ['required', 'in:0,1'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama sub klasifikasi harus diisi.',
|
||||
'name.max' => 'Nama sub klasifikasi tidak boleh lebih dari 100 karakter.',
|
||||
'classification_id.required' => 'Klasifikasi harus dipilih.',
|
||||
'classification_id.exists' => 'Klasifikasi yang dipilih tidak valid.',
|
||||
'status.required' => 'Status harus dipilih.',
|
||||
'status.in' => 'Status harus bernilai aktif atau tidak aktif.',
|
||||
'description.nullable' => 'Deskripsi boleh kosong jika tidak diperlukan.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SubLocationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'location_id' => ['required', 'exists:locations,id'],
|
||||
'status' => ['required', 'in:0,1'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama sub lokus harus diisi.',
|
||||
'name.max' => 'Nama sub lokus tidak boleh lebih dari 100 karakter.',
|
||||
'location_id.required' => 'Lokus harus dipilih.',
|
||||
'location_id.exists' => 'Lokus yang dipilih tidak valid.',
|
||||
'status.required' => 'Status harus dipilih.',
|
||||
'status.in' => 'Status harus bernilai aktif atau tidak aktif.',
|
||||
'description.nullable' => 'Deskripsi boleh kosong jika tidak diperlukan.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class UserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['required', 'max:100'],
|
||||
'role_id' => ['required', 'in:1,2,3,4,5', 'not_in:select'],
|
||||
'status' => ['required', 'in:1,2', 'not_in:select'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['email'] = ['required', 'email', 'max:100', 'unique:users,email'];
|
||||
$rules['password'] = ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
} elseif ($this->isMethod('put')) {
|
||||
$rules['email'] = ['required', 'email', 'max:100'];
|
||||
$rules['password'] = ['nullable', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
if (! filled(trim($this->password))) {
|
||||
$this->request->remove('password');
|
||||
}
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Nama wajib diisi.',
|
||||
'name.max' => 'Nama tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Email harus menggunakan format email yang valid.',
|
||||
'email.max' => 'Email tidak boleh lebih dari 100 karakter.',
|
||||
|
||||
'role_id.required' => 'Role wajib dipilih.',
|
||||
'role_id.in' => 'Role harus salah satu dari: Admin, Admin Monitoring, Admin Konten, atau Admin Keuangan.',
|
||||
|
||||
'status.required' => 'Status wajib dipilih.',
|
||||
'status.in' => 'Status harus salah satu dari: Aktif, atau Nonaktif.',
|
||||
|
||||
'password.required' => 'Password wajib diisi.',
|
||||
'password.confirmed' => 'Password dan konfirmasi password tidak cocok.',
|
||||
'password.min' => 'Password harus memiliki minimal 8 karakter.',
|
||||
'password.mixedCase' => 'Password harus mengandung huruf besar dan huruf kecil.',
|
||||
'password.numbers' => 'Password harus mengandung angka.',
|
||||
'password.symbols' => 'Password harus mengandung simbol.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Models\LoginHistory;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
|
||||
class LogUserLogin
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(Login $event): void
|
||||
{
|
||||
LoginHistory::create([
|
||||
'user_id' => $event->user->id,
|
||||
'ip_address' => request()->ip(),
|
||||
'user_agent' => request()->userAgent(),
|
||||
'logged_in_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AccountVerification extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public $status;
|
||||
|
||||
public $reason;
|
||||
|
||||
public $user;
|
||||
|
||||
public function __construct($user, $status, $rejectionReason = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->status = $status; // 'accepted' atau 'rejected'
|
||||
$this->reason = $rejectionReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: $this->status === 'accepted' ? 'Akun Simedkom Anda Disetujui' : 'Akun Simedkom Anda Ditolak'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
markdown: 'emails.account.verification',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class AiringProofTheme extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'airing_proof_themes';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'year',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['name', 'slug', 'year', 'description', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('airing_proof_theme') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Tema bukti tayang '{$this->name}' telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Announcement extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'announcements';
|
||||
|
||||
protected $fillable = [
|
||||
'headline',
|
||||
'content',
|
||||
'link',
|
||||
'attachment',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'announcements_users', 'announcement_id', 'user_id')
|
||||
->using(AnnouncementUser::class)
|
||||
->withPivot(['status', 'category'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['headline', 'content', 'link', 'attachment', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('announcement') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Pengumuman pengguna '{$this->headline}' telah {$eventName}";
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class AnnouncementUser extends Pivot
|
||||
{
|
||||
protected $table = 'announcements_users';
|
||||
|
||||
protected $fillable = [
|
||||
'announcement_id',
|
||||
'user_id',
|
||||
'status',
|
||||
'category',
|
||||
];
|
||||
|
||||
public function announcement()
|
||||
{
|
||||
return $this->belongsTo(Announcement::class, 'announcement_id', 'id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Classification extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'classifications';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function subClassifications()
|
||||
{
|
||||
return $this->hasMany(SubClassification::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function issues()
|
||||
{
|
||||
return $this->hasMany(IssueManagement::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['name', 'status', 'description', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('classification') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Klasifikasi '{$this->name}' telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Company extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'phone_number',
|
||||
'address',
|
||||
'director_name',
|
||||
'director_nik',
|
||||
'director_nik_doc',
|
||||
'deed_incorporation',
|
||||
'deed_incorporation_doc',
|
||||
'trade_license',
|
||||
'trade_license_doc',
|
||||
'tax_id_number',
|
||||
'tax_id_number_doc',
|
||||
'taxable_enterprise',
|
||||
'taxable_enterprise_doc',
|
||||
'annual_tax_return',
|
||||
'annual_tax_return_doc',
|
||||
'domicile_certificate',
|
||||
'domicile_certificate_doc',
|
||||
'profile',
|
||||
'profile_doc',
|
||||
'cooperation_request',
|
||||
'cooperation_request_doc',
|
||||
'edit_description',
|
||||
'edit_status',
|
||||
'edit_rejection_reason',
|
||||
'validated_at',
|
||||
'rejection_reason',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function media()
|
||||
{
|
||||
return $this->hasOne(Media::class, 'company_id', 'id')->withTrashed();
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'contacts';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'phone_number',
|
||||
'message',
|
||||
'reply_message',
|
||||
'ip_address',
|
||||
'status',
|
||||
];
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class ContentRecap extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'content_recaps';
|
||||
|
||||
protected $fillable = [
|
||||
'content_theme',
|
||||
'posted_date',
|
||||
'channel',
|
||||
'link',
|
||||
'classification_id',
|
||||
'social_media',
|
||||
'image',
|
||||
'content_type',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function classification()
|
||||
{
|
||||
return $this->belongsTo(ContentRecapClassification::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([
|
||||
'content_theme',
|
||||
'posted_date',
|
||||
'channel',
|
||||
'link',
|
||||
'classification_id',
|
||||
'social_media',
|
||||
'image',
|
||||
'content_type',
|
||||
'description',
|
||||
'enhancer_id', ]) // kolom yang dicatat
|
||||
->useLogName('content_recap') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Rekap Konten '{$this->content_theme}' telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class ContentRecapClassification extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'content_recap_classifications';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'year',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function contentRecaps()
|
||||
{
|
||||
return $this->hasMany(ContentRecap::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['name', 'slug', 'year', 'description', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('content_recap_classification') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Klasifikasi Rekap Konten '{$this->name}' telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Cooperation extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'cooperations';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'banner',
|
||||
'offer_file_template',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsToMany(Media::class, 'media_cooperations', 'cooperation_id', 'media_id')
|
||||
->using(MediaCooperation::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function proposals()
|
||||
{
|
||||
return $this->hasMany(CooperationProposal::class, 'cooperation_id', 'id');
|
||||
}
|
||||
|
||||
public function mediaOrder()
|
||||
{
|
||||
return $this->hasOne(Order::class, 'cooperation_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([
|
||||
'name',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'banner',
|
||||
'offer_file_template',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
]) // kolom yang dicatat
|
||||
->useLogName('cooperation') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Kerja Sama '{$this->name}' telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class CooperationCompletion extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'cooperation_completions';
|
||||
|
||||
protected $fillable = [
|
||||
'payment_request_letter',
|
||||
'invoice',
|
||||
'bank_reference',
|
||||
'electronic_tax_invoice',
|
||||
'other_document',
|
||||
'description',
|
||||
'status',
|
||||
'rejection_reason',
|
||||
'media_id',
|
||||
'order_id',
|
||||
];
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([
|
||||
'payment_request_letter',
|
||||
'invoice',
|
||||
'bank_reference',
|
||||
'electronic_tax_invoice',
|
||||
'other_document',
|
||||
'description',
|
||||
'status',
|
||||
'rejection_reason',
|
||||
'media_id',
|
||||
'order_id',
|
||||
])
|
||||
->useLogName('cooperation_completion') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Penyelesaian kerja sama telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class CooperationProposal extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'cooperation_proposals';
|
||||
|
||||
protected $fillable = [
|
||||
'attachment',
|
||||
'status',
|
||||
'e_catalog',
|
||||
'description',
|
||||
'rejection_reason',
|
||||
'cooperation_id',
|
||||
'media_id',
|
||||
];
|
||||
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
|
||||
public function cooperation()
|
||||
{
|
||||
return $this->belongsTo(Cooperation::class, 'cooperation_id', 'id');
|
||||
}
|
||||
|
||||
public function journalists()
|
||||
{
|
||||
return $this->belongsToMany(Journalist::class, 'journalists_cooperation_proposals', 'cooperation_proposal_id', 'journalist_id')
|
||||
->using(JournalistCooperationProposal::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([
|
||||
'attachment',
|
||||
'status',
|
||||
'e_catalog',
|
||||
'description',
|
||||
'rejection_reason',
|
||||
'cooperation_id',
|
||||
'media_id',
|
||||
])
|
||||
->useLogName('cooperation_proposal') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Pengajuan kerja sama telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class GovernmentAgency extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'government_agencies';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'short_name',
|
||||
'location',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function issues()
|
||||
{
|
||||
return $this->belongsToMany(IssueManagement::class, 'issue_managements_government_agencies', 'government_agency_id', 'issue_management_id')
|
||||
->using(IssueManagementGovernmentAgency::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['name', 'short_name', 'location', 'description', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('government_agency') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "OPD '{$this->name}' telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class IssueManagement extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'issue_managements';
|
||||
|
||||
protected $fillable = [
|
||||
'location_id',
|
||||
'sub_location_id',
|
||||
'classification_id',
|
||||
'sub_classification_id',
|
||||
'media_monitoring_id',
|
||||
'issue',
|
||||
'response',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(Location::class, 'location_id', 'id');
|
||||
}
|
||||
|
||||
public function subLocation()
|
||||
{
|
||||
return $this->belongsTo(SubLocation::class, 'sub_location_id', 'id');
|
||||
}
|
||||
|
||||
public function classification()
|
||||
{
|
||||
return $this->belongsTo(Classification::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function subClassification()
|
||||
{
|
||||
return $this->belongsTo(SubClassification::class, 'sub_classification_id', 'id');
|
||||
}
|
||||
|
||||
public function mediaMonitoring()
|
||||
{
|
||||
return $this->belongsTo(MediaMonitoring::class, 'media_monitoring_id', 'id');
|
||||
}
|
||||
|
||||
public function governmentAgencies()
|
||||
{
|
||||
return $this->belongsToMany(GovernmentAgency::class, 'issue_managements_government_agencies', 'issue_management_id', 'government_agency_id')
|
||||
->using(IssueManagementGovernmentAgency::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([
|
||||
'location_id',
|
||||
'sub_location_id',
|
||||
'classification_id',
|
||||
'sub_classification_id',
|
||||
'media_monitoring_id',
|
||||
'issue',
|
||||
'response',
|
||||
'description',
|
||||
'enhancer_id',
|
||||
]) // kolom yang dicatat
|
||||
->useLogName('issue_management') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
case 'updated':
|
||||
$eventName = 'diubah';
|
||||
break;
|
||||
case 'deleted':
|
||||
$eventName = 'dihapus';
|
||||
break;
|
||||
}
|
||||
|
||||
return "Manajemen Isu telah {$eventName}";
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class IssueManagementGovernmentAgency extends Pivot
|
||||
{
|
||||
protected $table = 'issue_managements_government_agencies';
|
||||
|
||||
protected $fillable = [
|
||||
'issue_management_id',
|
||||
'government_agency_id',
|
||||
];
|
||||
|
||||
public function issueManagement()
|
||||
{
|
||||
return $this->belongsTo(IssueManagement::class, 'issue_management_id', 'id');
|
||||
}
|
||||
|
||||
public function GovernmentAgency()
|
||||
{
|
||||
return $this->belongsTo(GovernmentAgency::class, 'government_agency_id', 'id');
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user