chore: run laravel pint
This commit is contained in:
parent
13ccfeac13
commit
e133f020cf
@ -10,17 +10,23 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CompanyExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class CompanyExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
* @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)
|
||||
@ -32,34 +38,35 @@ public function __construct($status, $edit_status, $address, $register_year, $re
|
||||
$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){
|
||||
if ($this->status !== 'all') {
|
||||
if ($this->status === 'waiting') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '0');
|
||||
});
|
||||
}else if($this->status === 'accepted'){
|
||||
$query->whereHas('user', function ($q){
|
||||
} elseif ($this->status === 'accepted') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '1');
|
||||
});
|
||||
}else if($this->status === 'rejected'){
|
||||
$query->whereHas('user', function ($q){
|
||||
} elseif ($this->status === 'rejected') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '2');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if($this->edit_status !== 'all'){
|
||||
if($this->edit_status === 'no-edit'){
|
||||
if ($this->edit_status !== 'all') {
|
||||
if ($this->edit_status === 'no-edit') {
|
||||
$query->where('edit_status', '0');
|
||||
}elseif($this->edit_status === 'waiting'){
|
||||
} elseif ($this->edit_status === 'waiting') {
|
||||
$query->where('edit_status', '1');
|
||||
}else if($this->edit_status === 'accepted'){
|
||||
} elseif ($this->edit_status === 'accepted') {
|
||||
$query->where('edit_status', '2');
|
||||
}else if($this->edit_status === 'rejected'){
|
||||
} elseif ($this->edit_status === 'rejected') {
|
||||
$query->where('edit_status', '3');
|
||||
}
|
||||
}
|
||||
@ -96,7 +103,7 @@ public function map($company): array
|
||||
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')
|
||||
Carbon::parse($company->validated_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -104,7 +111,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Perusahaan', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Perusahaan', 'Email', 'Direktur', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi']
|
||||
['NO', 'Nama Perusahaan', 'Email', 'Direktur', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -10,19 +10,25 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
|
||||
class ContentRecapExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class ContentRecapExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
* @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)
|
||||
@ -40,19 +46,19 @@ public function collection()
|
||||
{
|
||||
$query = ContentRecap::with(['enhancer', 'classification']);
|
||||
|
||||
if($this->classification && $this->classification !== 'all'){
|
||||
if ($this->classification && $this->classification !== 'all') {
|
||||
$query->where('classification_id', decrypt_id($this->classification));
|
||||
}
|
||||
|
||||
if($this->channel && $this->channel !== 'all'){
|
||||
if ($this->channel && $this->channel !== 'all') {
|
||||
$query->where('channel', $this->channel);
|
||||
}
|
||||
|
||||
if($this->social_media && $this->social_media !== 'all'){
|
||||
if ($this->social_media && $this->social_media !== 'all') {
|
||||
$query->where('social_media', $this->social_media);
|
||||
}
|
||||
|
||||
if($this->content_type && $this->content_type !== 'all'){
|
||||
if ($this->content_type && $this->content_type !== 'all') {
|
||||
$query->where('content_type', 'LIKE', '%'.$this->content_type.'%');
|
||||
}
|
||||
|
||||
@ -93,7 +99,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Rekap Konten', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Tema Konten', 'Link', 'Klasifikasi', 'Media Sosial', 'Jenis Konten', 'Tanggal Posting', 'Channel', 'Deskripsi', 'Dibuat Pada']
|
||||
['NO', 'Tema Konten', 'Link', 'Klasifikasi', 'Media Sosial', 'Jenis Konten', 'Tanggal Posting', 'Channel', 'Deskripsi', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -11,15 +11,17 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CooperationArchiveExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class CooperationArchiveExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($year, $month, $date)
|
||||
@ -35,17 +37,17 @@ public function collection()
|
||||
|
||||
if (is_role(['1'])) {
|
||||
// Hanya untuk role 1: filter kerja sama lebih dari 1 tahun
|
||||
if (!$this->year && !$this->month && !$this->date) {
|
||||
if (! $this->year && ! $this->month && ! $this->date) {
|
||||
$query->where('created_at', '<=', Carbon::now()->subYear());
|
||||
}
|
||||
} else if (is_role(['3'])) {
|
||||
} 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);
|
||||
});
|
||||
$query->where('status', 1)->where('media_id', $mediaId);
|
||||
});
|
||||
|
||||
if (!$this->year && !$this->month && !$this->date) {
|
||||
if (! $this->year && ! $this->month && ! $this->date) {
|
||||
$query->where('created_at', '<=', Carbon::now()->subYear());
|
||||
}
|
||||
}
|
||||
@ -83,7 +85,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Rekap Konten', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Taanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Dibuat Pada']
|
||||
['NO', 'Nama Kerja Sama', 'Taanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -3,25 +3,31 @@
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\CooperationCompletion;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
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, WithStyles, WithMapping
|
||||
class CooperationCompletionExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
* @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)
|
||||
@ -36,19 +42,19 @@ public function __construct($media, $status, $year, $from_month, $to_month, $dat
|
||||
|
||||
public function collection()
|
||||
{
|
||||
if(is_role(['1', '5'])){
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = CooperationCompletion::with(['media.company']);
|
||||
}else if(is_role(['3'])){
|
||||
} 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])) {
|
||||
if (! empty($this->media[0])) {
|
||||
$query->whereIn('media_id', $this->media);
|
||||
}
|
||||
|
||||
if ($this->status) {
|
||||
switch($this->status){
|
||||
switch ($this->status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
@ -95,7 +101,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Penyelesaian Kerja Sama', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Media', 'Perusahaan', 'Tanggal Upload', 'Status']
|
||||
['NO', 'Nama Kerja Sama', 'Media', 'Perusahaan', 'Tanggal Upload', 'Status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\Media;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
@ -12,15 +11,17 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CooperationExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class CooperationExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($year, $month, $date)
|
||||
@ -39,7 +40,7 @@ public function collection()
|
||||
|
||||
$query->whereHas('proposals', function ($q) use ($mediaId) {
|
||||
$q->where('status', 1)
|
||||
->where('media_id', $mediaId);
|
||||
->where('media_id', $mediaId);
|
||||
});
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Rekap Konten', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Tanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Media', 'Dibuat Pada']
|
||||
['NO', 'Nama Kerja Sama', 'Tanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Media', 'Dibuat Pada'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -10,18 +10,23 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class JournalistExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class JournalistExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @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)
|
||||
@ -36,17 +41,17 @@ public function __construct($media_ids, $status, $edit_status, $register_year, $
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Journalist::with(['media' => function($q) {
|
||||
$query = Journalist::with(['media' => function ($q) {
|
||||
$q->withTrashed();
|
||||
}, 'media.company' => function($q) {
|
||||
}, 'media.company' => function ($q) {
|
||||
$q->withTrashed();
|
||||
}, 'media.company.user' => function($q) {
|
||||
}, 'media.company.user' => function ($q) {
|
||||
$q->withTrashed();
|
||||
}])
|
||||
->where('approved_status', '1')
|
||||
->whereNull('deleted_at');
|
||||
->where('approved_status', '1')
|
||||
->whereNull('deleted_at');
|
||||
|
||||
if (is_array($this->media_ids) && !in_array('all', $this->media_ids)) {
|
||||
if (is_array($this->media_ids) && ! in_array('all', $this->media_ids)) {
|
||||
$query->whereIn('media_id', array_map('decrypt_id', $this->media_ids));
|
||||
}
|
||||
|
||||
@ -66,14 +71,14 @@ public function collection()
|
||||
}
|
||||
}
|
||||
|
||||
if($this->edit_status !== 'all'){
|
||||
if($this->edit_status === 'no-edit'){
|
||||
if ($this->edit_status !== 'all') {
|
||||
if ($this->edit_status === 'no-edit') {
|
||||
$query->where('edit_status', '0');
|
||||
}elseif($this->edit_status === 'waiting'){
|
||||
} elseif ($this->edit_status === 'waiting') {
|
||||
$query->where('edit_status', '1');
|
||||
}else if($this->edit_status === 'accepted'){
|
||||
} elseif ($this->edit_status === 'accepted') {
|
||||
$query->where('edit_status', '2');
|
||||
}else if($this->edit_status === 'rejected'){
|
||||
} elseif ($this->edit_status === 'rejected') {
|
||||
$query->where('edit_status', '3');
|
||||
}
|
||||
}
|
||||
@ -113,7 +118,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Jurnalis', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Jurnalis', 'Nama Media', 'Nama Perusahaan', 'Email', 'Status', 'Status Edit', 'Tanggal Daftar']
|
||||
['NO', 'Nama Jurnalis', 'Nama Media', 'Nama Perusahaan', 'Email', 'Status', 'Status Edit', 'Tanggal Daftar'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -10,20 +10,27 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class MediaExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class MediaExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @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)
|
||||
@ -42,52 +49,52 @@ public function collection()
|
||||
{
|
||||
$query = Media::with(['company.user']);
|
||||
|
||||
if($this->type !== 'all'){
|
||||
if($this->type === 'online'){
|
||||
if ($this->type !== 'all') {
|
||||
if ($this->type === 'online') {
|
||||
$query->where('type', 'online');
|
||||
}elseif($this->type === 'print'){
|
||||
} elseif ($this->type === 'print') {
|
||||
$query->where('type', 'cetak');
|
||||
}else if($this->type === 'radio'){
|
||||
} elseif ($this->type === 'radio') {
|
||||
$query->where('type', 'radio');
|
||||
}else if($this->type === 'television'){
|
||||
} elseif ($this->type === 'television') {
|
||||
$query->where('type', 'televisi');
|
||||
}
|
||||
}
|
||||
|
||||
if($this->classification !== 'all'){
|
||||
if($this->classification === 'local'){
|
||||
if ($this->classification !== 'all') {
|
||||
if ($this->classification === 'local') {
|
||||
$query->where('classification', 'lokal');
|
||||
}elseif($this->classification === 'regional'){
|
||||
} elseif ($this->classification === 'regional') {
|
||||
$query->where('classification', 'regional');
|
||||
}else if($this->classification === 'national'){
|
||||
} elseif ($this->classification === 'national') {
|
||||
$query->where('classification', 'nasional');
|
||||
}
|
||||
}
|
||||
|
||||
if($this->status !== 'all'){
|
||||
if($this->status === 'waiting'){
|
||||
$query->whereHas('user', function ($q){
|
||||
if ($this->status !== 'all') {
|
||||
if ($this->status === 'waiting') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '0');
|
||||
});
|
||||
}else if($this->status === 'accepted'){
|
||||
$query->whereHas('user', function ($q){
|
||||
} elseif ($this->status === 'accepted') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '1');
|
||||
});
|
||||
}else if($this->status === 'rejected'){
|
||||
$query->whereHas('user', function ($q){
|
||||
} elseif ($this->status === 'rejected') {
|
||||
$query->whereHas('user', function ($q) {
|
||||
$q->where('status', '2');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if($this->edit_status !== 'all'){
|
||||
if($this->edit_status === 'no-edit'){
|
||||
if ($this->edit_status !== 'all') {
|
||||
if ($this->edit_status === 'no-edit') {
|
||||
$query->where('edit_status', '0');
|
||||
}elseif($this->edit_status === 'waiting'){
|
||||
} elseif ($this->edit_status === 'waiting') {
|
||||
$query->where('edit_status', '1');
|
||||
}else if($this->edit_status === 'accepted'){
|
||||
} elseif ($this->edit_status === 'accepted') {
|
||||
$query->where('edit_status', '2');
|
||||
}else if($this->edit_status === 'rejected'){
|
||||
} elseif ($this->edit_status === 'rejected') {
|
||||
$query->where('edit_status', '3');
|
||||
}
|
||||
}
|
||||
@ -126,7 +133,7 @@ public function map($media): array
|
||||
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')
|
||||
Carbon::parse($media->company->validated_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -134,7 +141,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Media', '', '', '', '', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Media', 'Nama Perusahaan', 'Email', 'Tipe', 'Klasifikasi', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi']
|
||||
['NO', 'Nama Media', 'Nama Perusahaan', 'Email', 'Tipe', 'Klasifikasi', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -10,22 +10,31 @@
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class MediaMonitoringExport implements FromCollection, WithHeadings, WithStyles, WithMapping
|
||||
class MediaMonitoringExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @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)
|
||||
@ -46,55 +55,55 @@ public function collection()
|
||||
{
|
||||
$query = MediaMonitoring::with(['enhancer', 'issue']);
|
||||
|
||||
if($this->news_title){
|
||||
$query->where('title', 'LIKE', '%'. $this->news_title.'%');
|
||||
}
|
||||
if ($this->news_title) {
|
||||
$query->where('title', 'LIKE', '%'.$this->news_title.'%');
|
||||
}
|
||||
|
||||
if($this->channel && $this->channel !== 'all'){
|
||||
$query->where('channel', $this->channel);
|
||||
}
|
||||
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->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->keyword) {
|
||||
$query->where('keyword', 'LIKE', '%'.$this->keyword.'%');
|
||||
}
|
||||
|
||||
if ($this->input_year) {
|
||||
$query->whereYear('created_at', $this->input_year);
|
||||
}
|
||||
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_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->input_date) {
|
||||
$query->whereDate('created_at', $this->input_date);
|
||||
}
|
||||
|
||||
if ($this->release_year) {
|
||||
$query->whereYear('release_date', $this->release_year);
|
||||
}
|
||||
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_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);
|
||||
}
|
||||
if ($this->release_date) {
|
||||
$query->whereDate('release_date', $this->release_date);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function map($mediaMonitoring): array
|
||||
@ -123,7 +132,7 @@ 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']
|
||||
'Tanggal Input'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -4,23 +4,25 @@
|
||||
|
||||
use App\Models\News;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
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, WithStyles, WithMapping
|
||||
class NewsExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $no = 1;
|
||||
|
||||
protected $category;
|
||||
|
||||
protected $year;
|
||||
|
||||
protected $month;
|
||||
|
||||
protected $date;
|
||||
|
||||
public function __construct($category, $year, $month, $date)
|
||||
@ -30,14 +32,15 @@ public function __construct($category, $year, $month, $date)
|
||||
$this->month = $month;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = News::query();
|
||||
|
||||
if($this->category !== 'all'){
|
||||
if($this->category === 'news'){
|
||||
if ($this->category !== 'all') {
|
||||
if ($this->category === 'news') {
|
||||
$query->where('category', '0');
|
||||
}else if($this->category === 'announcement'){
|
||||
} elseif ($this->category === 'announcement') {
|
||||
$query->where('category', '1');
|
||||
}
|
||||
}
|
||||
@ -67,7 +70,7 @@ public function map($news): array
|
||||
$news->link ?? 'Tidak ada',
|
||||
$news->tag ?? 'Tidak ada',
|
||||
$news->category === '0' ? 'Berita' : 'Pengumuman',
|
||||
$news->views == '0'? '0' : $news->views,
|
||||
$news->views == '0' ? '0' : $news->views,
|
||||
Carbon::parse($news->created_at)->locale('id')->translatedFormat('l, d F Y'),
|
||||
$news->author->name,
|
||||
];
|
||||
@ -77,7 +80,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Data Berita', '', '', '', '', '', '', ''],
|
||||
['NO', 'Judul', 'Link', 'Tag', 'Kategori', 'Dilihat', 'Dibuat Pada', 'Dibuat Oleh']
|
||||
['NO', 'Judul', 'Link', 'Tag', 'Kategori', 'Dilihat', 'Dibuat Pada', 'Dibuat Oleh'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -3,26 +3,31 @@
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Report;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
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, WithStyles, WithMapping
|
||||
class ReportExport implements FromCollection, WithHeadings, WithMapping, WithStyles
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
* @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)
|
||||
@ -37,19 +42,19 @@ public function __construct($media, $status, $year, $from_month, $to_month, $dat
|
||||
|
||||
public function collection()
|
||||
{
|
||||
if(is_role(['1', '5'])){
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = Report::with(['media.company', 'order.cooperation']);
|
||||
}else if(is_role(['3'])){
|
||||
} 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)) {
|
||||
if (! empty($this->media) && is_array($this->media)) {
|
||||
$query->whereIn('media_id', $this->media);
|
||||
}
|
||||
|
||||
if ($this->status) {
|
||||
switch($this->status){
|
||||
switch ($this->status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
@ -97,7 +102,7 @@ public function headings(): array
|
||||
{
|
||||
return [
|
||||
['Laporan Bukti Tayang', '', '', '', '', '', '', ''],
|
||||
['NO', 'Nama Kerja Sama', 'Media', 'Perusahaan', 'Tanggal Upload', 'Tanggal Melaporkan', 'Status']
|
||||
['NO', 'Nama Kerja Sama', 'Media', 'Perusahaan', 'Tanggal Upload', 'Tanggal Melaporkan', 'Status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -2,12 +2,10 @@
|
||||
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use App\Settings\AppSettings;
|
||||
use Carbon\Carbon;
|
||||
use Hashids\Hashids;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -129,8 +127,8 @@
|
||||
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();
|
||||
$randomFilename = Str::random(35).time().'.'.$file->getClientOriginalExtension();
|
||||
$originalFileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'.'.$file->getClientOriginalExtension();
|
||||
|
||||
$file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
@ -149,16 +147,16 @@ function store_file($file = null, $path = null, $disk = 'public')
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('display_file')) {
|
||||
if (! function_exists('display_file')) {
|
||||
function display_file($dir, $filename)
|
||||
{
|
||||
$path = storage_path("app/public/uploads/{$dir}/{$filename}");
|
||||
|
||||
if (!filled($filename)) {
|
||||
if (! filled($filename)) {
|
||||
return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
}
|
||||
|
||||
if (!file_exists($path)) {
|
||||
if (! file_exists($path)) {
|
||||
return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
}
|
||||
|
||||
@ -179,10 +177,11 @@ function display_file($dir, $filename)
|
||||
function delete_file($path)
|
||||
{
|
||||
// Menggunakan public_path untuk file yang berada di dalam storage/public
|
||||
$fullPath = public_path('storage/' . $path);
|
||||
$fullPath = public_path('storage/'.$path);
|
||||
|
||||
if (File::exists($fullPath)) {
|
||||
File::delete($fullPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -193,11 +192,11 @@ function delete_file($path)
|
||||
if (! function_exists('is_file_exists')) {
|
||||
function is_file_exists($path)
|
||||
{
|
||||
return File::exists(public_path('storage/' . $path));
|
||||
return File::exists(public_path('storage/'.$path));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_role_name')) {
|
||||
if (! function_exists('get_role_name')) {
|
||||
function get_role_name($role = null)
|
||||
{
|
||||
|
||||
@ -207,26 +206,26 @@ function get_role_name($role = null)
|
||||
|
||||
switch ($role) {
|
||||
case '1':
|
||||
return "Administrator";
|
||||
return 'Administrator';
|
||||
case '2':
|
||||
return "Admin Monitoring";
|
||||
return 'Admin Monitoring';
|
||||
case '3':
|
||||
return "Perusahaan";
|
||||
return 'Perusahaan';
|
||||
case '4':
|
||||
return "Admin Konten";
|
||||
return 'Admin Konten';
|
||||
case '5':
|
||||
return "Admin Keuangan";
|
||||
return 'Admin Keuangan';
|
||||
default:
|
||||
return "Role Tidak Dikenal";
|
||||
return 'Role Tidak Dikenal';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('shorten_text')) {
|
||||
if (! function_exists('shorten_text')) {
|
||||
function shorten_text($text, $maxLength = 100)
|
||||
{
|
||||
if (strlen($text) > $maxLength) {
|
||||
return substr($text, 0, $maxLength) . '...';
|
||||
return substr($text, 0, $maxLength).'...';
|
||||
}
|
||||
|
||||
return $text;
|
||||
@ -239,6 +238,7 @@ function is_role($roles)
|
||||
if (Auth::check()) {
|
||||
return in_array(Auth::user()->role_id, (array) $roles) || Auth::user()->role_id === '4';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -247,6 +247,7 @@ function is_role($roles)
|
||||
function encrypt_id($id)
|
||||
{
|
||||
$hashids = new Hashids('alwayssaybismillahirrahmanirrahim', 15);
|
||||
|
||||
return $hashids->encode($id);
|
||||
}
|
||||
}
|
||||
@ -256,18 +257,19 @@ function decrypt_id($hash)
|
||||
{
|
||||
$hashids = new Hashids('alwayssaybismillahirrahmanirrahim', 15);
|
||||
$result = $hashids->decode($hash);
|
||||
|
||||
return $result ? $result[0] : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('idn_date')) {
|
||||
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')) {
|
||||
if (! function_exists('get_user_status')) {
|
||||
function get_user_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
@ -278,12 +280,12 @@ function get_user_status($status)
|
||||
case '2':
|
||||
return 'Ditolak';
|
||||
default:
|
||||
return "Tidak Diketahui";
|
||||
return 'Tidak Diketahui';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_edit_status')) {
|
||||
if (! function_exists('get_edit_status')) {
|
||||
function get_edit_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
@ -296,7 +298,7 @@ function get_edit_status($status)
|
||||
case '3':
|
||||
return 'Ditolak';
|
||||
default:
|
||||
return "Tidak Diketahui";
|
||||
return 'Tidak Diketahui';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,6 +311,7 @@ function get_cooperation_notif()
|
||||
$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())
|
||||
@ -334,6 +337,7 @@ function get_unread_announcements()
|
||||
$userId = $user->id;
|
||||
|
||||
$user = User::with('announcements')->findOrFail($userId);
|
||||
|
||||
return $user->announcements()
|
||||
->wherePivot('status', '=', '0')
|
||||
->count();
|
||||
@ -365,7 +369,7 @@ function display_image($name, $dir = 'defaults', $default = 'default.jpg')
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_user_agent')) {
|
||||
if (! function_exists('get_user_agent')) {
|
||||
function get_user_agent($userAgentParam): array
|
||||
{
|
||||
$userAgent = $userAgentParam;
|
||||
@ -442,7 +446,7 @@ function titlefy($text)
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_activity_log_name')) {
|
||||
if (! function_exists('get_activity_log_name')) {
|
||||
function get_activity_log_name($name)
|
||||
{
|
||||
|
||||
@ -450,97 +454,97 @@ function get_activity_log_name($name)
|
||||
case 'airing_proof_theme':
|
||||
return [
|
||||
'name' => 'Tema Bukti Tayang',
|
||||
'route' => 'dashboard.airing.proof.themes.show'
|
||||
'route' => 'dashboard.airing.proof.themes.show',
|
||||
];
|
||||
case 'announcement':
|
||||
return [
|
||||
'name' => 'Pengumuman',
|
||||
'route' => 'dashboard.announcements.show'
|
||||
'route' => 'dashboard.announcements.show',
|
||||
];
|
||||
case 'classification':
|
||||
return [
|
||||
'name' => 'Klasifikasi',
|
||||
'route' => 'dashboard.classifications.show'
|
||||
'route' => 'dashboard.classifications.show',
|
||||
];
|
||||
case 'content_recap':
|
||||
return [
|
||||
'name' => 'Rekap Konten',
|
||||
'route' => 'dashboard.content.recaps.show'
|
||||
'route' => 'dashboard.content.recaps.show',
|
||||
];
|
||||
case 'content_recap_classification':
|
||||
return [
|
||||
'name' => 'Klasifikasi Rekap Konten',
|
||||
'route' => 'dashboard.content.recap.classifications.show'
|
||||
'route' => 'dashboard.content.recap.classifications.show',
|
||||
];
|
||||
case 'cooperation':
|
||||
return [
|
||||
'name' => 'Kerja Sama',
|
||||
'route' => 'dashboard.cooperations.show'
|
||||
'route' => 'dashboard.cooperations.show',
|
||||
];
|
||||
case 'cooperation_completion':
|
||||
return [
|
||||
'name' => 'Penyelesaian Kerja Sama',
|
||||
'route' => 'dashboard.cooperation.completions.show'
|
||||
'route' => 'dashboard.cooperation.completions.show',
|
||||
];
|
||||
case 'cooperation_proposal':
|
||||
return [
|
||||
'name' => 'Pengajuan Kerja Sama',
|
||||
'route' => 'dashboard.cooperations.media.proposal.show'
|
||||
'route' => 'dashboard.cooperations.media.proposal.show',
|
||||
];
|
||||
case 'government_agency':
|
||||
return [
|
||||
'name' => 'OPD',
|
||||
'route' => 'dashboard.government.agencies.show'
|
||||
'route' => 'dashboard.government.agencies.show',
|
||||
];
|
||||
case 'issue_management':
|
||||
return [
|
||||
'name' => 'Manajemen Isu',
|
||||
'route' => 'dashboard.issue.managements.show'
|
||||
'route' => 'dashboard.issue.managements.show',
|
||||
];
|
||||
case 'location':
|
||||
return [
|
||||
'name' => 'Location',
|
||||
'route' => 'dashboard.locations.show'
|
||||
'route' => 'dashboard.locations.show',
|
||||
];
|
||||
case 'media_monitoring':
|
||||
return [
|
||||
'name' => 'Monitoring Media',
|
||||
'route' => 'dashboard.media.monitorings.show'
|
||||
'route' => 'dashboard.media.monitorings.show',
|
||||
];
|
||||
case 'news':
|
||||
return [
|
||||
'name' => 'Berita',
|
||||
'route' => 'dashboard.news.show'
|
||||
'route' => 'dashboard.news.show',
|
||||
];
|
||||
case 'order':
|
||||
return [
|
||||
'name' => 'Media Order',
|
||||
'route' => 'dashboard.media.orders.show'
|
||||
'route' => 'dashboard.media.orders.show',
|
||||
];
|
||||
case 'airing_proof_report':
|
||||
return [
|
||||
'name' => 'Laporan Bukti Tayang',
|
||||
'route' => 'dashboard.reports.show'
|
||||
'route' => 'dashboard.reports.show',
|
||||
];
|
||||
case 'user_role':
|
||||
return [
|
||||
'name' => 'Hak Akses',
|
||||
'route' => 'dashboard.role.index'
|
||||
'route' => 'dashboard.role.index',
|
||||
];
|
||||
case 'sub_classification':
|
||||
return [
|
||||
'name' => 'Sub Klasifikasi',
|
||||
'route' => 'dashboard.sub.classifications.show'
|
||||
'route' => 'dashboard.sub.classifications.show',
|
||||
];
|
||||
case 'sub_location':
|
||||
return [
|
||||
'name' => 'Sub Lokasi',
|
||||
'route' => 'dashboard.sub.locations.show'
|
||||
'route' => 'dashboard.sub.locations.show',
|
||||
];
|
||||
default:
|
||||
return [
|
||||
'name' => 'Tidak Valid',
|
||||
'route' => null
|
||||
'route' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class AuthController extends Controller
|
||||
public function login()
|
||||
{
|
||||
return view('auth.login', [
|
||||
'title' => 'Masuk'
|
||||
'title' => 'Masuk',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ public function loginAction(LoginRequest $request)
|
||||
|
||||
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.');
|
||||
@ -37,7 +38,7 @@ public function register()
|
||||
{
|
||||
return view('auth.register', [
|
||||
'title' => 'Daftar',
|
||||
'sample' => "Hai"
|
||||
'sample' => 'Hai',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ public function registerAction(RegisterRequest $request)
|
||||
|
||||
$mediaFiles = [
|
||||
'media_journalism_organization_doc',
|
||||
'media_press_council_certificate_doc'
|
||||
'media_press_council_certificate_doc',
|
||||
];
|
||||
|
||||
$mediaFileNames = [];
|
||||
@ -130,7 +131,7 @@ public function registerAction(RegisterRequest $request)
|
||||
|
||||
$journalistFiles = [
|
||||
'journalist_press_card_doc',
|
||||
'journalist_ukw_sertificate_doc'
|
||||
'journalist_ukw_sertificate_doc',
|
||||
];
|
||||
|
||||
$journalistFileNames = [];
|
||||
@ -148,12 +149,13 @@ public function registerAction(RegisterRequest $request)
|
||||
'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' => $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();
|
||||
@ -165,7 +167,7 @@ public function registerAction(RegisterRequest $request)
|
||||
public function registerSuccess()
|
||||
{
|
||||
return view('auth.register-success', [
|
||||
'title' => 'Daftar Berhasil'
|
||||
'title' => 'Daftar Berhasil',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -9,82 +9,91 @@
|
||||
|
||||
class AiringProofThemeController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.airing-proof-themes.index', [
|
||||
'title' => "Data Tema Bukti Tayang"
|
||||
'title' => 'Data Tema Bukti Tayang',
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.airing-proof-themes.create', [
|
||||
'title' => "Buat Tema Bukti Tayang Baru"
|
||||
'title' => 'Buat Tema Bukti Tayang Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(AiringProofThemeRequest $request){
|
||||
public function store(AiringProofThemeRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
|
||||
try{
|
||||
try {
|
||||
$slug = $validatedData['slug'];
|
||||
$existing = AiringProofTheme::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
->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.');
|
||||
->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);
|
||||
} 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){
|
||||
public function edit($id)
|
||||
{
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.airing-proof-themes.edit', [
|
||||
'title' => "Ubah Tema Bukti Tayang",
|
||||
'airingProofTheme' => $airingProofTheme
|
||||
'title' => 'Ubah Tema Bukti Tayang',
|
||||
'airingProofTheme' => $airingProofTheme,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(AiringProofThemeRequest $request, $id){
|
||||
public function update(AiringProofThemeRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("Airing Proof Themes (update): ". $e);
|
||||
} 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){
|
||||
public function show($id)
|
||||
{
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.airing-proof-themes.show', [
|
||||
'title' => "Detail Tema Bukti Tayang",
|
||||
'airingProofTheme' => $airingProofTheme
|
||||
'title' => 'Detail Tema Bukti Tayang',
|
||||
'airingProofTheme' => $airingProofTheme,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->delete();
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Airing Proof Themes (destroy): ". $e);
|
||||
Log::error('Airing Proof Themes (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus tema bukti tayang.'], 500);
|
||||
}
|
||||
|
||||
@ -93,25 +102,26 @@ public function destroy($id){
|
||||
|
||||
public function restore($slug)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if (!$airingProofTheme) {
|
||||
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);
|
||||
} 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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AnnouncementRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@ -14,75 +13,81 @@
|
||||
|
||||
class AnnouncementController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Pengumuman',
|
||||
'category' => $request->input('category', 'general')
|
||||
'category' => $request->input('category', 'general'),
|
||||
];
|
||||
|
||||
if(is_role(['1'])){
|
||||
if (is_role(['1'])) {
|
||||
return view('dashboard.announcements.index', $data);
|
||||
}else if(is_role(['3'])){
|
||||
} elseif (is_role(['3'])) {
|
||||
return view('dashboard.announcements.media.index', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.announcements.create', [
|
||||
'title' => 'Buat Pengumuman Baru',
|
||||
'users' => User::all()
|
||||
'users' => User::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(AnnouncementRequest $request){
|
||||
public function store(AnnouncementRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
if($request->hasFile('attachment')){
|
||||
try {
|
||||
if ($request->hasFile('attachment')) {
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements')['randomFileName'];
|
||||
}
|
||||
|
||||
$announcement = DB::transaction(function() use ($validatedData){
|
||||
$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.");
|
||||
if ($announcement->users()->count() < 1) {
|
||||
throw new \Exception('Data tidak valid.');
|
||||
}
|
||||
|
||||
return $announcement;
|
||||
});
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("Announcements (store): ". $e);
|
||||
} 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){
|
||||
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()
|
||||
'selectedUsersIds' => $announcement->users->pluck('id')->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(AnnouncementRequest $request, $id){
|
||||
public function update(AnnouncementRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
DB::transaction(function () use($request, $validatedData, $announcement){
|
||||
if($request->hasFile('attachment')){
|
||||
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{
|
||||
} else {
|
||||
$validatedData['attachment'] = $announcement->attachment;
|
||||
}
|
||||
|
||||
@ -96,16 +101,18 @@ public function update(AnnouncementRequest $request, $id){
|
||||
$announcement->users()->sync($mediaData);
|
||||
}
|
||||
});
|
||||
}catch(\Exception $e){
|
||||
Log::error("Announcements (update): ". $e);
|
||||
} 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) {
|
||||
public function show($id)
|
||||
{
|
||||
$announcement = Announcement::with(['users' => function ($query) {
|
||||
$query->withPivot('category');
|
||||
}])->findOrFail(decrypt_id($id));
|
||||
|
||||
@ -115,33 +122,37 @@ public function show($id){
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
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);
|
||||
Log::error('Announcements (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus pengumuman.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus pengumuman.']);
|
||||
}
|
||||
|
||||
public function read($id){
|
||||
public function read($id)
|
||||
{
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if(!in_array(Auth::id(), $announcement->users->pluck('id')->toArray())){
|
||||
if (! in_array(Auth::id(), $announcement->users->pluck('id')->toArray())) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
try{
|
||||
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.');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Announcements (read): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal membaca pengumuman.');
|
||||
}
|
||||
|
||||
return view('dashboard.announcements.read', [
|
||||
|
||||
@ -5,15 +5,13 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClassificationRequest;
|
||||
use App\Models\Classification;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ClassificationController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.classifications.index', [
|
||||
'title' => 'Data Klasifikasi',
|
||||
'filter' => $request->input('filter', null),
|
||||
@ -21,55 +19,62 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.classifications.create', [
|
||||
'title' => 'Buat Klasifikasi Baru'
|
||||
'title' => 'Buat Klasifikasi Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ClassificationRequest $request){
|
||||
public function store(ClassificationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$createdClassification = Classification::create($validatedData);
|
||||
}catch (\Exception $e){
|
||||
Log::error("Classifications (store): ". $e);
|
||||
} 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));
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
public function edit($id)
|
||||
{
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.classifications.edit', [
|
||||
'title' => 'Ubah Klasifikasi',
|
||||
'classification' => $classification
|
||||
'classification' => $classification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ClassificationRequest $request, $id){
|
||||
public function update(ClassificationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
$classification->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("Classifications (update): ". $e);
|
||||
} 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){
|
||||
public function show($id)
|
||||
{
|
||||
$classification = Classification::withTrashed()->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.classifications.show', [
|
||||
'title' => 'Detail Klasifikasi',
|
||||
'classification' => $classification
|
||||
'classification' => $classification,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -79,7 +84,8 @@ public function destroy($id)
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
$classification->delete();
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Classifications (destroy): ". $e);
|
||||
Log::error('Classifications (destroy): '.$e);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Gagal menghapus klasifikasi.',
|
||||
@ -98,7 +104,7 @@ public function restore($id)
|
||||
try {
|
||||
$classification = Classification::withTrashed()->findOrFail(decrypt_id($id));
|
||||
|
||||
if (!$classification->trashed()) {
|
||||
if (! $classification->trashed()) {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Klasifikasi belum dihapus.',
|
||||
@ -107,7 +113,8 @@ public function restore($id)
|
||||
|
||||
$classification->restore();
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Classifications (restore): ". $e);
|
||||
Log::error('Classifications (restore): '.$e);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Gagal mengembalikan klasifikasi.',
|
||||
@ -119,6 +126,4 @@ public function restore($id)
|
||||
'message' => 'Klasifikasi berhasil dikembalikan.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -21,9 +21,10 @@
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
if(is_role(['1', '5'])){
|
||||
return view('dashboard.companies.admin.index',[
|
||||
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),
|
||||
@ -32,7 +33,7 @@ public function index(Request $request){
|
||||
'register_month' => $request->input('register_month', null),
|
||||
'register_date' => $request->input('register_date', null),
|
||||
]);
|
||||
}else if(is_role(['3'])){
|
||||
} elseif (is_role(['3'])) {
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
$data = [
|
||||
@ -44,20 +45,22 @@ public function index(Request $request){
|
||||
}
|
||||
}
|
||||
|
||||
public function editRequest(){
|
||||
if(!in_array(Auth::user()->company->edit_status, ['0', '2', '3'])){
|
||||
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'
|
||||
'title' => 'Permohonan Ubah Data Perusahaan',
|
||||
]);
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request){
|
||||
public function editRequestAction(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
if(!in_array(Auth::user()->company->edit_status, ['0', '2', '3'])){
|
||||
try {
|
||||
if (! in_array(Auth::user()->company->edit_status, ['0', '2', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -70,19 +73,21 @@ public function editRequestAction(Request $request){
|
||||
$user = User::with(['company'])->findOrFail(Auth::id());
|
||||
$user->company->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description']
|
||||
'edit_description' => $validatedData['edit_description'],
|
||||
]);
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (editRequestAction): ". $e);
|
||||
} 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'){
|
||||
public function edit()
|
||||
{
|
||||
if (Auth::user()->company->edit_status !== '2') {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -90,16 +95,17 @@ public function edit(){
|
||||
|
||||
return view('dashboard.companies.edit', [
|
||||
'title' => 'Ubah Data Perusahaan',
|
||||
'user' => $user
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(CompanyRequest $request){
|
||||
public function update(CompanyRequest $request)
|
||||
{
|
||||
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
if(Auth::user()->company->edit_status !== '2'){
|
||||
try {
|
||||
if (Auth::user()->company->edit_status !== '2') {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -126,7 +132,7 @@ public function update(CompanyRequest $request){
|
||||
}
|
||||
}
|
||||
|
||||
DB::transaction(function()use($company, $validatedData, $companyFileNames){
|
||||
DB::transaction(function () use ($company, $validatedData, $companyFileNames) {
|
||||
$company->update([
|
||||
'name' => $validatedData['company_name'],
|
||||
'email' => $validatedData['company_email'],
|
||||
@ -154,15 +160,17 @@ public function update(CompanyRequest $request){
|
||||
]);
|
||||
});
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (update): ". $e);
|
||||
} 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){
|
||||
public function show($id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
@ -173,15 +181,16 @@ public function show($id, $type){
|
||||
'purpose' => 'show',
|
||||
'idnPage' => 'perusahaan',
|
||||
'route' => 'companies',
|
||||
'type' => $type
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch($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':
|
||||
@ -199,11 +208,12 @@ public function show($id, $type){
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
|
||||
return response()->json([
|
||||
'status' => 'warning',
|
||||
'message' => 'Aksi belum tersedia.'
|
||||
'message' => 'Aksi belum tersedia.',
|
||||
]);
|
||||
|
||||
// try{
|
||||
@ -217,10 +227,11 @@ public function destroy($id){
|
||||
// }
|
||||
}
|
||||
|
||||
public function process(Request $request, $id, $type){
|
||||
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'])){
|
||||
if ($request->query('category') && ! in_array($request->query('category'), ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -233,7 +244,7 @@ public function process(Request $request, $id, $type){
|
||||
'idnPage' => 'perusahaan',
|
||||
'route' => 'companies',
|
||||
'type' => $type,
|
||||
'category' => $request->query('category', null)
|
||||
'category' => $request->query('category', null),
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
@ -244,6 +255,7 @@ public function process(Request $request, $id, $type){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
@ -260,46 +272,49 @@ public function process(Request $request, $id, $type){
|
||||
}
|
||||
}
|
||||
|
||||
public function processAcceptAction(Request $request, $id, $type, $category){
|
||||
public function processAcceptAction(Request $request, $id, $type, $category)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$user = User::with(['company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if(!in_array($category, ['account-status', 'edit-request'])){
|
||||
if (! in_array($category, ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if(is_role(['1']) && in_array($category, ['account-status', 'edit-request'])){
|
||||
if($category === 'account-status' && $user->status === '0'){
|
||||
if (is_role(['1']) && in_array($category, ['account-status', 'edit-request'])) {
|
||||
if ($category === 'account-status' && $user->status === '0') {
|
||||
$user->update([
|
||||
'status' => '1'
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'accepted'));
|
||||
}else if($category === 'edit-request' && $user->company->edit_status === '1'){
|
||||
} elseif ($category === 'edit-request' && $user->company->edit_status === '1') {
|
||||
$user->company->update([
|
||||
'edit_status' => '2'
|
||||
'edit_status' => '2',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (processAcceptAction): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (processAcceptAction): '.$e);
|
||||
|
||||
return response()->json([
|
||||
'failed-status' => 'Gagal menyetujui'.($category === 'edit-request' ? ' permohonan edit' : '').' perusahaan.'
|
||||
'failed-status' => 'Gagal menyetujui'.($category === 'edit-request' ? ' permohonan edit' : '').' perusahaan.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function processRejectAction(Request $request, $id, $type, $category){
|
||||
public function processRejectAction(Request $request, $id, $type, $category)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$user = User::with(['company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if(!in_array($category, ['account-status', 'edit-request'])){
|
||||
if (! in_array($category, ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if(is_role(['1']) && in_array($category, ['account-status', 'edit-request'])){
|
||||
if (is_role(['1']) && in_array($category, ['account-status', 'edit-request'])) {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
@ -307,25 +322,26 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
if($category === 'account-status' && $user->status === '0'){
|
||||
if ($category === 'account-status' && $user->status === '0') {
|
||||
$user->update([
|
||||
'status' => '2'
|
||||
'status' => '2',
|
||||
]);
|
||||
|
||||
$user->company->update([
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'rejected', $validatedData['rejection_reason']));
|
||||
}else if($category === 'edit-request' && $user->company->edit_status === '1'){
|
||||
} elseif ($category === 'edit-request' && $user->company->edit_status === '1') {
|
||||
$user->company->update([
|
||||
'edit_status' => '3',
|
||||
'edit_rejection_reason' => $validatedData['rejection_reason']
|
||||
'edit_rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (processRejectAction): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (processRejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('faileds-status', 'Gagal melakukan proses.');
|
||||
}
|
||||
|
||||
@ -335,7 +351,7 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
@ -346,38 +362,44 @@ public function export(Request $request)
|
||||
$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.');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (export): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
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.');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (filter): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filter data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try{
|
||||
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);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Company (printData): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,38 +3,41 @@
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ReceiveMessageContactRequest;
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.contacts.index', [
|
||||
'title' => 'Pesan Kontak',
|
||||
'status' => $request->input('status', null)
|
||||
'status' => $request->input('status', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.contacts.show', [
|
||||
'title' => 'Detail Pesan',
|
||||
'contact' => $contact
|
||||
'contact' => $contact,
|
||||
]);
|
||||
}
|
||||
|
||||
public function reply($id){
|
||||
public function reply($id)
|
||||
{
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.contacts.reply', [
|
||||
'title' => 'Balas Pesan',
|
||||
'contact' => $contact
|
||||
'contact' => $contact,
|
||||
]);
|
||||
}
|
||||
|
||||
public function replyAction(Request $request, $id){
|
||||
public function replyAction(Request $request, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'reply_message' => ['required'],
|
||||
], [
|
||||
@ -45,13 +48,14 @@ public function replyAction(Request $request, $id){
|
||||
|
||||
$contact->update([
|
||||
'reply_message' => $validatedData['reply_message'],
|
||||
'status' => '1'
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
return redirect()->route('dashboard.contact.messages.show', ['id' => encrypt_id($contact->id)])->with('success-status', 'Berhasil membalas pesan.');
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$contact = Contact::findOrFail(decrypt_id($id));
|
||||
$contact->delete();
|
||||
|
||||
@ -4,88 +4,95 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ContentRecapClassificationRequest;
|
||||
use App\Models\ContentRecap;
|
||||
use App\Models\ContentRecapClassification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ContentRecapClassificationController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.content-recaps.classifications.index', [
|
||||
'title' => "Klasifikasi Rekap Konten"
|
||||
'title' => 'Klasifikasi Rekap Konten',
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.content-recaps.classifications.create', [
|
||||
'title' => "Buat Klasifikasi Rekap Konten Baru"
|
||||
'title' => 'Buat Klasifikasi Rekap Konten Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ContentRecapClassificationRequest $request){
|
||||
public function store(ContentRecapClassificationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$existedData = ContentRecapClassification::withTrashed()->where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if($existedData && filled($existedData->deleted_at)){
|
||||
if ($existedData && filled($existedData->deleted_at)) {
|
||||
return redirect()->back()->with('data-exists', $validatedData['slug']);
|
||||
}elseif($existedData){
|
||||
} 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);
|
||||
} 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));
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}
|
||||
|
||||
public function edit($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
|
||||
'title' => 'Ubah Klasifikasi Rekap Konten',
|
||||
'contentRecapClassification' => $contentRecapClassification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ContentRecapClassificationRequest $request, $id){
|
||||
public function update(ContentRecapClassificationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
$contentRecapClassification->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecapClassifications (update): ". $e);
|
||||
} 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){
|
||||
public function show($id)
|
||||
{
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.content-recaps.classifications.show', [
|
||||
'title' => "Detail Klasifikasi Rekap Konten",
|
||||
'contentRecapClassification' => $contentRecapClassification
|
||||
'title' => 'Detail Klasifikasi Rekap Konten',
|
||||
'contentRecapClassification' => $contentRecapClassification,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
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);
|
||||
Log::error('ContentRecapClassifications (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus klasifikasi rekap konten.'], 500);
|
||||
}
|
||||
}
|
||||
@ -93,23 +100,25 @@ public function destroy($id){
|
||||
public function restore($slug)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$recapContentClassification = ContentRecapClassification::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if (!$recapContentClassification) {
|
||||
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);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecapClassifications (restore): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses pemulihan.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
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 ContentRecapController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.content-recaps.index', [
|
||||
'title' => 'Rekap Konten',
|
||||
'classifications' => ContentRecapClassification::all(),
|
||||
@ -30,26 +30,29 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.content-recaps.create', [
|
||||
'title' => 'Tambah Rekap Konten',
|
||||
'classifications' => ContentRecapClassification::all()
|
||||
'classifications' => ContentRecapClassification::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ContentRecapRequest $request){
|
||||
public function store(ContentRecapRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$createdContentRecap = ContentRecap::create($validatedData);
|
||||
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
if ($request->has('image') && filled($validatedData['image'])) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (store): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (store): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan rekap konten.');
|
||||
}
|
||||
|
||||
@ -57,31 +60,34 @@ public function store(ContentRecapRequest $request){
|
||||
->with('new_data', encrypt_id($createdContentRecap->id));
|
||||
}
|
||||
|
||||
public function edit($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()
|
||||
'classifications' => ContentRecapClassification::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ContentRecapRequest $request, $id){
|
||||
public function update(ContentRecapRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
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{
|
||||
} else {
|
||||
$validatedData['image'] = $contentRecap->image;
|
||||
}
|
||||
|
||||
$contentRecap->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (update): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah rekap konten.');
|
||||
}
|
||||
|
||||
@ -89,22 +95,25 @@ public function update(ContentRecapRequest $request, $id){
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.content-recaps.show', [
|
||||
'title' => 'Detail Rekap Konten',
|
||||
'contentRecap' => $contentRecap
|
||||
'contentRecap' => $contentRecap,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
$contentRecap->delete();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("ContentRecaps (destroy): ". $e);
|
||||
Log::error('ContentRecaps (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus rekap konten.'], 500);
|
||||
}
|
||||
|
||||
@ -116,20 +125,22 @@ public function checkLink(Request $request)
|
||||
$linkExists = ContentRecap::where('link', $request->link)->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (filter): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (filter): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filter data.');
|
||||
}
|
||||
|
||||
@ -139,7 +150,7 @@ public function filter(Request $request){
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
$classification = $request->input('classification', 'all');
|
||||
$channel = $request->input('channel', 'all');
|
||||
$social_media = $request->input('social_media', 'all');
|
||||
@ -151,22 +162,25 @@ public function export(Request $request)
|
||||
$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);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('ContentRecaps (export): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try{
|
||||
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 $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.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
class CooperationArchiveController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.cooperation-archives.index', [
|
||||
'title' => 'Arsip Kerja Sama',
|
||||
'date' => $request->input('date', null),
|
||||
@ -21,21 +22,22 @@ public function index(Request $request){
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
@ -43,10 +45,9 @@ public function filter(Request $request){
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.cooperation.archives.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CooperationCompletionRequest;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Cooperation;
|
||||
use App\Models\CooperationCompletion;
|
||||
use App\Models\Media;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
@ -19,7 +18,8 @@
|
||||
class CooperationCompletionController extends Controller
|
||||
{
|
||||
// Main page: Penyelesaian Kerja Sama
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.cooperation-completions.index', [
|
||||
'title' => 'Penyelesaian Kerja Sama',
|
||||
'mediaCollection' => Media::all(),
|
||||
@ -32,10 +32,11 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(CooperationCompletionRequest $request, $id){
|
||||
public function store(CooperationCompletionRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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'];
|
||||
@ -44,75 +45,80 @@ public function store(CooperationCompletionRequest $request, $id){
|
||||
|
||||
$validatedData['electronic_tax_invoice'] = store_file($validatedData['electronic_tax_invoice'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
if(isset($validatedData['other_document'])){
|
||||
if (isset($validatedData['other_document'])) {
|
||||
$validatedData['other_document'] = store_file($validatedData['other_document'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['other_document'] = null;
|
||||
} 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);
|
||||
} 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){
|
||||
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
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function showIndex($id){
|
||||
public function showIndex($id)
|
||||
{
|
||||
$cooperationCompletion = CooperationCompletion::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-completions.index.show', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'cooperationCompletion' => $cooperationCompletion
|
||||
'cooperationCompletion' => $cooperationCompletion,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processIndex($id){
|
||||
public function processIndex($id)
|
||||
{
|
||||
$cooperationCompletion = CooperationCompletion::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-completions.index.process', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'cooperationCompletion' => $cooperationCompletion
|
||||
'cooperationCompletion' => $cooperationCompletion,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accept($id){
|
||||
public function accept($id)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$completion->update([
|
||||
'status' => '1'
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerja sama <u>'. $completion->order->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'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()
|
||||
'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);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (accept): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui penyelesaian kerja sama');
|
||||
}
|
||||
|
||||
@ -120,19 +126,21 @@ public function accept($id){
|
||||
|
||||
}
|
||||
|
||||
public function reject($mediaOrderId, $id){
|
||||
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
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
@ -143,21 +151,22 @@ public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
|
||||
$completion->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'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>',
|
||||
'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()
|
||||
'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);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (rejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak penyelesaian kerja sama');
|
||||
}
|
||||
|
||||
@ -165,9 +174,10 @@ public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
|
||||
}
|
||||
|
||||
public function rejectActionIndex(Request $request, $id){
|
||||
public function rejectActionIndex(Request $request, $id)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
@ -178,21 +188,22 @@ public function rejectActionIndex(Request $request, $id){
|
||||
|
||||
$completion->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'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>',
|
||||
'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()
|
||||
'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);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationCompletions (rejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak penyelesaian kerja sama');
|
||||
}
|
||||
|
||||
@ -202,7 +213,7 @@ public function rejectActionIndex(Request $request, $id){
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
$export_type = $request->input('export_type', 'excel');
|
||||
|
||||
$status = $request->input('status', null);
|
||||
@ -212,23 +223,24 @@ public function export(Request $request)
|
||||
$to_month = $request->input('to_month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
if($export_type === 'excel'){
|
||||
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'])){
|
||||
} elseif ($export_type === 'pdf') {
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = CooperationCompletion::with(['media.company']);
|
||||
}else if(is_role(['3'])){
|
||||
} 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)) {
|
||||
if (! empty($media) && is_array($media)) {
|
||||
$query->whereIn('media_id', $media);
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
switch($status){
|
||||
switch ($status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
@ -263,22 +275,22 @@ public function export(Request $request)
|
||||
return $pdf->stream(slugify('laporan bukti tayang ').'.pdf');
|
||||
}
|
||||
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function singlePrint(){
|
||||
try{
|
||||
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 $pdf->stream(slugify('Penyelesaian kerja sama '.$cooperationCompletion->media->name).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,13 +14,15 @@
|
||||
|
||||
class CooperationRequestController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.cooperation-requests.index', [
|
||||
'title' => 'Ajuan Kerja Sama'
|
||||
'title' => 'Ajuan Kerja Sama',
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperationPivot = $cooperation->media()
|
||||
@ -30,29 +32,32 @@ public function show($id){
|
||||
return view('dashboard.cooperation-requests.show', [
|
||||
'title' => 'Tolak Kerja Sama',
|
||||
'cooperation' => $cooperation,
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposal(){
|
||||
return view('dashboard.cooperation-requests.media-proposals.index',[
|
||||
'title' => 'Ajuan Kerja Sama Saya'
|
||||
public function mediaProposal()
|
||||
{
|
||||
return view('dashboard.cooperation-requests.media-proposals.index', [
|
||||
'title' => 'Ajuan Kerja Sama Saya',
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalShow($id){
|
||||
public function mediaProposalShow($id)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-requests.media-proposals.show',[
|
||||
return view('dashboard.cooperation-requests.media-proposals.show', [
|
||||
'title' => 'Detail Ajuan Kerja Sama',
|
||||
'proposal' => $proposal
|
||||
'proposal' => $proposal,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accept(Request $request, $id){
|
||||
public function accept(Request $request, $id)
|
||||
{
|
||||
|
||||
try{
|
||||
if(!Auth::check() || Auth::user()->role_id !== 3){
|
||||
try {
|
||||
if (! Auth::check() || Auth::user()->role_id !== 3) {
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
@ -62,7 +67,7 @@ public function accept(Request $request, $id){
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaCooperation) {
|
||||
if (! $mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
@ -74,9 +79,9 @@ public function accept(Request $request, $id){
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerja Sama <u>'.$cooperation->name.'</u> <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name. '</u>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
@ -95,14 +100,16 @@ public function accept(Request $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja Sama sudah diterima sebelumnya.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationRequest (accept): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (accept): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createProposal($id){
|
||||
public function createProposal($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperationPivot = $cooperation->media()
|
||||
@ -113,14 +120,15 @@ public function createProposal($id){
|
||||
'title' => 'Ajukan Kerja Sama',
|
||||
'user' => Auth::user(),
|
||||
'cooperation' => $cooperation,
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot,
|
||||
]);
|
||||
}
|
||||
|
||||
public function storeProposal(JournalistCooperationProposalRequest $request, $id){
|
||||
public function storeProposal(JournalistCooperationProposalRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
@ -131,9 +139,9 @@ public function storeProposal(JournalistCooperationProposalRequest $request, $id
|
||||
|
||||
// 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()
|
||||
'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) {
|
||||
@ -148,15 +156,17 @@ public function storeProposal(JournalistCooperationProposalRequest $request, $id
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::info("ERROR Cooperation Proposals: ". $e);
|
||||
} 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){
|
||||
public function reject($id)
|
||||
{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperationPivot = $cooperation->media()
|
||||
@ -166,14 +176,15 @@ public function reject($id){
|
||||
return view('dashboard.cooperation-requests.reject', [
|
||||
'title' => 'Tolak Kerja Sama',
|
||||
'cooperation' => $cooperation,
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot
|
||||
'mediaCooperationPivot' => $mediaCooperationPivot,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejectAction(Request $request, $id){
|
||||
public function rejectAction(Request $request, $id)
|
||||
{
|
||||
|
||||
try{
|
||||
if(!Auth::check() || Auth::user()->role_id !== 3){
|
||||
try {
|
||||
if (! Auth::check() || Auth::user()->role_id !== 3) {
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
@ -189,11 +200,10 @@ public function rejectAction(Request $request, $id){
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaCooperation) {
|
||||
if (! $mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
|
||||
if ($mediaCooperation->pivot->status != '3') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '2',
|
||||
@ -202,11 +212,11 @@ public function rejectAction(Request $request, $id){
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerja Sama <u>'.$cooperation->name.'</u> <span class="text-danger fw-bold">ditolak</span> oleh media <u>'.$mediaCooperation->name. '</u>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
@ -225,41 +235,44 @@ public function rejectAction(Request $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja sama sudah ditolak sebelumnya.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationRequest (rejectAction): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (rejectAction): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editProposal($id){
|
||||
public function editProposal($id)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.cooperation-requests.media-proposals.edit',[
|
||||
return view('dashboard.cooperation-requests.media-proposals.edit', [
|
||||
'title' => 'Ubah Ajuan Kerja Sama',
|
||||
'proposal' => $proposal,
|
||||
'selectedJournalists' => $proposal->journalists->pluck('id')->toArray()
|
||||
'selectedJournalists' => $proposal->journalists->pluck('id')->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateProposal(JournalistCooperationProposalRequest $request, $id){
|
||||
public function updateProposal(JournalistCooperationProposalRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
|
||||
try{
|
||||
try {
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $proposal->cooperation_id;
|
||||
|
||||
if($request->hasFile('attachment')){
|
||||
if ($request->hasFile('attachment')) {
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
delete_file('app/public/uploads/cooperation-proposals/'.$proposal->image);
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['attachment'] = $proposal->attachment;
|
||||
}
|
||||
|
||||
$proposal->update($validatedData);
|
||||
|
||||
if($request->has('journalist_ids')){
|
||||
if ($request->has('journalist_ids')) {
|
||||
$proposal->journalists()->sync($validatedData['journalist_ids']);
|
||||
}
|
||||
|
||||
@ -268,23 +281,25 @@ public function updateProposal(JournalistCooperationProposalRequest $request, $i
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengajuan kerja sama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationRequest (updateProposal): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('CooperationRequest (updateProposal): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengajuan kerja sama');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function destroyProposal($id){
|
||||
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);
|
||||
Log::error('CooperationRequest (destroyProposal): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus ajuan kerja sama.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,57 +5,61 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\GovernmentAgencyRequest;
|
||||
use App\Models\GovernmentAgency;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class GovernmentAgencyController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.government-agencies.index', [
|
||||
'title' => 'Data OPD',
|
||||
'new_data' => session()->get('new_data', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.government-agencies.create', [
|
||||
'title' => 'Buat OPD Baru'
|
||||
'title' => 'Buat OPD Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(GovernmentAgencyRequest $request){
|
||||
public function store(GovernmentAgencyRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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);
|
||||
->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){
|
||||
public function edit($id)
|
||||
{
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.government-agencies.edit',[
|
||||
return view('dashboard.government-agencies.edit', [
|
||||
'title' => 'Ubah OPD',
|
||||
'governmentAgency' => $governmentAgency
|
||||
'governmentAgency' => $governmentAgency,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(GovernmentAgencyRequest $request, $id){
|
||||
public function update(GovernmentAgencyRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
$governmentAgency->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("GovernmentAgencies (update): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('GovernmentAgencies (update): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah OPD');
|
||||
}
|
||||
|
||||
@ -63,16 +67,18 @@ public function update(GovernmentAgencyRequest $request, $id){
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$governmentAgency = GovernmentAgency::find(decrypt_id($id));
|
||||
|
||||
return view('dashboard.government-agencies.show',[
|
||||
return view('dashboard.government-agencies.show', [
|
||||
'title' => 'Detail OPD',
|
||||
'governmentAgency' => $governmentAgency
|
||||
'governmentAgency' => $governmentAgency,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
|
||||
@ -80,7 +86,8 @@ public function destroy($id){
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus OPD']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("GovernmentAgencies (destroy): ". $e);
|
||||
Log::error('GovernmentAgencies (destroy): '.$e);
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus OPD.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,14 +16,15 @@
|
||||
|
||||
class JournalistController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
if(is_role(['1', '5'])){
|
||||
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){
|
||||
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',[
|
||||
return view('dashboard.journalists.admin.index', [
|
||||
'title' => 'Data Jurnalis',
|
||||
'media' => Media::all(),
|
||||
'media_ids' => $request->input('media_ids', null),
|
||||
@ -33,46 +34,51 @@ public function index(Request $request){
|
||||
'register_month' => $request->input('register_month', null),
|
||||
'register_date' => $request->input('register_date', null),
|
||||
]);
|
||||
}else if(is_role(['3'])){
|
||||
} elseif (is_role(['3'])) {
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
return view('dashboard.journalists.index',[
|
||||
|
||||
return view('dashboard.journalists.index', [
|
||||
'title' => 'Data Jurnalis',
|
||||
'user' => $user,
|
||||
'journalists' => $user->company->media->journalists
|
||||
->where('approved_status', '1')
|
||||
->whereNull('deleted_at'),
|
||||
->where('approved_status', '1')
|
||||
->whereNull('deleted_at'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submission(){
|
||||
return view('dashboard.journalists.submission',[
|
||||
'title' => 'Data Permohonan Penambahan Jurnalis'
|
||||
public function submission()
|
||||
{
|
||||
return view('dashboard.journalists.submission', [
|
||||
'title' => 'Data Permohonan Penambahan Jurnalis',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processSubmission($id){
|
||||
public function processSubmission($id)
|
||||
{
|
||||
$journalist = Journalist::with(['media.company'])->findOrFail(decrypt_id($id));
|
||||
return view('dashboard.journalists.process-submission',[
|
||||
|
||||
return view('dashboard.journalists.process-submission', [
|
||||
'title' => 'Data Permohonan Penambahan Jurnalis',
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processSubmissionAction(Request $request, $id, $action){
|
||||
public function processSubmissionAction(Request $request, $id, $action)
|
||||
{
|
||||
$journalist = Journalist::with(['media.company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if($action === 'accept'){
|
||||
if ($action === 'accept') {
|
||||
$acceptedJournalist = $journalist->update([
|
||||
'approved_status' => '1',
|
||||
'approved_at' => now(),
|
||||
]);
|
||||
|
||||
if($acceptedJournalist){
|
||||
if ($acceptedJournalist) {
|
||||
return response()->json(['message' => 'Berhasil menyetujui jurnalis.']);
|
||||
}
|
||||
|
||||
}else if($action === 'reject'){
|
||||
} elseif ($action === 'reject') {
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
@ -81,21 +87,22 @@ public function processSubmissionAction(Request $request, $id, $action){
|
||||
|
||||
$rejectedJournalist = $journalist->update([
|
||||
'approved_status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'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 create()
|
||||
{
|
||||
return view('dashboard.journalists.create', [
|
||||
'title' => 'Tambah Data Jurnalis',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(JournalistRequest $request){
|
||||
public function store(JournalistRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$fileFieldMap = [
|
||||
@ -108,7 +115,7 @@ public function store(JournalistRequest $request){
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$journalistFileNames[$requestKey] = null;
|
||||
}
|
||||
}
|
||||
@ -119,37 +126,39 @@ public function store(JournalistRequest $request){
|
||||
'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' => $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
|
||||
'media_id' => Auth::user()->company->media->id,
|
||||
]);
|
||||
|
||||
if($createdJournalist){
|
||||
if ($createdJournalist) {
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil menambahkan jurnalis.')->with('created-journalist', true);
|
||||
}else{
|
||||
} else {
|
||||
return redirect()->route('dashboard.journalists.index')->with('failed-status', 'Gagal menambahkan jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function editRequest($id){
|
||||
public function editRequest($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if(!in_array($journalist->edit_status, ['0', '3'])){
|
||||
if (! in_array($journalist->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('dashboard.journalists.edit-request', [
|
||||
'title' => 'Permohonan Ubah Data Jurnalis',
|
||||
'journalist' => $journalist
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request, $id){
|
||||
public function editRequestAction(Request $request, $id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if(!in_array($journalist->edit_status, ['0', '3'])){
|
||||
if (! in_array($journalist->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -159,52 +168,54 @@ public function editRequestAction(Request $request, $id){
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
if(!Auth::check()){
|
||||
if (! Auth::check()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$updatedJournalist = $journalist->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description']
|
||||
'edit_description' => $validatedData['edit_description'],
|
||||
]);
|
||||
|
||||
if($updatedJournalist){
|
||||
if ($updatedJournalist) {
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil melakukan permohonan edit data jurnalis.');
|
||||
}else{
|
||||
} else {
|
||||
return redirect()->route('dashboard.journalists.index')->with('failed-status', 'Gagal melakukan permohonan edit data jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function processEdit($id){
|
||||
public function processEdit($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if(!in_array($journalist->edit_status, ['1', '2']) || !is_role(['1'])){
|
||||
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'
|
||||
'purpose' => 'processEdit',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processEditAction(Request $request, $id, $action){
|
||||
public function processEditAction(Request $request, $id, $action)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if(!in_array($journalist->edit_status, ['1']) || !is_role(['1'])){
|
||||
if (! in_array($journalist->edit_status, ['1']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if(is_role(['1'])){
|
||||
if (is_role(['1'])) {
|
||||
|
||||
if($action === 'accept'){
|
||||
if ($action === 'accept') {
|
||||
$acceptedJournalist = $journalist->update([
|
||||
'edit_status' => '2',
|
||||
]);
|
||||
|
||||
if($acceptedJournalist){
|
||||
if ($acceptedJournalist) {
|
||||
return response()->json(['message' => 'Berhasil menyetujui permohonan edit jurnalis.']);
|
||||
}
|
||||
}else if($action === 'reject'){
|
||||
} elseif ($action === 'reject') {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'edit_rejection_reason' => ['required'],
|
||||
@ -214,7 +225,7 @@ public function processEditAction(Request $request, $id, $action){
|
||||
|
||||
$journalist->update([
|
||||
'edit_status' => '3',
|
||||
'edit_rejection_reason' => $validatedData['edit_rejection_reason']
|
||||
'edit_rejection_reason' => $validatedData['edit_rejection_reason'],
|
||||
]);
|
||||
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil menolak permohonan edit jurnalis.');
|
||||
@ -222,20 +233,22 @@ public function processEditAction(Request $request, $id, $action){
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
public function edit($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.journalists.edit', [
|
||||
'title' => 'Ubah Data Jurnalis',
|
||||
'journalist' => $journalist
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(JournalistRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
public function update(JournalistRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
if(!in_array($journalist->edit_status, ['2'])){
|
||||
if (! in_array($journalist->edit_status, ['2'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -249,7 +262,7 @@ public function update(JournalistRequest $request, $id){
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$journalistFileNames[$requestKey] = $journalist->{$dbField};
|
||||
}
|
||||
}
|
||||
@ -260,32 +273,34 @@ public function update(JournalistRequest $request, $id){
|
||||
'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' => $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
|
||||
'media_id' => Auth::user()->company->media->id,
|
||||
]);
|
||||
|
||||
if($createdJournalist){
|
||||
if ($createdJournalist) {
|
||||
return redirect()->route('dashboard.journalists.index')->with('success-status', 'Berhasil mengubah jurnalis.');
|
||||
}else{
|
||||
} else {
|
||||
return redirect()->route('dashboard.journalists.index')->with('failed-status', 'Gagal mengubah jurnalis.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.journalists.show', [
|
||||
'title' => 'Detail Jurnalis',
|
||||
'journalist' => $journalist
|
||||
'journalist' => $journalist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$journalist = Journalist::findOrFail(decrypt_id($id));
|
||||
|
||||
@ -296,7 +311,7 @@ public function destroy($id){
|
||||
if ($journalists->count() <= 1) {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Media harus punya minimal satu jurnalis.'
|
||||
'message' => 'Media harus punya minimal satu jurnalis.',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -335,19 +350,18 @@ public function filter(Request $request)
|
||||
}
|
||||
|
||||
// Filter semua field yang terisi
|
||||
$filterField = array_filter($filteredRequest, fn($val) => filled($val));
|
||||
$filterField = array_filter($filteredRequest, fn ($val) => filled($val));
|
||||
|
||||
return redirect()->route('dashboard.journalists.index', $filterField);
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,70 +5,74 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\LocationRequest;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LocationController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.locations.index', [
|
||||
'title' => 'Data Lokus',
|
||||
'new_data' => session()->get('new_data', null),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.locations.create', [
|
||||
'title' => 'Buat Lokus Baru'
|
||||
'title' => 'Buat Lokus Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(LocationRequest $request){
|
||||
public function store(LocationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
->with('new_data', encrypt_id($createdLocation->id));
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
public function edit($id)
|
||||
{
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.locations.edit', [
|
||||
'title' => 'Ubah Lokus',
|
||||
'location' => $location
|
||||
'location' => $location,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(LocationRequest $request, $id){
|
||||
public function update(LocationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.locations.show', [
|
||||
'title' => 'Detail Lokus',
|
||||
'location' => $location
|
||||
'location' => $location,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
$location->delete();
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
|
||||
class LogActivityController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.log-activities.index', [
|
||||
'title' => 'Log',
|
||||
'year' => $request->input('year', null),
|
||||
@ -19,13 +20,14 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$log = Activity::findOrFail(decrypt_id($id));
|
||||
|
||||
// dd($log);
|
||||
return view('dashboard.log-activities.show', [
|
||||
'title' => 'Log',
|
||||
'log' => $log
|
||||
'log' => $log,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
|
||||
class LoginHistoryController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.login-history.index', [
|
||||
'title' => 'Aktivitas Login',
|
||||
'year' => $request->input('year', null),
|
||||
@ -17,9 +18,10 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
@ -27,7 +29,7 @@ public function filter(Request $request){
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.login.history.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filtering data.');
|
||||
}
|
||||
|
||||
|
||||
@ -17,9 +17,10 @@
|
||||
|
||||
class MediaController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
if(is_role(['1', '5'])){
|
||||
return view('dashboard.media.admin.index',[
|
||||
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),
|
||||
@ -30,7 +31,7 @@ public function index(Request $request){
|
||||
'register_month' => $request->input('register_month', null),
|
||||
'register_date' => $request->input('register_date', null),
|
||||
]);
|
||||
}else if(is_role(['3'])){
|
||||
} elseif (is_role(['3'])) {
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(Auth::id());
|
||||
|
||||
$data = [
|
||||
@ -42,19 +43,21 @@ public function index(Request $request){
|
||||
}
|
||||
}
|
||||
|
||||
public function editRequest(){
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['0', '3'])){
|
||||
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'
|
||||
'title' => 'Permohonan Ubah Data Media',
|
||||
]);
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request){
|
||||
try{
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['0', '3'])){
|
||||
public function editRequestAction(Request $request)
|
||||
{
|
||||
try {
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['0', '3'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -64,16 +67,16 @@ public function editRequestAction(Request $request){
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
if(!Auth::check()){
|
||||
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']
|
||||
'edit_description' => $validatedData['edit_description'],
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('dashboard.media.index')->with('failed-status', 'Gagal melakukan permohonan edit data media.');
|
||||
}
|
||||
|
||||
@ -81,8 +84,9 @@ public function editRequestAction(Request $request){
|
||||
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['2'])){
|
||||
public function edit()
|
||||
{
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['2'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -90,19 +94,19 @@ public function edit(){
|
||||
|
||||
return view('dashboard.media.edit', [
|
||||
'title' => 'Ubah Data Media',
|
||||
'user' => $user
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(MediaRequest $request){
|
||||
public function update(MediaRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['2'])){
|
||||
try {
|
||||
if (! in_array(Auth::user()->company->media->edit_status, ['2'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
$media = User::with(['company.media'])->findOrFail(Auth::id())->company->media;
|
||||
|
||||
$fileFieldMap = [
|
||||
@ -133,14 +137,15 @@ public function update(MediaRequest $request){
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
} 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){
|
||||
public function show($id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
@ -151,7 +156,7 @@ public function show($id, $type){
|
||||
'purpose' => 'show',
|
||||
'idnPage' => 'media',
|
||||
'route' => 'media',
|
||||
'type' => $type
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
@ -162,6 +167,7 @@ public function show($id, $type){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
@ -179,17 +185,19 @@ public function show($id, $type){
|
||||
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'warning',
|
||||
'message' => 'Aksi belum tersedia.'
|
||||
'message' => 'Aksi belum tersedia.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function process(Request $request, $id, $type){
|
||||
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'])){
|
||||
if ($request->query('category') && ! in_array($request->query('category'), ['account-status', 'edit-request'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -202,7 +210,7 @@ public function process(Request $request, $id, $type){
|
||||
'idnPage' => 'media',
|
||||
'route' => 'media',
|
||||
'type' => $type,
|
||||
'category' => $request->query('category', null)
|
||||
'category' => $request->query('category', null),
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
@ -213,6 +221,7 @@ public function process(Request $request, $id, $type){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
@ -229,32 +238,34 @@ public function process(Request $request, $id, $type){
|
||||
}
|
||||
}
|
||||
|
||||
public function processAcceptAction(Request $request, $id, $type, $category){
|
||||
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'])){
|
||||
if (! in_array($category, ['account-status', 'edit-request']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if(is_role(['1']) && $category === 'edit-request'){
|
||||
if (is_role(['1']) && $category === 'edit-request') {
|
||||
$user->company->media->update([
|
||||
'edit_status' => '2'
|
||||
'edit_status' => '2',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Berhasil menyetujui permohonan edit media.'
|
||||
'message' => 'Berhasil menyetujui permohonan edit media.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function processRejectAction(Request $request, $id, $type, $category){
|
||||
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'])){
|
||||
if (! in_array($category, ['account-status', 'edit-request']) || ! is_role(['1'])) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if(is_role(['1'])){
|
||||
if (is_role(['1'])) {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
@ -262,10 +273,10 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
if($category === 'edit-request' && $user->company->media->edit_status === '1'){
|
||||
if ($category === 'edit-request' && $user->company->media->edit_status === '1') {
|
||||
$user->company->media->update([
|
||||
'edit_status' => '3',
|
||||
'edit_rejection_reason' => $validatedData['rejection_reason']
|
||||
'edit_rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -275,7 +286,7 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
$type = $request->input('type', null);
|
||||
$classification = $request->input('classification', null);
|
||||
$status = $request->input('status', null);
|
||||
@ -288,14 +299,15 @@ public function export(Request $request)
|
||||
$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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
@ -303,20 +315,21 @@ public function filter(Request $request){
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.media.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,8 @@
|
||||
|
||||
class MediaCooperationController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.media-cooperations.index', [
|
||||
'title' => 'Kerja Sama',
|
||||
'date' => $request->input('date', null),
|
||||
@ -28,24 +29,26 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.media-cooperations.create', [
|
||||
'title' => 'Tambah Kerja Sama',
|
||||
'media' => Media::all()
|
||||
'media' => Media::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(CooperationRequest $request){
|
||||
public function store(CooperationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
if($request->hasFile('banner')){
|
||||
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 = DB::transaction(function () use ($validatedData) {
|
||||
$createdCooperation = Cooperation::create($validatedData);
|
||||
|
||||
$allMediaIds = Media::pluck('id')->toArray();
|
||||
@ -57,25 +60,25 @@ public function store(CooperationRequest $request){
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
if(in_array('all', $validatedData['media_ids'])){
|
||||
foreach($allMediaIds as $mediaId){
|
||||
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){
|
||||
} 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>
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
@ -89,40 +92,44 @@ public function store(CooperationRequest $request){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan kerja sama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::info("ERROR (Cooperation): ". $e);
|
||||
} catch (\Exception $e) {
|
||||
Log::info('ERROR (Cooperation): '.$e);
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan kerja sama');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
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()
|
||||
'selectedMediaIds' => $cooperation->media->pluck('id')->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(CooperationRequest $request, $id){
|
||||
public function update(CooperationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
$oldCooperationName = $cooperation->name;
|
||||
|
||||
if($request->hasFile('banner')){
|
||||
if ($request->hasFile('banner')) {
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->banner);
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['banner'] = $cooperation->banner;
|
||||
}
|
||||
|
||||
if($request->hasFile('offer_file_template')){
|
||||
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{
|
||||
} else {
|
||||
$validatedData['offer_file_template'] = $cooperation->offer_file_template;
|
||||
}
|
||||
|
||||
@ -133,16 +140,16 @@ public function update(CooperationRequest $request, $id){
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
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>.
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
@ -153,40 +160,43 @@ public function update(CooperationRequest $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah kerja sama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah kerja sama');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$mediaCooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-cooperations.show', [
|
||||
'title' => 'Detail Kerja Sama',
|
||||
'mediaCooperation' => $mediaCooperation
|
||||
'mediaCooperation' => $mediaCooperation,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
@ -194,46 +204,48 @@ public function filter(Request $request){
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.cooperations.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mediaProposal($id){
|
||||
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
|
||||
'mediaCooperation' => $mediaCooperation,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalShow($id, $proposalId){
|
||||
public function mediaProposalShow($id, $proposalId)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
return view('dashboard.media-cooperations.media-proposals.show',[
|
||||
return view('dashboard.media-cooperations.media-proposals.show', [
|
||||
'title' => 'Detail Ajuan Kerja Sama',
|
||||
'proposal' => $proposal
|
||||
'proposal' => $proposal,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalAccept($id, $proposalId){
|
||||
public function mediaProposalAccept($id, $proposalId)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
$acceptedProposal = $proposal->update([
|
||||
'status' => '1'
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerja sama <u>'. $proposal->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
@ -244,22 +256,24 @@ public function mediaProposalAccept($id, $proposalId){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui pengajuan kerja sama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui pengajuan kerja sama');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function mediaProposalReject($id, $proposalId){
|
||||
public function mediaProposalReject($id, $proposalId)
|
||||
{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
return view('dashboard.media-cooperations.media-proposals.reject',[
|
||||
return view('dashboard.media-cooperations.media-proposals.reject', [
|
||||
'title' => 'Tolak Ajuan Kerja Sama',
|
||||
'proposal' => $proposal
|
||||
'proposal' => $proposal,
|
||||
]);
|
||||
}
|
||||
|
||||
public function mediaProposalRejectAction(Request $request, $id, $proposalId){
|
||||
public function mediaProposalRejectAction(Request $request, $id, $proposalId)
|
||||
{
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
@ -267,22 +281,22 @@ public function mediaProposalRejectAction(Request $request, $id, $proposalId){
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try{
|
||||
try {
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
$rejectedProposal = $proposal->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerja sama <u>'. $proposal->cooperation->name .'</u> <span class="text-danger">ditolak</span>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
@ -293,29 +307,30 @@ public function mediaProposalRejectAction(Request $request, $id, $proposalId){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak pengajuan kerja sama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak pengajuan kerja sama');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function process($id, $process, $paramMediaId = null){
|
||||
public function process($id, $process, $paramMediaId = null)
|
||||
{
|
||||
$mediaCooperation = Cooperation::with([
|
||||
'media',
|
||||
'mediaOrder.media',
|
||||
'mediaOrder.reports',
|
||||
'mediaOrder.completions'
|
||||
'mediaOrder.completions',
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
'process' => $process,
|
||||
'mediaCooperation' => $mediaCooperation,
|
||||
'mediaOrder' => $mediaCooperation->mediaOrder,
|
||||
'mediaId' => is_role(['3']) ? Auth::user()->company->media->id : null
|
||||
'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) use ($data) {
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
|
||||
@ -336,31 +351,31 @@ public function process($id, $process, $paramMediaId = null){
|
||||
}
|
||||
|
||||
// Tab Kerja Sama
|
||||
if($process === 'cooperation'){
|
||||
if ($process === 'cooperation') {
|
||||
$data['title'] = 'Detail Kerja Sama';
|
||||
|
||||
if(is_role(['3'])){
|
||||
if (is_role(['3'])) {
|
||||
$mediaOrderSafe = $data['mediaOrder'] ? $data['mediaOrder']->media->where('id', $data['mediaId'])->first() : null;
|
||||
|
||||
if($mediaOrderSafe){
|
||||
if ($mediaOrderSafe) {
|
||||
$data['mediaOrderPivot'] = $mediaOrderSafe->pivot;
|
||||
}
|
||||
|
||||
// Can Commented
|
||||
if($mediaOrderSafe){
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) use ($data) {
|
||||
if ($mediaOrderSafe) {
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
$reports = null;
|
||||
}
|
||||
|
||||
if(filled($reports)){
|
||||
if (filled($reports)) {
|
||||
$data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
return $item->status === '1';
|
||||
});
|
||||
$data['isHaveReports'] = true;
|
||||
}else{
|
||||
} else {
|
||||
$data['isAllReportsAccepted'] = false;
|
||||
$data['isHaveReports'] = false;
|
||||
}
|
||||
@ -370,24 +385,24 @@ public function process($id, $process, $paramMediaId = null){
|
||||
|
||||
return view('dashboard.media-cooperations.processes.cooperations.index', $data);
|
||||
|
||||
// Tab Media order
|
||||
}else if($process === 'media-order'){
|
||||
// Tab Media order
|
||||
} elseif ($process === 'media-order') {
|
||||
$data['title'] = 'Media Order';
|
||||
|
||||
if(is_role(['3'])){
|
||||
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) {
|
||||
$reports = $data['mediaOrder']->reports->filter(function ($reports) {
|
||||
return $reports->media_id == Auth::user()->company->media->id;
|
||||
});
|
||||
|
||||
if(filled($reports)){
|
||||
if (filled($reports)) {
|
||||
$data['isAllReportsAccepted'] = $reports->every(function ($item) {
|
||||
return $item->status === '1';
|
||||
});
|
||||
$data['isHaveReports'] = true;
|
||||
}else{
|
||||
} else {
|
||||
$data['isAllReportsAccepted'] = false;
|
||||
$data['isHaveReports'] = false;
|
||||
}
|
||||
@ -397,11 +412,11 @@ public function process($id, $process, $paramMediaId = null){
|
||||
|
||||
return view('dashboard.media-cooperations.processes.media-orders.index', $data);
|
||||
|
||||
// Tab laporan
|
||||
}else if($process === 'reports'){
|
||||
// Tab laporan
|
||||
} elseif ($process === 'reports') {
|
||||
$data['title'] = 'Laporan';
|
||||
|
||||
if(is_role(['3'])){
|
||||
if (is_role(['3'])) {
|
||||
$data['mediaOrderPivot'] = $data['mediaOrder']->media->where('id', $data['mediaId'])->first()->pivot;
|
||||
|
||||
$data['reporterMediaId'] = Auth::user()->company->media->id;
|
||||
@ -427,21 +442,21 @@ public function process($id, $process, $paramMediaId = null){
|
||||
|
||||
$data['cooperationCompletion'] = $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first();
|
||||
|
||||
if($reportCount === $data['mediaOrder']->required_reports){
|
||||
if ($reportCount === $data['mediaOrder']->required_reports) {
|
||||
$data['isReportsCompleted'] = true;
|
||||
}else{
|
||||
} else {
|
||||
$data['isReportsCompleted'] = false;
|
||||
}
|
||||
|
||||
return view('dashboard.media-cooperations.processes.reports.index-media', $data);
|
||||
}else{
|
||||
} else {
|
||||
$data['mediaOrder'] = $mediaCooperation->mediaOrder;
|
||||
$data['reporterMedia'] = $paramMediaId ? Media::findOrFail(decrypt_id($paramMediaId)) : null;
|
||||
$data['reporterMediaId'] = $paramMediaId ? decrypt_id($paramMediaId) : null;
|
||||
$data['reporterMediaId'] = $paramMediaId ? decrypt_id($paramMediaId) : null;
|
||||
|
||||
if(!$paramMediaId){
|
||||
if (! $paramMediaId) {
|
||||
return view('dashboard.media-cooperations.processes.reports.index-admin', $data);
|
||||
}else{
|
||||
} else {
|
||||
return view('dashboard.media-cooperations.processes.reports.index-media', $data);
|
||||
}
|
||||
}
|
||||
@ -507,9 +522,8 @@ public function process($id, $process, $paramMediaId = null){
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// Tab Selesai
|
||||
}else if($process === 'completion'){
|
||||
// Tab Selesai
|
||||
} elseif ($process === 'completion') {
|
||||
$data['title'] = 'Penyelesaian';
|
||||
|
||||
$data['isHaveReports'] = true;
|
||||
@ -517,7 +531,7 @@ public function process($id, $process, $paramMediaId = null){
|
||||
|
||||
$data['cooperationCompletion'] = $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first();
|
||||
|
||||
if(is_role(['3'])){
|
||||
if (is_role(['3'])) {
|
||||
$data['mediaOrderPivot'] = $data['mediaOrder']->media->where('id', $data['mediaId'])->first()->pivot;
|
||||
|
||||
// Can Commented
|
||||
@ -537,12 +551,11 @@ public function process($id, $process, $paramMediaId = null){
|
||||
// Can Commented
|
||||
|
||||
return view('dashboard.media-cooperations.processes.completions.index-media', $data);
|
||||
}else{
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
else if($process === 'completions'){
|
||||
} elseif ($process === 'completions') {
|
||||
$data['title'] = 'Penyelesaian';
|
||||
|
||||
$data['isHaveReports'] = true;
|
||||
@ -550,40 +563,39 @@ public function process($id, $process, $paramMediaId = null){
|
||||
|
||||
$data['cooperationCompletion'] = $data['mediaOrder']->completions()->where('media_id', $data['mediaId'])->first();
|
||||
|
||||
if(is_role(['1'])){
|
||||
if (is_role(['1'])) {
|
||||
return view('dashboard.media-cooperations.processes.completions.index-admin', $data);
|
||||
}else{
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$cooperation = Cooperation::with(['media', 'mediaOrder'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if($cooperation->mediaOrder){
|
||||
if ($cooperation->mediaOrder) {
|
||||
|
||||
DB::transaction(function()use ($cooperation){
|
||||
DB::transaction(function () use ($cooperation) {
|
||||
$cooperation->media()->detach();
|
||||
$cooperation->delete();
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ajuan kerja sama dan semua media berhasil dihapus.'
|
||||
'message' => 'Ajuan kerja sama dan semua media berhasil dihapus.',
|
||||
]);
|
||||
}else{
|
||||
} else {
|
||||
return response()->json(['message' => 'Kerja Sama sudah memiliki media order.'], 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Gagal menghapus ajuan kerja sama.'], 500);
|
||||
}
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class MediaMonitoringController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.media-monitorings.index', [
|
||||
'title' => 'Monitoring Media',
|
||||
'news_title' => $request->input('news_title', null),
|
||||
@ -30,16 +30,18 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.media-monitorings.create', [
|
||||
'title' => 'Tambah Monitoring Media'
|
||||
'title' => 'Tambah Monitoring Media',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(MediaMonitoringRequest $request){
|
||||
public function store(MediaMonitoringRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$latestCode = MediaMonitoring::max('code');
|
||||
$lastNumber = $latestCode ? intval(substr($latestCode, 3)) : 0;
|
||||
$newNumber = str_pad($lastNumber + 1, 6, '0', STR_PAD_LEFT);
|
||||
@ -49,62 +51,65 @@ public function store(MediaMonitoringRequest $request){
|
||||
$validatedData['image'] = store_file($validatedData['image'], 'uploads/media-monitorings')['randomFileName'];
|
||||
|
||||
MediaMonitoring::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
} 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){
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-monitorings.edit', [
|
||||
'title' => 'Ubah Monitoring Media',
|
||||
'mediaMonitoring' => $mediaMonitoring
|
||||
'mediaMonitoring' => $mediaMonitoring,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(MediaMonitoringRequest $request, $id){
|
||||
public function update(MediaMonitoringRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
$validatedData['code'] = $mediaMonitoring->code;
|
||||
|
||||
if($request->has('image')){
|
||||
if ($request->has('image')) {
|
||||
delete_file('app/public/uploads/media-monitorings/'.$mediaMonitoring->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-monitorings')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['image'] = $mediaMonitoring->image;
|
||||
}
|
||||
|
||||
$mediaMonitoring->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
} 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){
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.media-monitorings.show', [
|
||||
'title' => 'Detail Monitoring Media',
|
||||
'mediaMonitoring' => $mediaMonitoring
|
||||
'mediaMonitoring' => $mediaMonitoring,
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
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);
|
||||
@ -116,13 +121,14 @@ public function checkLink(Request $request)
|
||||
$linkExists = MediaMonitoring::where('link', $request->link)->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
@ -130,7 +136,7 @@ public function filter(Request $request){
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.media.monitorings.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
|
||||
@ -139,7 +145,7 @@ public function filter(Request $request){
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$news_title = $request->input('news_title', null);
|
||||
$channel = $request->input('channel', 'all');
|
||||
$issue_status = $request->input('issue_status', 'all');
|
||||
@ -154,20 +160,21 @@ public function export(Request $request)
|
||||
$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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
public function printData($id)
|
||||
{
|
||||
|
||||
try{
|
||||
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 $pdf->stream(slugify('monitoring media '.$mediaMonitoring->code).'.pdf');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
|
||||
class MediaOrderController extends Controller
|
||||
{
|
||||
public function create($id){
|
||||
public function create($id)
|
||||
{
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$media = $cooperation->proposals->where('status', '1')->pluck('media_id');
|
||||
|
||||
@ -23,37 +24,38 @@ public function create($id){
|
||||
'title' => 'Buat Media Order',
|
||||
'cooperation' => $cooperation,
|
||||
'media' => Media::all(),
|
||||
'acceptedMedia' => $media
|
||||
'acceptedMedia' => $media,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(OrderRequest $request, $id){
|
||||
public function store(OrderRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
if($request->hasFile('image')){
|
||||
try {
|
||||
if ($request->hasFile('image')) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $cooperation->id;
|
||||
|
||||
$createdOrder = DB::transaction(function()use($validatedData, $cooperation){
|
||||
$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){
|
||||
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>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
@ -67,12 +69,13 @@ public function store(OrderRequest $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat media order');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat media order');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
public function edit($id)
|
||||
{
|
||||
// $cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaOrder = Order::findOrFail(decrypt_id($id));
|
||||
@ -86,23 +89,24 @@ public function edit($id){
|
||||
'mediaOrder' => $mediaOrder,
|
||||
'media' => Media::all(),
|
||||
'acceptedMedia' => $media,
|
||||
'acceptedMediaNow' => $mediaOrder->media->pluck('id')
|
||||
'acceptedMediaNow' => $mediaOrder->media->pluck('id'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(OrderRequest $request, $id){
|
||||
public function update(OrderRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$mediaOrder = Order::findOrFail(decrypt_id($id));
|
||||
|
||||
$validatedData['cooperation_id'] = $mediaOrder->cooperation_id;
|
||||
|
||||
if($request->hasFile('image')){
|
||||
if ($request->hasFile('image')) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/media-orders/'.$mediaOrder->image);
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['image'] = $mediaOrder->image;
|
||||
}
|
||||
|
||||
@ -117,13 +121,14 @@ public function update(OrderRequest $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah media order');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} 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){
|
||||
public function accept(Request $request, $id)
|
||||
{
|
||||
if (! Auth::check() || Auth::user()->role_id !== 3) {
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
@ -133,7 +138,7 @@ public function accept(Request $request, $id){
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaOrder) {
|
||||
if (! $mediaOrder) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
@ -144,9 +149,9 @@ public function accept(Request $request, $id){
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.$mediaOrder->name.'</u> telah <span class="text-primary">menerima</span> media order kerja sama <b>'.$order->cooperation->name. '</b>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
@ -167,14 +172,15 @@ public function accept(Request $request, $id){
|
||||
}
|
||||
}
|
||||
|
||||
public function reject(Request $request, $id){
|
||||
public function reject(Request $request, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try{
|
||||
try {
|
||||
|
||||
$order = Order::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
@ -182,23 +188,23 @@ public function reject(Request $request, $id){
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaOrder) {
|
||||
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']
|
||||
'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>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
@ -217,7 +223,7 @@ public function reject(Request $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerja sama sudah diterima sebelumnya.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak media order.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
use App\Models\News;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
@ -16,7 +15,8 @@
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.news.index', [
|
||||
'title' => 'Data Berita',
|
||||
'category' => $request->input('category', null),
|
||||
@ -27,65 +27,69 @@ public function index(Request $request){
|
||||
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.news.create', [
|
||||
'title' => 'Buat Berita Baru'
|
||||
'title' => 'Buat Berita Baru',
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(NewsRequest $request){
|
||||
public function store(NewsRequest $request)
|
||||
{
|
||||
// dd('hai');
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$isNewsExists = News::withTrashed()->where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if($isNewsExists){
|
||||
if ($isNewsExists) {
|
||||
return redirect()->back()->with('failed-status', 'Maaf, berita dengan judul tersebut sudah pernah ditambahkan.');
|
||||
}
|
||||
|
||||
try{
|
||||
if($request->has('image')){
|
||||
try {
|
||||
if ($request->has('image')) {
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
}
|
||||
News::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
} 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){
|
||||
public function edit($id)
|
||||
{
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.news.edit', [
|
||||
'title' => 'Ubah Berita',
|
||||
'news' => $news
|
||||
'news' => $news,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(NewsRequest $request, $id){
|
||||
public function update(NewsRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
if($request->has('image')){
|
||||
if ($request->has('image')) {
|
||||
delete_file('uploads/news/'.$news->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['image'] = $news->image;
|
||||
}
|
||||
|
||||
$isNewsExists = News::where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if($isNewsExists && $isNewsExists->id !== $news->id){
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah berita.');
|
||||
}
|
||||
|
||||
@ -93,12 +97,13 @@ public function update(NewsRequest $request, $id){
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.news.show', [
|
||||
'title' => 'Detail Berita',
|
||||
'news' => $news
|
||||
'news' => $news,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -106,9 +111,9 @@ public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
DB::transaction(function () use ($id, $news) {
|
||||
DB::transaction(function () use ($news) {
|
||||
|
||||
$newSlug = Str::limit($news->slug . '-deleted-' . now()->timestamp, 191);
|
||||
$newSlug = Str::limit($news->slug.'-deleted-'.now()->timestamp, 191);
|
||||
|
||||
$news->update([
|
||||
'slug' => $newSlug,
|
||||
@ -121,31 +126,32 @@ public function destroy($id)
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Berita tidak ditemukan.'], 404);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Gagal menghapus berita: ' . $e->getMessage());
|
||||
Log::error('Gagal menghapus berita: '.$e->getMessage());
|
||||
|
||||
return response()->json(['message' => 'Gagal menghapus berita.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
try{
|
||||
try {
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
@ -153,22 +159,22 @@ public function filter(Request $request){
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.news.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function printData($slug){
|
||||
public function printData($slug)
|
||||
{
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
|
||||
@ -179,7 +185,7 @@ public function checkLink(Request $request)
|
||||
$linkExists = News::where('link', $request->link)->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class OverviewController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Ikhtisar'
|
||||
'title' => 'Ikhtisar',
|
||||
];
|
||||
|
||||
$year = $request->input('year') ? $request->input('year') : Carbon::now()->year;
|
||||
@ -66,7 +66,6 @@ public function index(Request $request)
|
||||
$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) {
|
||||
@ -145,7 +144,7 @@ public function index(Request $request)
|
||||
$query->where('media_orders.status', '=', '1');
|
||||
})
|
||||
->get();
|
||||
} else if (is_role(['1'])) {
|
||||
} elseif (is_role(['1'])) {
|
||||
// Statistik Isu
|
||||
$issues = IssueManagement::all();
|
||||
$issueCounts = $issues->groupBy('issue')->map(function ($group) {
|
||||
@ -184,7 +183,6 @@ public function index(Request $request)
|
||||
$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) {
|
||||
@ -233,7 +231,7 @@ public function index(Request $request)
|
||||
|
||||
// Data kalender media order
|
||||
$data['mediaOrders'] = Order::with(['cooperation'])->get();
|
||||
} else if (is_role(['5'])) {
|
||||
} elseif (is_role(['5'])) {
|
||||
|
||||
// Statistik Penyelesaian Kerja sama
|
||||
$cooperationCompletion = CooperationCompletion::all();
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.reports.index', [
|
||||
'title' => 'Laporan Bukti Tayang',
|
||||
'mediaCollection' => Media::all(),
|
||||
@ -30,108 +30,116 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function create($id){
|
||||
public function create($id)
|
||||
{
|
||||
return view('dashboard.reports.create', [
|
||||
'title' => 'Buat Laporan',
|
||||
'mediaOrderId' => $id
|
||||
'mediaOrderId' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(ReportRequest $request, $id){
|
||||
public function store(ReportRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan laporan.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.cooperations.process', ['id' => $id, 'process' => 'reports'])->with('success-status', 'Berhasil menambahkan laporan.');
|
||||
}
|
||||
|
||||
public function edit($mediaOrderId, $id){
|
||||
public function edit($mediaOrderId, $id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.edit', [
|
||||
'title' => 'Buat Laporan',
|
||||
'report' => $report,
|
||||
'mediaOrderId' => $mediaOrderId
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(ReportRequest $request, $mediaOrderId, $id){
|
||||
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{
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
if($request->hasFile('image')){
|
||||
if ($request->hasFile('image')) {
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/reports/'.$report->proof);
|
||||
}else{
|
||||
} else {
|
||||
$validatedData['proof'] = $report->proof;
|
||||
}
|
||||
|
||||
$updatedReport = $report->update($validatedData);
|
||||
|
||||
if($updatedReport){
|
||||
if ($updatedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah laporan.');
|
||||
}else{
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah laporan.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah laporan.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($mediaOrderId, $id){
|
||||
public function show($mediaOrderId, $id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.show', [
|
||||
'title' => 'Detail Laporan',
|
||||
'report' => $report,
|
||||
'mediaOrderId' => $mediaOrderId
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function showIndex($id){
|
||||
public function showIndex($id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.index.show', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'report' => $report
|
||||
'report' => $report,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processIndex($id){
|
||||
public function processIndex($id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.index.process', [
|
||||
'title' => 'Detail Penyelesaian Kerja Sama',
|
||||
'report' => $report
|
||||
'report' => $report,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accept($id){
|
||||
public function accept($id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$acceptedReport = $report->update([
|
||||
'status' => '1'
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Laporan bukti tayang kerja sama <u>'. $report->order->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
@ -144,36 +152,38 @@ public function accept($id){
|
||||
}
|
||||
}
|
||||
|
||||
public function reject($mediaOrderId, $id){
|
||||
public function reject($mediaOrderId, $id)
|
||||
{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.reports.reject', [
|
||||
'title' => 'Tolak Laporan',
|
||||
'report' => $report,
|
||||
'mediaOrderId' => $mediaOrderId
|
||||
'mediaOrderId' => $mediaOrderId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try{
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$rejectedReport = $report->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'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>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
@ -184,31 +194,32 @@ public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}
|
||||
|
||||
public function rejectActionIndex(Request $request, $id){
|
||||
public function rejectActionIndex(Request $request, $id)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
try{
|
||||
try {
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$rejectedReport = $report->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'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>',
|
||||
'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()
|
||||
'enhancer_id' => Auth::id(),
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
@ -219,18 +230,18 @@ public function rejectActionIndex(Request $request, $id){
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
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);
|
||||
@ -240,17 +251,17 @@ public function destroy($id){
|
||||
public function checkLink(Request $request)
|
||||
{
|
||||
$linkExists = Report::where('link', $request->link)
|
||||
->where('media_id', Auth::user()->company->media->id)
|
||||
->exists();
|
||||
->where('media_id', Auth::user()->company->media->id)
|
||||
->exists();
|
||||
|
||||
return response()->json([
|
||||
'exists' => $linkExists
|
||||
'exists' => $linkExists,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
$export_type = $request->input('export_type', 'excel');
|
||||
|
||||
$media = $request->input('media', null);
|
||||
@ -260,23 +271,24 @@ public function export(Request $request)
|
||||
$to_month = $request->input('to_month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
if($export_type === 'excel'){
|
||||
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'])){
|
||||
} elseif ($export_type === 'pdf') {
|
||||
if (is_role(['1', '5'])) {
|
||||
$query = Report::with(['media.company', 'order.cooperation']);
|
||||
}else if(is_role(['3'])){
|
||||
} 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)) {
|
||||
if (! empty($media) && is_array($media)) {
|
||||
$query->whereIn('media_id', $media);
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
switch($status){
|
||||
switch ($status) {
|
||||
case 'waiting':
|
||||
$query->where('status', '0');
|
||||
break;
|
||||
@ -311,20 +323,21 @@ public function export(Request $request)
|
||||
return $pdf->stream(slugify('laporan bukti tayang ').'.pdf');
|
||||
}
|
||||
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function singlePrint(){
|
||||
try{
|
||||
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 $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.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.role.index', [
|
||||
'title' => 'Role Pengguna'
|
||||
'title' => 'Role Pengguna',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,11 +5,11 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SettingRequest;
|
||||
use App\Settings\AppSettings;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.setting.index', [
|
||||
'title' => 'Pengaturan Aplikasi',
|
||||
]);
|
||||
@ -19,7 +19,7 @@ public function update(SettingRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$settings = app(AppSettings::class);
|
||||
|
||||
$files = ['app_icon', 'app_logo'];
|
||||
@ -35,32 +35,31 @@ public function update(SettingRequest $request)
|
||||
}
|
||||
|
||||
$settings->fill([
|
||||
'app_name' => $validatedData['app_name'] ?? $settings->app_name,
|
||||
'app_title' => $validatedData['app_title'] ?? $settings->app_title,
|
||||
'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,
|
||||
'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,
|
||||
'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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah informasi aplikasi.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,17 +15,17 @@
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StatisticController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$statistics = [
|
||||
[
|
||||
'name' => 'Aktivitas Login',
|
||||
'category' => 'login-activities',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
// [
|
||||
// 'name' => 'Jurnalis',
|
||||
@ -35,12 +35,12 @@ public function index(Request $request){
|
||||
[
|
||||
'name' => 'Kerja Sama Media',
|
||||
'category' => 'media-cooperations',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Laporan Bukti Tayang',
|
||||
'category' => 'airing-proof-reports',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
// [
|
||||
// 'name' => 'Media',
|
||||
@ -50,17 +50,17 @@ public function index(Request $request){
|
||||
[
|
||||
'name' => 'Monitoring Media & Manajemen Isu',
|
||||
'category' => 'media-monitorings-issue-management',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Penyelesaian Kerja Sama',
|
||||
'category' => 'cooperation-completions',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Pengguna',
|
||||
'category' => 'users',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
// [
|
||||
// 'name' => 'Perusahaan',
|
||||
@ -70,23 +70,23 @@ public function index(Request $request){
|
||||
[
|
||||
'name' => 'Rekap Konten',
|
||||
'category' => 'content-recaps',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Pengunjung Website',
|
||||
'category' => 'website-visitors',
|
||||
'is_available' => true
|
||||
'is_available' => true,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
return view('dashboard.statistics.index', [
|
||||
'title' => 'Statistik',
|
||||
'statistics' => $statistics
|
||||
'statistics' => $statistics,
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(Request $request, $category){
|
||||
public function show(Request $request, $category)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'category' => $category,
|
||||
@ -101,7 +101,7 @@ public function show(Request $request, $category){
|
||||
'companies',
|
||||
];
|
||||
|
||||
if(in_array($category, $upComings)){
|
||||
if (in_array($category, $upComings)) {
|
||||
return redirect()->back()->with('waiting-status', 'Dalam pegembangan');
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public function show(Request $request, $category){
|
||||
$from_month = $request->input('from_month', null);
|
||||
$to_month = $request->input('to_month', null);
|
||||
|
||||
switch($category){
|
||||
switch ($category) {
|
||||
case 'login-activities':
|
||||
$data['title'] = 'Statistik Aktivitas Login';
|
||||
$data['data_time'] = $year === 'all' ? 'Semua' : 'Tahun '.$year;
|
||||
@ -118,7 +118,7 @@ public function show(Request $request, $category){
|
||||
|
||||
$loginActivities = LoginHistory::with(['user']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$loginActivities->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
@ -140,11 +140,11 @@ public function show(Request $request, $category){
|
||||
|
||||
$mediaCooperation = MediaCooperation::with(['cooperation', 'media']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$mediaCooperation->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -156,7 +156,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$mediaCooperation->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -176,7 +176,7 @@ public function show(Request $request, $category){
|
||||
|
||||
// Kelompokkan data berdasarkan status lalu bulan
|
||||
$mediaCooperation->groupBy('status')->each(function ($groupedByStatus, $status) use (&$monthlyStatus) {
|
||||
$label = match ((int)$status) {
|
||||
$label = match ((int) $status) {
|
||||
0 => 'waiting',
|
||||
1 => 'accepted',
|
||||
2 => 'rejected',
|
||||
@ -185,7 +185,7 @@ public function show(Request $request, $category){
|
||||
|
||||
if ($label) {
|
||||
$groupedByStatus->groupBy(function ($item) {
|
||||
return (int)$item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
return (int) $item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
})->each(function ($items, $month) use (&$monthlyStatus, $label) {
|
||||
$monthlyStatus[$label][$month - 1] = $items->count();
|
||||
});
|
||||
@ -216,11 +216,11 @@ public function show(Request $request, $category){
|
||||
|
||||
$airingProofReport = Report::with(['order', 'media']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$airingProofReport->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -232,7 +232,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$airingProofReport->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -252,7 +252,7 @@ public function show(Request $request, $category){
|
||||
|
||||
// Kelompokkan data berdasarkan status lalu bulan
|
||||
$airingProofReport->groupBy('status')->each(function ($groupedByStatus, $status) use (&$monthlyStatus) {
|
||||
$label = match ((int)$status) {
|
||||
$label = match ((int) $status) {
|
||||
0 => 'waiting',
|
||||
1 => 'accepted',
|
||||
2 => 'rejected',
|
||||
@ -261,7 +261,7 @@ public function show(Request $request, $category){
|
||||
|
||||
if ($label) {
|
||||
$groupedByStatus->groupBy(function ($item) {
|
||||
return (int)$item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
return (int) $item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
})->each(function ($items, $month) use (&$monthlyStatus, $label) {
|
||||
$monthlyStatus[$label][$month - 1] = $items->count();
|
||||
});
|
||||
@ -294,12 +294,12 @@ public function show(Request $request, $category){
|
||||
$issues = IssueManagement::with(['mediaMonitoring']);
|
||||
$mediaMonitorings = MediaMonitoring::with(['issue']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$issues->whereYear('created_at', $year);
|
||||
$mediaMonitorings->whereYear('created_at', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -311,7 +311,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$issues->whereBetween('created_at', [$start, $end]);
|
||||
$mediaMonitorings->whereBetween('created_at', [$start, $end]);
|
||||
@ -320,7 +320,6 @@ public function show(Request $request, $category){
|
||||
$issues = $issues->get();
|
||||
$mediaMonitorings = $mediaMonitorings->get();
|
||||
|
||||
|
||||
$issueCounts = $issues->groupBy('issue')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
@ -361,28 +360,28 @@ public function show(Request $request, $category){
|
||||
});
|
||||
|
||||
$mediaMonitoringWithoutIssue = MediaMonitoring::doesntHave('issue')
|
||||
->when($year && $year !== 'all' && !(filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
->when($year && $year !== 'all' && ! (filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
|
||||
$mediaMonitoringWithIssue = MediaMonitoring::has('issue')
|
||||
->when($year && $year !== 'all' && !(filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
->when($year && $year !== 'all' && ! (filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
|
||||
$data['mediaMonitoringWithoutIssueCount'] = $mediaMonitoringWithoutIssue->count();
|
||||
$data['mediaMonitoringWithIssueCount'] = $mediaMonitoringWithIssue->count();
|
||||
@ -397,11 +396,11 @@ public function show(Request $request, $category){
|
||||
|
||||
$cooperationCompletion = CooperationCompletion::with(['order', 'media']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$cooperationCompletion->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -413,7 +412,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$cooperationCompletion->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -433,7 +432,7 @@ public function show(Request $request, $category){
|
||||
|
||||
// Kelompokkan data berdasarkan status lalu bulan
|
||||
$cooperationCompletion->groupBy('status')->each(function ($groupedByStatus, $status) use (&$monthlyStatus) {
|
||||
$label = match ((int)$status) {
|
||||
$label = match ((int) $status) {
|
||||
0 => 'waiting',
|
||||
1 => 'accepted',
|
||||
2 => 'rejected',
|
||||
@ -442,7 +441,7 @@ public function show(Request $request, $category){
|
||||
|
||||
if ($label) {
|
||||
$groupedByStatus->groupBy(function ($item) {
|
||||
return (int)$item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
return (int) $item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
})->each(function ($items, $month) use (&$monthlyStatus, $label) {
|
||||
$monthlyStatus[$label][$month - 1] = $items->count();
|
||||
});
|
||||
@ -475,11 +474,11 @@ public function show(Request $request, $category){
|
||||
|
||||
$registerUsers = User::query();
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$registerUsers->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -491,7 +490,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$registerUsers->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -513,11 +512,11 @@ public function show(Request $request, $category){
|
||||
|
||||
$contenteRecap = ContentRecap::with(['enhancer', 'classification']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$contenteRecap->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -529,7 +528,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$contenteRecap->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -576,11 +575,11 @@ public function show(Request $request, $category){
|
||||
|
||||
$websiteVisitors = Visitor::query();
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$websiteVisitors->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -592,7 +591,7 @@ public function show(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$websiteVisitors->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -613,7 +612,8 @@ public function show(Request $request, $category){
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request, $category){
|
||||
public function export(Request $request, $category)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'category' => $category,
|
||||
@ -629,7 +629,7 @@ public function export(Request $request, $category){
|
||||
|
||||
// dd($from_month.' - '. $to_month);
|
||||
|
||||
switch($category){
|
||||
switch ($category) {
|
||||
case 'login-activities':
|
||||
$data['title'] = 'Statistik Aktivitas Login';
|
||||
|
||||
@ -637,7 +637,7 @@ public function export(Request $request, $category){
|
||||
|
||||
$loginActivities = LoginHistory::with(['user']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$loginActivities->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
@ -653,6 +653,7 @@ public function export(Request $request, $category){
|
||||
$data['loginActivities'] = $monthlyCount;
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.login-activity', $data);
|
||||
|
||||
return $pdf->stream('aktivitas-login-'.$data['year'].'.pdf');
|
||||
case 'media-cooperations':
|
||||
$data['title'] = 'Statistik Kerja Sama Media';
|
||||
@ -660,11 +661,11 @@ public function export(Request $request, $category){
|
||||
|
||||
$mediaCooperation = MediaCooperation::with(['cooperation', 'media']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$mediaCooperation->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -676,7 +677,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$mediaCooperation->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -696,7 +697,7 @@ public function export(Request $request, $category){
|
||||
|
||||
// Kelompokkan data berdasarkan status lalu bulan
|
||||
$mediaCooperation->groupBy('status')->each(function ($groupedByStatus, $status) use (&$monthlyStatus) {
|
||||
$label = match ((int)$status) {
|
||||
$label = match ((int) $status) {
|
||||
0 => 'waiting',
|
||||
1 => 'accepted',
|
||||
2 => 'rejected',
|
||||
@ -705,7 +706,7 @@ public function export(Request $request, $category){
|
||||
|
||||
if ($label) {
|
||||
$groupedByStatus->groupBy(function ($item) {
|
||||
return (int)$item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
return (int) $item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
})->each(function ($items, $month) use (&$monthlyStatus, $label) {
|
||||
$monthlyStatus[$label][$month - 1] = $items->count();
|
||||
});
|
||||
@ -732,6 +733,7 @@ public function export(Request $request, $category){
|
||||
// dd($data);
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.media-cooperation', $data);
|
||||
|
||||
return $pdf->stream('kerja-sama-media.pdf');
|
||||
case 'airing-proof-reports':
|
||||
$data['title'] = 'Statistik Laporan Bukti Tayang';
|
||||
@ -739,11 +741,11 @@ public function export(Request $request, $category){
|
||||
|
||||
$airingProofReport = Report::with(['order', 'media']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$airingProofReport->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -755,7 +757,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$airingProofReport->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -775,7 +777,7 @@ public function export(Request $request, $category){
|
||||
|
||||
// Kelompokkan data berdasarkan status lalu bulan
|
||||
$airingProofReport->groupBy('status')->each(function ($groupedByStatus, $status) use (&$monthlyStatus) {
|
||||
$label = match ((int)$status) {
|
||||
$label = match ((int) $status) {
|
||||
0 => 'waiting',
|
||||
1 => 'accepted',
|
||||
2 => 'rejected',
|
||||
@ -784,7 +786,7 @@ public function export(Request $request, $category){
|
||||
|
||||
if ($label) {
|
||||
$groupedByStatus->groupBy(function ($item) {
|
||||
return (int)$item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
return (int) $item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
})->each(function ($items, $month) use (&$monthlyStatus, $label) {
|
||||
$monthlyStatus[$label][$month - 1] = $items->count();
|
||||
});
|
||||
@ -809,6 +811,7 @@ public function export(Request $request, $category){
|
||||
$data['airingProofReportRejected'] = $airingProofReportCount->get('2', 0);
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.airing-proof-report', $data);
|
||||
|
||||
return $pdf->stream('laporan-bukti-tayang.pdf');
|
||||
case 'media-monitorings-issue-management':
|
||||
$data['title'] = 'Statistik Monitoring Media & Manajemen Isu';
|
||||
@ -818,12 +821,12 @@ public function export(Request $request, $category){
|
||||
$issues = IssueManagement::with(['mediaMonitoring']);
|
||||
$mediaMonitorings = MediaMonitoring::with(['issue']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$issues->whereYear('created_at', $year);
|
||||
$mediaMonitorings->whereYear('created_at', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -835,7 +838,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$issues->whereBetween('created_at', [$start, $end]);
|
||||
$mediaMonitorings->whereBetween('created_at', [$start, $end]);
|
||||
@ -844,7 +847,6 @@ public function export(Request $request, $category){
|
||||
$issues = $issues->get();
|
||||
$mediaMonitorings = $mediaMonitorings->get();
|
||||
|
||||
|
||||
$issueCounts = $issues->groupBy('issue')->map(function ($group) {
|
||||
return $group->count();
|
||||
});
|
||||
@ -885,28 +887,28 @@ public function export(Request $request, $category){
|
||||
});
|
||||
|
||||
$mediaMonitoringWithoutIssue = MediaMonitoring::doesntHave('issue')
|
||||
->when($year && $year !== 'all' && !(filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
->when($year && $year !== 'all' && ! (filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
|
||||
$mediaMonitoringWithIssue = MediaMonitoring::has('issue')
|
||||
->when($year && $year !== 'all' && !(filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
->when($year && $year !== 'all' && ! (filled($from_month) || filled($to_month)), function ($query) use ($year) {
|
||||
$query->whereYear('created_at', $year);
|
||||
})
|
||||
->when($from_month && $to_month, function ($query) use ($from_month, $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
$query->whereBetween('created_at', [$start, $end]);
|
||||
})
|
||||
->get();
|
||||
|
||||
$data['mediaMonitoringWithoutIssueCount'] = $mediaMonitoringWithoutIssue->count();
|
||||
$data['mediaMonitoringWithIssueCount'] = $mediaMonitoringWithIssue->count();
|
||||
@ -915,6 +917,7 @@ public function export(Request $request, $category){
|
||||
$data['issueManagementMonthly'] = $issueManagementMonthly;
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.media-monitoring-issue-management', $data);
|
||||
|
||||
return $pdf->stream('monitoring-media-manajemen-isu.pdf');
|
||||
case 'cooperation-completions':
|
||||
$data['title'] = 'Statistik Penyelesaian Kerja Sama';
|
||||
@ -922,11 +925,11 @@ public function export(Request $request, $category){
|
||||
|
||||
$cooperationCompletion = CooperationCompletion::with(['order', 'media']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$cooperationCompletion->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -938,7 +941,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$cooperationCompletion->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -958,7 +961,7 @@ public function export(Request $request, $category){
|
||||
|
||||
// Kelompokkan data berdasarkan status lalu bulan
|
||||
$cooperationCompletion->groupBy('status')->each(function ($groupedByStatus, $status) use (&$monthlyStatus) {
|
||||
$label = match ((int)$status) {
|
||||
$label = match ((int) $status) {
|
||||
0 => 'waiting',
|
||||
1 => 'accepted',
|
||||
2 => 'rejected',
|
||||
@ -967,7 +970,7 @@ public function export(Request $request, $category){
|
||||
|
||||
if ($label) {
|
||||
$groupedByStatus->groupBy(function ($item) {
|
||||
return (int)$item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
return (int) $item->created_at->format('m'); // bulan sebagai angka 1–12
|
||||
})->each(function ($items, $month) use (&$monthlyStatus, $label) {
|
||||
$monthlyStatus[$label][$month - 1] = $items->count();
|
||||
});
|
||||
@ -992,6 +995,7 @@ public function export(Request $request, $category){
|
||||
$data['cooperationCompletionRejected'] = $cooperationCompletionCount->get('2', 0);
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.cooperation-completion', $data);
|
||||
|
||||
return $pdf->stream('penyelesaian-kerja-sama.pdf');
|
||||
case 'users':
|
||||
$data['title'] = 'Statistik Pengguna';
|
||||
@ -1001,11 +1005,11 @@ public function export(Request $request, $category){
|
||||
|
||||
$registerUsers = User::query();
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$registerUsers->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -1017,7 +1021,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$registerUsers->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -1033,6 +1037,7 @@ public function export(Request $request, $category){
|
||||
$data['registerUserMonth'] = $monthlyCount;
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.user', $data);
|
||||
|
||||
return $pdf->stream('pengguna.pdf');
|
||||
case 'content-recaps':
|
||||
$data['title'] = 'Statistik Rekap Konten';
|
||||
@ -1040,11 +1045,11 @@ public function export(Request $request, $category){
|
||||
|
||||
$contenteRecap = ContentRecap::with(['enhancer', 'classification']);
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$contenteRecap->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -1056,7 +1061,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$contenteRecap->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -1095,6 +1100,7 @@ public function export(Request $request, $category){
|
||||
$data['socialMedia3ContentRecap'] = $contentRecapSocialMediaCount->get('Purwakarta Saber Hoaks', 0);
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.content-recap', $data);
|
||||
|
||||
return $pdf->stream('rekap-konten.pdf');
|
||||
case 'website-visitors':
|
||||
$data['title'] = 'Statistik Pengunjung Website';
|
||||
@ -1104,11 +1110,11 @@ public function export(Request $request, $category){
|
||||
|
||||
$websiteVisitors = Visitor::query();
|
||||
|
||||
if($year && $year !== 'all' && !(filled($from_month) || filled($to_month))){
|
||||
if ($year && $year !== 'all' && ! (filled($from_month) || filled($to_month))) {
|
||||
$websiteVisitors->whereYear('created_at', '=', $year);
|
||||
}
|
||||
|
||||
if($from_month && $to_month){
|
||||
if ($from_month && $to_month) {
|
||||
$start = Carbon::parse($from_month)->startOfMonth();
|
||||
$end = Carbon::parse($to_month)->endOfMonth();
|
||||
|
||||
@ -1120,7 +1126,7 @@ public function export(Request $request, $category){
|
||||
$fromFormatted = $fromDate ? $fromDate->translatedFormat('F Y') : '-';
|
||||
$toFormatted = $toDate ? $toDate->translatedFormat('F Y') : '-';
|
||||
|
||||
$data['data_time'] = $fromFormatted . ' - ' . $toFormatted;
|
||||
$data['data_time'] = $fromFormatted.' - '.$toFormatted;
|
||||
|
||||
$websiteVisitors->whereBetween('created_at', [$start, $end]);
|
||||
}
|
||||
@ -1136,6 +1142,7 @@ public function export(Request $request, $category){
|
||||
$data['websiteVisitorMonth'] = $monthlyCount;
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.statistics.exports.pdf.website-visitor', $data);
|
||||
|
||||
return $pdf->stream('pengunjung-aplikasi.pdf');
|
||||
default:
|
||||
abort(404);
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
use App\Models\Classification;
|
||||
use App\Models\SubClassification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SubClassificationController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Data Sub Klasifikasi',
|
||||
@ -24,61 +23,66 @@ public function index(Request $request){
|
||||
return view('dashboard.sub-classifications.index', $viewData);
|
||||
}
|
||||
|
||||
public function create(Request $request){
|
||||
public function create(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Buat Sub Klasifikasi Baru',
|
||||
'fromClassification' => false
|
||||
'fromClassification' => false,
|
||||
];
|
||||
|
||||
if($request->has('classification')){
|
||||
if ($request->has('classification')) {
|
||||
$classificationId = decrypt_id($request->query('classification'));
|
||||
$viewData['classification'] = Classification::findOrFail($classificationId);
|
||||
$viewData['fromClassification'] = true;
|
||||
}else{
|
||||
} else {
|
||||
$viewData['classifications'] = Classification::all();
|
||||
}
|
||||
|
||||
return view('dashboard.sub-classifications.create', $viewData);
|
||||
}
|
||||
|
||||
public function store(SubClassificationRequest $request){
|
||||
public function store(SubClassificationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
->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){
|
||||
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()
|
||||
'classifications' => Classification::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(SubClassificationRequest $request, $id){
|
||||
public function update(SubClassificationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah sub klasifikasi.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$subClassification = SubClassification::with(['classification'])->withTrashed()->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.sub-classifications.show', [
|
||||
@ -87,7 +91,8 @@ public function show($id){
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$subClassification = SubClassification::findOrFail(decrypt_id($id));
|
||||
$subClassification->delete();
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
use App\Models\Location;
|
||||
use App\Models\SubLocation;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SubLocationController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Data Sub Lokus',
|
||||
@ -23,61 +22,66 @@ public function index(Request $request){
|
||||
return view('dashboard.sub-locations.index', $viewData);
|
||||
}
|
||||
|
||||
public function create(Request $request){
|
||||
public function create(Request $request)
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'title' => 'Buat Sub Lokus Baru',
|
||||
'fromLocation' => false
|
||||
'fromLocation' => false,
|
||||
];
|
||||
|
||||
if($request->has('location')){
|
||||
if ($request->has('location')) {
|
||||
$locationId = decrypt_id($request->query('location'));
|
||||
$viewData['location'] = Location::findOrFail($locationId);
|
||||
$viewData['fromLocation'] = true;
|
||||
}else{
|
||||
} else {
|
||||
$viewData['locations'] = Location::all();
|
||||
}
|
||||
|
||||
return view('dashboard.sub-locations.create', $viewData);
|
||||
}
|
||||
|
||||
public function store(SubLocationRequest $request){
|
||||
public function store(SubLocationRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
->with('new_data', encrypt_id($createdSubLocation->id));
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan sub lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
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()
|
||||
'locations' => Location::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(SubLocationRequest $request, $id){
|
||||
public function update(SubLocationRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
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){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah sub lokus.');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
public function show($id)
|
||||
{
|
||||
$subLocation = SubLocation::with(['location'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.sub-locations.show', [
|
||||
@ -86,7 +90,8 @@ public function show($id){
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$subLocation = SubLocation::findOrFail(decrypt_id($id));
|
||||
$subLocation->delete();
|
||||
|
||||
@ -17,7 +17,8 @@
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('dashboard.users.index', [
|
||||
'title' => 'Data Pengguna',
|
||||
'role' => $request->input('role', null),
|
||||
@ -25,19 +26,21 @@ public function index(Request $request){
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
return view('dashboard.users.create', [
|
||||
'title' => 'Buat Pengguna Baru',
|
||||
'roles' => Role::all()
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(UserRequest $request){
|
||||
public function store(UserRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
User::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat pengguna baru.');
|
||||
}
|
||||
|
||||
@ -45,30 +48,33 @@ public function store(UserRequest $request){
|
||||
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
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()
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(UserRequest $request, $id){
|
||||
public function update(UserRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$user = User::findOrFail(decrypt_id($id));
|
||||
$user->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
} 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){
|
||||
public function show($id, $type)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
@ -76,7 +82,7 @@ public function show($id, $type){
|
||||
'user' => $user,
|
||||
'roles' => Role::all(),
|
||||
'page' => 'show-user',
|
||||
'type' => $type
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
@ -85,6 +91,7 @@ public function show($id, $type){
|
||||
|
||||
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':
|
||||
@ -102,24 +109,26 @@ public function show($id, $type){
|
||||
|
||||
}
|
||||
|
||||
public function resetPassword($id){
|
||||
public function resetPassword($id)
|
||||
{
|
||||
$user = User::with(['role'])->findOrFail(decrypt_id($id));
|
||||
|
||||
return view('dashboard.users.reset-password',[
|
||||
return view('dashboard.users.reset-password', [
|
||||
'title' => 'Reset Password',
|
||||
'page' => 'reset',
|
||||
'user' => $user
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetPasswordAction(ResetPasswordRequest $request, $id){
|
||||
public function resetPasswordAction(ResetPasswordRequest $request, $id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
User::findOrFail(decrypt_id($id))->update([
|
||||
'password' => $validatedData['password']
|
||||
'password' => $validatedData['password'],
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mereset password pengguna.');
|
||||
}
|
||||
|
||||
@ -157,14 +166,15 @@ public function destroy($id)
|
||||
}
|
||||
}
|
||||
|
||||
public function profile($type){
|
||||
public function profile($type)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => 'Detail Akun',
|
||||
'user' => Auth::user(),
|
||||
'roles' => Role::all(),
|
||||
'page' => 'profile',
|
||||
'type' => $type
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
switch ($type) {
|
||||
@ -175,6 +185,7 @@ public function profile($type){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', Auth::user()->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
@ -191,7 +202,8 @@ public function profile($type){
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
public function filter(Request $request)
|
||||
{
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
@ -202,7 +214,8 @@ public function filter(Request $request){
|
||||
return redirect()->route('dashboard.users.index', $filterField);
|
||||
}
|
||||
|
||||
public function process($id, $type, $process){
|
||||
public function process($id, $type, $process)
|
||||
{
|
||||
$user = User::with(['role', 'company.media.journalists'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$data = [
|
||||
@ -222,6 +235,7 @@ public function process($id, $type, $process){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
@ -239,20 +253,21 @@ public function process($id, $type, $process){
|
||||
|
||||
}
|
||||
|
||||
public function statusAction(Request $request, $id, $action){
|
||||
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'){
|
||||
try {
|
||||
if ($user->status === '0' && Auth::check() && is_role(['1'])) {
|
||||
if ($action == 'accept') {
|
||||
$user->update([
|
||||
'status' => '1'
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'accepted'));
|
||||
|
||||
return response()->json(['message' => 'Berhasil menyetujui pengguna.']);
|
||||
}else if($action == 'reject'){
|
||||
} elseif ($action == 'reject') {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
@ -261,11 +276,11 @@ public function statusAction(Request $request, $id, $action){
|
||||
]);
|
||||
|
||||
$user->update([
|
||||
'status' => '3'
|
||||
'status' => '3',
|
||||
]);
|
||||
|
||||
$user->company->update([
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'rejected', strip_tags($validatedData['rejection_reason'])));
|
||||
@ -274,13 +289,14 @@ public function statusAction(Request $request, $id, $action){
|
||||
}
|
||||
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setting(){
|
||||
public function setting()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
return view('dashboard.users.setting', [
|
||||
@ -289,45 +305,47 @@ public function setting(){
|
||||
]);
|
||||
}
|
||||
|
||||
public function settingAction(AccountSettingRequest $request){
|
||||
public function settingAction(AccountSettingRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$user->update([
|
||||
'name' => $validatedData['name'],
|
||||
'email' => $validatedData['email'],
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
} 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(){
|
||||
public function changePassword()
|
||||
{
|
||||
$user = User::with(['role'])->findOrFail(Auth::id());
|
||||
|
||||
return view('dashboard.users.reset-password',[
|
||||
return view('dashboard.users.reset-password', [
|
||||
'title' => 'Ubah Password',
|
||||
'page' => 'change',
|
||||
'user' => $user
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
public function changePasswordAction(ChangePasswordRequest $request){
|
||||
public function changePasswordAction(ChangePasswordRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
try {
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$user->update([
|
||||
'password' => $validatedData['password']
|
||||
'password' => $validatedData['password'],
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah password.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.users.setting')->with('success-status', 'Berhasil mengubah password.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ class HomepageController extends Controller
|
||||
|
||||
protected $totalVisitor;
|
||||
|
||||
public function __construct(){
|
||||
public function __construct()
|
||||
{
|
||||
$today = Carbon::today();
|
||||
$yesterday = Carbon::yesterday();
|
||||
$thisMonth = Carbon::now()->startOfMonth();
|
||||
@ -53,31 +54,33 @@ public function __construct(){
|
||||
View::share('totalVisitor', $this->totalVisitor);
|
||||
}
|
||||
|
||||
public function landing(){
|
||||
public function landing()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Beranda',
|
||||
'page' => 'landing',
|
||||
'news' => News::whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])
|
||||
->where('category', '=', '0')
|
||||
->latest()
|
||||
->get(),
|
||||
->where('category', '=', '0')
|
||||
->latest()
|
||||
->get(),
|
||||
'announcements' => News::whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])
|
||||
->where('category', '=', '1')
|
||||
->latest()
|
||||
->get(),
|
||||
->where('category', '=', '1')
|
||||
->latest()
|
||||
->get(),
|
||||
];
|
||||
|
||||
return view('homepage.index', $data);
|
||||
}
|
||||
|
||||
public function search(Request $request){
|
||||
public function search(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'search' => 'nullable|string|max:255|regex:/^[a-zA-Z0-9\s]+$/'
|
||||
'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.regex' => 'Pencarian hanya boleh mengandung huruf, angka, dan spasi.',
|
||||
]);
|
||||
|
||||
$search = trim($request->input('search'));
|
||||
@ -87,18 +90,19 @@ public function search(Request $request){
|
||||
'page' => 'search',
|
||||
'data' => News::query()
|
||||
->when($search, function ($query, $search) {
|
||||
return $query->where('title', 'LIKE', '%' . $search . '%');
|
||||
return $query->where('title', 'LIKE', '%'.$search.'%');
|
||||
})
|
||||
->latest()
|
||||
->simplePaginate(12)
|
||||
->appends(['search' => $search]),
|
||||
'search' => $search
|
||||
'search' => $search,
|
||||
];
|
||||
|
||||
return view('homepage.search', $data);
|
||||
}
|
||||
|
||||
public function news(Request $request){
|
||||
public function news(Request $request)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => 'Berita',
|
||||
@ -107,19 +111,20 @@ public function news(Request $request){
|
||||
|
||||
$search = $request->input('search', null);
|
||||
|
||||
if($search){
|
||||
if ($search) {
|
||||
$data['news'] = News::where('title', 'LIKE', "%{$search}%")
|
||||
->where('category', '0')
|
||||
->latest()
|
||||
->simplePaginate(12);
|
||||
}else{
|
||||
->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){
|
||||
public function readNews($slug)
|
||||
{
|
||||
$news = News::where('slug', $slug)->first();
|
||||
$news->increment('views', 1);
|
||||
|
||||
@ -128,14 +133,15 @@ public function readNews($slug){
|
||||
'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()
|
||||
'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){
|
||||
public function announcement(Request $request)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => 'Pengumuman',
|
||||
@ -144,19 +150,20 @@ public function announcement(Request $request){
|
||||
|
||||
$search = $request->input('search', null);
|
||||
|
||||
if($search){
|
||||
if ($search) {
|
||||
$data['announcements'] = News::where('category', '1')->where('title', 'LIKE', "%{$search}%")
|
||||
// ->orWhere('content', 'LIKE', "%{$search}%")
|
||||
->latest()
|
||||
->simplePaginate(6);
|
||||
}else{
|
||||
->latest()
|
||||
->simplePaginate(6);
|
||||
} else {
|
||||
$data['announcements'] = News::where('category', '1')->latest()->simplePaginate(6);
|
||||
}
|
||||
|
||||
return view('homepage.announcements.index', $data);
|
||||
}
|
||||
|
||||
public function readAnnouncement($slug){
|
||||
public function readAnnouncement($slug)
|
||||
{
|
||||
$announcement = News::where('slug', $slug)->first();
|
||||
$announcement->increment('views', 1);
|
||||
|
||||
@ -164,45 +171,49 @@ public function readAnnouncement($slug){
|
||||
'title' => 'Pengumuman',
|
||||
'page' => 'announcements',
|
||||
'announcement' => $announcement,
|
||||
'otherAnnouncements' => News::where('category', '1')->orderByDesc('id')->where('id', '!=', $announcement->id)->take(4)->get()
|
||||
'otherAnnouncements' => News::where('category', '1')->orderByDesc('id')->where('id', '!=', $announcement->id)->take(4)->get(),
|
||||
];
|
||||
|
||||
return view('homepage.announcements.read', $data);
|
||||
|
||||
}
|
||||
|
||||
public function aboutUs(){
|
||||
public function aboutUs()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Tentang Kami',
|
||||
'page' => 'about_us'
|
||||
'page' => 'about_us',
|
||||
];
|
||||
|
||||
return view('homepage.about-us.index', $data);
|
||||
}
|
||||
|
||||
public function contact(){
|
||||
public function contact()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Kontak',
|
||||
'page' => 'contacts'
|
||||
'page' => 'contacts',
|
||||
];
|
||||
|
||||
return view('homepage.contacts.index', $data);
|
||||
}
|
||||
|
||||
public function receiveMessage(ReceiveMessageContactRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
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";
|
||||
if ($createdMessage) {
|
||||
return 'Berhasil mengirim pesan';
|
||||
} else {
|
||||
return 'Gagal mengirim pesan';
|
||||
}
|
||||
}
|
||||
|
||||
public function customError($code){
|
||||
public function customError($code)
|
||||
{
|
||||
abort($code);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
@ -20,8 +18,8 @@ class AnnouncementMiddleware
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if(Auth::check() && Auth::user()->role_id == 3){
|
||||
$user = User::with(['announcements' => function($query) {
|
||||
if (Auth::check() && Auth::user()->role_id == 3) {
|
||||
$user = User::with(['announcements' => function ($query) {
|
||||
$query->orderBy('id', 'desc');
|
||||
}])->find(Auth::user()->id);
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class AuthenticatedMiddleware
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
|
||||
if(Auth::check()){
|
||||
if (Auth::check()) {
|
||||
return redirect()->route('dashboard.overview');
|
||||
}
|
||||
|
||||
|
||||
@ -16,11 +16,11 @@ class RoleMiddleware
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$roles): Response
|
||||
{
|
||||
if (!Auth::check()) {
|
||||
if (! Auth::check()) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
if (!in_array(Auth::user()->role_id, $roles)) {
|
||||
if (! in_array(Auth::user()->role_id, $roles)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
use App\Models\Visitor;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Dotenv\Util\Str;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@ -46,7 +45,7 @@ public function messages(): array
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'slug' => filled($this->name) && filled($this->year) ? \Illuminate\Support\Str::slug($this->name. ' '. $this->year) : null,
|
||||
'slug' => filled($this->name) && filled($this->year) ? \Illuminate\Support\Str::slug($this->name.' '.$this->year) : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -26,13 +26,13 @@ public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' => ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
'my_password' => ['required', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols(), new MatchCurrentPasswordRule()],
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols(), new MatchCurrentPasswordRule],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ClassificationRequest extends FormRequest
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ class ContentRecapRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1','2']);
|
||||
return Auth::check() && is_role(['1', '2']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,7 +25,7 @@ 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'],
|
||||
'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'],
|
||||
@ -34,9 +34,9 @@ public function rules(): array
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['image'] = ['required', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}else if($this->isMethod('put')){
|
||||
} elseif ($this->isMethod('put')) {
|
||||
$rules['image'] = ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}
|
||||
|
||||
@ -73,6 +73,4 @@ public function messages()
|
||||
'description.nullable' => 'Deskripsi bersifat opsional.',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -61,5 +61,4 @@ public function messages(): array
|
||||
'other_document.max' => 'Ukuran dokumen lainnya tidak boleh lebih dari 2MB.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ public function authorize(): bool
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
$rules = [
|
||||
'name' => ['required'],
|
||||
'start_date' => ['required', 'date'],
|
||||
'end_date' => ['required', 'date'],
|
||||
@ -33,10 +33,10 @@ public function rules(): array
|
||||
'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'];
|
||||
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;
|
||||
@ -75,5 +75,4 @@ public function messages(): array
|
||||
'description.required' => 'Deskripsi kerja sama wajib diisi.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class IssueManagementRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1','2']);
|
||||
return Auth::check() && is_role(['1', '2']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,14 +27,15 @@ public function rules(): array
|
||||
'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'],
|
||||
'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([
|
||||
@ -67,5 +68,4 @@ public function messages()
|
||||
'government_agencies.*.exists' => 'Agensi pemerintah yang dipilih tidak valid.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,12 +26,12 @@ public function rules(): array
|
||||
'journalist_ids' => ['required', 'array'],
|
||||
'journalist_ids.*' => ['required', 'exists:journalists,id'],
|
||||
'e_catalog' => ['nullable'],
|
||||
'description' => ['nullable']
|
||||
'description' => ['nullable'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['attachment'] = ['required', 'file', 'mimes:pdf', 'max:2048'];
|
||||
}else{
|
||||
} else {
|
||||
$rules['attachment'] = ['nullable', 'file', 'mimes:pdf', 'max:2048'];
|
||||
}
|
||||
|
||||
@ -53,7 +53,4 @@ public function messages(): array
|
||||
'description.nullable' => 'Deskripsi boleh kosong.',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ class LoginRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return !Auth::check();
|
||||
return ! Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -12,7 +12,7 @@ class MediaMonitoringRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check() && is_role(['1','2']);
|
||||
return Auth::check() && is_role(['1', '2']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ public function rules(): array
|
||||
'link' => ['nullable', 'url'],
|
||||
'news_page' => ['nullable'],
|
||||
'writter' => ['required', 'max:100'],
|
||||
'channel'=> ['required', 'in:website,tiktok,youtube,instagram,facebook,twitter,cetak'],
|
||||
'channel' => ['required', 'in:website,tiktok,youtube,instagram,facebook,twitter,cetak'],
|
||||
'content' => ['required'],
|
||||
'influencer' => ['nullable', 'max:100'],
|
||||
'keyword' => ['required', 'max:100'],
|
||||
@ -38,9 +38,9 @@ public function rules(): array
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['image'] = ['required', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}else if($this->isMethod('put')){
|
||||
} elseif ($this->isMethod('put')) {
|
||||
$rules['image'] = ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}
|
||||
|
||||
@ -92,6 +92,4 @@ public function messages()
|
||||
'image.max' => 'Ukuran gambar tidak boleh lebih dari 2MB.',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'title' => ['required' , 'max:200'],
|
||||
'title' => ['required', 'max:200'],
|
||||
'content' => ['required'],
|
||||
'link' => ['nullable', 'url'],
|
||||
'tag' => ['nullable'],
|
||||
|
||||
@ -34,7 +34,8 @@ public function rules(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function prepareForValidation(){
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
@ -66,5 +67,4 @@ public function messages(): array
|
||||
'task_description.required' => 'Deskripsi tugas harus diisi.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ReceiveMessageContactRequest extends FormRequest
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ class RegisterRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return !Auth::check();
|
||||
return ! Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -29,9 +29,9 @@ public function rules(): array
|
||||
'description' => ['nullable'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['proof'] = ['required', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}else{
|
||||
} else {
|
||||
$rules['proof'] = ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'];
|
||||
}
|
||||
|
||||
@ -52,5 +52,4 @@ public function messages(): array
|
||||
'proof.max' => 'Ukuran gambar tidak boleh lebih dari 2MB.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,13 +26,13 @@ public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' => ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()],
|
||||
'my_password' => ['required', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols(), new MatchCurrentPasswordRule()],
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols(), new MatchCurrentPasswordRule],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,5 +54,4 @@ public function messages()
|
||||
'my_password.symbols' => 'Password Anda harus mengandung simbol.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -60,5 +60,4 @@ protected function prepareForValidation()
|
||||
'contact_telegram' => filled($this->contact_telegram) ? $this->contact_telegram : null,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -51,5 +51,4 @@ protected function prepareForValidation()
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\MatchCurrentPasswordRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
@ -30,26 +29,26 @@ public function rules(): array
|
||||
'status' => ['required', 'in:1,2', 'not_in:select'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
if ($this->isMethod('post')) {
|
||||
$rules['email'] = ['required', 'email', 'max:100', 'unique:users,email'];
|
||||
$rules['password'] = ['required', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
}else if($this->isMethod('put')){
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
} elseif ($this->isMethod('put')) {
|
||||
$rules['email'] = ['required', 'email', 'max:100'];
|
||||
$rules['password'] = ['nullable', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
||||
public function prepareForValidation(){
|
||||
if (!filled(trim($this->password))) {
|
||||
public function prepareForValidation()
|
||||
{
|
||||
if (! filled(trim($this->password))) {
|
||||
$this->request->remove('password');
|
||||
}
|
||||
}
|
||||
@ -78,5 +77,4 @@ public function messages()
|
||||
'password.symbols' => 'Password harus mengandung simbol.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
use App\Models\LoginHistory;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class LogUserLogin
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
@ -17,7 +16,9 @@ class AccountVerification extends Mailable
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public $status;
|
||||
|
||||
public $reason;
|
||||
|
||||
public $user;
|
||||
|
||||
public function __construct($user, $status, $rejectionReason = null)
|
||||
|
||||
@ -4,12 +4,13 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class AiringProofTheme extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'airing_proof_themes';
|
||||
|
||||
protected $fillable = [
|
||||
@ -17,10 +18,11 @@ class AiringProofTheme extends Model
|
||||
'slug',
|
||||
'year',
|
||||
'description',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
@ -34,7 +36,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -3,12 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Announcement extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'announcements';
|
||||
|
||||
protected $fillable = [
|
||||
@ -16,19 +17,20 @@ class Announcement extends Model
|
||||
'content',
|
||||
'link',
|
||||
'attachment',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function enhancer(){
|
||||
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();
|
||||
->using(AnnouncementUser::class)
|
||||
->withPivot(['status', 'category'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
@ -41,7 +43,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class AnnouncementUser extends Pivot
|
||||
@ -13,14 +12,16 @@ class AnnouncementUser extends Pivot
|
||||
'announcement_id',
|
||||
'user_id',
|
||||
'status',
|
||||
'category'
|
||||
'category',
|
||||
];
|
||||
|
||||
public function announcement(){
|
||||
public function announcement()
|
||||
{
|
||||
return $this->belongsTo(Announcement::class, 'announcement_id', 'id');
|
||||
}
|
||||
|
||||
public function user(){
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,30 +4,34 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Classification extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'classifications';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'description',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function subClassifications(){
|
||||
public function subClassifications()
|
||||
{
|
||||
return $this->hasMany(SubClassification::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function issues(){
|
||||
public function issues()
|
||||
{
|
||||
return $this->hasMany(IssueManagement::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
@ -41,7 +45,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
@ -55,5 +59,4 @@ public function getDescriptionForEvent(string $eventName): string
|
||||
|
||||
return "Klasifikasi '{$this->name}' telah {$eventName}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
class Company extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $fillable = [
|
||||
@ -39,14 +40,16 @@ class Company extends Model
|
||||
'edit_rejection_reason',
|
||||
'validated_at',
|
||||
'rejection_reason',
|
||||
'user_id'
|
||||
'user_id',
|
||||
];
|
||||
|
||||
public function user(){
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->hasOne(Media::class, 'company_id', 'id')->withTrashed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,12 +4,13 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class ContentRecap extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'content_recaps';
|
||||
|
||||
protected $fillable = [
|
||||
@ -30,7 +31,8 @@ public function enhancer()
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function classification(){
|
||||
public function classification()
|
||||
{
|
||||
return $this->belongsTo(ContentRecapClassification::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
@ -47,14 +49,14 @@ public function getActivitylogOptions(): LogOptions
|
||||
'image',
|
||||
'content_type',
|
||||
'description',
|
||||
'enhancer_id',]) // kolom yang dicatat
|
||||
'enhancer_id', ]) // kolom yang dicatat
|
||||
->useLogName('content_recap') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -4,12 +4,13 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class ContentRecapClassification extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'content_recap_classifications';
|
||||
|
||||
protected $fillable = [
|
||||
@ -17,14 +18,16 @@ class ContentRecapClassification extends Model
|
||||
'slug',
|
||||
'year',
|
||||
'description',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function contentRecaps(){
|
||||
public function contentRecaps()
|
||||
{
|
||||
return $this->hasMany(ContentRecap::class, 'classification_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
@ -38,7 +41,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Cooperation extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'cooperations';
|
||||
|
||||
@ -26,16 +26,18 @@ class Cooperation extends Model
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsToMany(Media::class, 'media_cooperations', 'cooperation_id', 'media_id')
|
||||
->using(MediaCooperation::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
->using(MediaCooperation::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function proposals(){
|
||||
public function proposals()
|
||||
{
|
||||
return $this->hasMany(CooperationProposal::class, 'cooperation_id', 'id');
|
||||
}
|
||||
|
||||
public function mediaOrder(){
|
||||
public function mediaOrder()
|
||||
{
|
||||
return $this->hasOne(Order::class, 'cooperation_id', 'id');
|
||||
}
|
||||
|
||||
@ -57,7 +59,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -3,12 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class CooperationCompletion extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'cooperation_completions';
|
||||
|
||||
protected $fillable = [
|
||||
@ -24,11 +25,13 @@ class CooperationCompletion extends Model
|
||||
'order_id',
|
||||
];
|
||||
|
||||
public function order(){
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
|
||||
@ -53,7 +56,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class CooperationProposal extends Model
|
||||
{
|
||||
@ -23,19 +22,21 @@ class CooperationProposal extends Model
|
||||
'media_id',
|
||||
];
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
|
||||
public function cooperation(){
|
||||
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();
|
||||
->using(JournalistCooperationProposal::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
@ -56,7 +57,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class GovernmentAgency extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'government_agencies';
|
||||
|
||||
@ -24,11 +24,12 @@ class GovernmentAgency extends Model
|
||||
public function issues()
|
||||
{
|
||||
return $this->belongsToMany(IssueManagement::class, 'issue_managements_government_agencies', 'government_agency_id', 'issue_management_id')
|
||||
->using(IssueManagementGovernmentAgency::class)
|
||||
->withTimestamps();
|
||||
->using(IssueManagementGovernmentAgency::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -3,14 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Model\Pivot;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class IssueManagement extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'issue_managements';
|
||||
|
||||
@ -26,31 +25,40 @@ class IssueManagement extends Model
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function location(){
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(Location::class, 'location_id', 'id');
|
||||
}
|
||||
public function subLocation(){
|
||||
|
||||
public function subLocation()
|
||||
{
|
||||
return $this->belongsTo(SubLocation::class, 'sub_location_id', 'id');
|
||||
}
|
||||
public function classification(){
|
||||
|
||||
public function classification()
|
||||
{
|
||||
return $this->belongsTo(Classification::class, 'classification_id', 'id');
|
||||
}
|
||||
public function subClassification(){
|
||||
|
||||
public function subClassification()
|
||||
{
|
||||
return $this->belongsTo(SubClassification::class, 'sub_classification_id', 'id');
|
||||
}
|
||||
|
||||
public function mediaMonitoring(){
|
||||
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();
|
||||
->using(IssueManagementGovernmentAgency::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
@ -74,7 +82,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
@ -88,5 +96,4 @@ public function getDescriptionForEvent(string $eventName): string
|
||||
|
||||
return "Manajemen Isu telah {$eventName}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class IssueManagementGovernmentAgency extends Pivot
|
||||
@ -14,12 +13,13 @@ class IssueManagementGovernmentAgency extends Pivot
|
||||
'government_agency_id',
|
||||
];
|
||||
|
||||
public function issueManagement(){
|
||||
public function issueManagement()
|
||||
{
|
||||
return $this->belongsTo(IssueManagement::class, 'issue_management_id', 'id');
|
||||
}
|
||||
|
||||
public function GovernmentAgency(){
|
||||
public function GovernmentAgency()
|
||||
{
|
||||
return $this->belongsTo(GovernmentAgency::class, 'government_agency_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -24,17 +24,18 @@ class Journalist extends Model
|
||||
'edit_description',
|
||||
'edit_status',
|
||||
'edit_rejection_reason',
|
||||
'media_id'
|
||||
'media_id',
|
||||
];
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function cooperationProposals()
|
||||
{
|
||||
return $this->belongsToMany(CooperationProposal::class, 'journalists_cooperation_proposals', 'journalist_id', 'cooperation_proposal_id')
|
||||
->using(JournalistCooperationProposal::class)
|
||||
->withTimestamps();
|
||||
->using(JournalistCooperationProposal::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class JournalistCooperationProposal extends Pivot
|
||||
@ -14,11 +13,13 @@ class JournalistCooperationProposal extends Pivot
|
||||
'cooperation_proposal_id',
|
||||
];
|
||||
|
||||
public function journalist(){
|
||||
public function journalist()
|
||||
{
|
||||
return $this->belongsTo(Journalist::class, 'journalists_id', 'id');
|
||||
}
|
||||
|
||||
public function cooperationProposal(){
|
||||
public function cooperationProposal()
|
||||
{
|
||||
return $this->belongsTo(CooperationProposal::class, 'cooperation_proposal_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
class OldJournalist extends Model
|
||||
{
|
||||
protected $connection = 'legacy';
|
||||
protected $connection = 'legacy';
|
||||
|
||||
protected $table = 'journalists';
|
||||
protected $table = 'journalists';
|
||||
}
|
||||
|
||||
@ -3,44 +3,48 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Location extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'locations';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'description',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function subLocations(){
|
||||
public function subLocations()
|
||||
{
|
||||
return $this->hasMany(SubLocation::class, 'location_id', 'id');
|
||||
}
|
||||
|
||||
public function issues(){
|
||||
public function issues()
|
||||
{
|
||||
return $this->hasMany(IssueManagement::class, 'location_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
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
|
||||
->logOnly(['name', 'status', 'description', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('location') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -12,10 +12,11 @@ class LoginHistory extends Model
|
||||
'user_id',
|
||||
'ip_address',
|
||||
'user_agent',
|
||||
'logged_in_at'
|
||||
'logged_in_at',
|
||||
];
|
||||
|
||||
public function user(){
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ class Media extends Model
|
||||
'edit_description',
|
||||
'edit_status',
|
||||
'edit_rejection_reason',
|
||||
'company_id'
|
||||
'company_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
@ -39,36 +39,39 @@ public function user()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function company(){
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class, 'company_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function journalists(){
|
||||
public function journalists()
|
||||
{
|
||||
return $this->hasMany(Journalist::class, 'media_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function cooperations()
|
||||
{
|
||||
return $this->belongsToMany(Cooperation::class, 'media_cooperations', 'media_id', 'cooperation_id')
|
||||
->using(MediaCooperation::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
->using(MediaCooperation::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function orders()
|
||||
{
|
||||
return $this->belongsToMany(Order::class, 'media_orders', 'media_id', 'order_id')
|
||||
->using(MediaOrder::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
->using(MediaOrder::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function reports(){
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasMany(Report::class, 'media_id', 'id');
|
||||
}
|
||||
|
||||
public function completions(){
|
||||
public function completions()
|
||||
{
|
||||
return $this->hasMany(CooperationCompletion::class, 'order_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class MediaCooperation extends Pivot
|
||||
@ -13,14 +12,16 @@ class MediaCooperation extends Pivot
|
||||
'cooperation_id',
|
||||
'media_id',
|
||||
'status',
|
||||
'rejection_reason'
|
||||
'rejection_reason',
|
||||
];
|
||||
|
||||
public function cooperation(){
|
||||
public function cooperation()
|
||||
{
|
||||
return $this->belongsTo(Cooperation::class, 'cooperation_id', 'id');
|
||||
}
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class MediaMonitoring extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'media_monitorings';
|
||||
|
||||
@ -31,7 +31,8 @@ class MediaMonitoring extends Model
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function issue(){
|
||||
public function issue()
|
||||
{
|
||||
return $this->hasOne(IssueManagement::class, 'media_monitoring_id', 'id');
|
||||
}
|
||||
|
||||
@ -66,7 +67,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
@ -80,5 +81,4 @@ public function getDescriptionForEvent(string $eventName): string
|
||||
|
||||
return "Monitoring Media '{$this->title}' telah {$eventName}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class MediaOrder extends Pivot
|
||||
@ -13,14 +12,16 @@ class MediaOrder extends Pivot
|
||||
'order_id',
|
||||
'media_id',
|
||||
'status',
|
||||
'rejection_reason'
|
||||
'rejection_reason',
|
||||
];
|
||||
|
||||
public function order(){
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,13 +4,14 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class News extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
protected $table = 'news';
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'news';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
@ -21,10 +22,11 @@ class News extends Model
|
||||
'tag',
|
||||
'category',
|
||||
'views',
|
||||
'author_id'
|
||||
'author_id',
|
||||
];
|
||||
|
||||
public function author(){
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'author_id', 'id');
|
||||
}
|
||||
|
||||
@ -38,7 +40,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
@ -50,9 +52,9 @@ public function getDescriptionForEvent(string $eventName): string
|
||||
break;
|
||||
}
|
||||
|
||||
if($this->category == '0'){
|
||||
if ($this->category == '0') {
|
||||
return "Berita '{$this->title}' telah {$eventName}";
|
||||
}else{
|
||||
} else {
|
||||
return "Pengumuman '{$this->title}' telah {$eventName}";
|
||||
}
|
||||
|
||||
|
||||
@ -4,13 +4,12 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'orders';
|
||||
|
||||
@ -27,20 +26,23 @@ class Order extends Model
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsToMany(Media::class, 'media_orders', 'order_id', 'media_id')
|
||||
->using(MediaOrder::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
->using(MediaOrder::class)
|
||||
->withPivot(['status', 'rejection_reason'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function cooperation(){
|
||||
public function cooperation()
|
||||
{
|
||||
return $this->belongsTo(Cooperation::class, 'cooperation_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function reports(){
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasMany(Report::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function completions(){
|
||||
public function completions()
|
||||
{
|
||||
return $this->hasMany(CooperationCompletion::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Report extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'reports';
|
||||
|
||||
@ -25,11 +25,13 @@ class Report extends Model
|
||||
'order_id',
|
||||
];
|
||||
|
||||
public function order(){
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function media(){
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'media_id', 'id');
|
||||
}
|
||||
|
||||
@ -53,7 +55,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -3,20 +3,22 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
protected $table = 'user_roles';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description'
|
||||
'description',
|
||||
];
|
||||
|
||||
public function user(){
|
||||
public function user()
|
||||
{
|
||||
return $this->hasMany(User::class, 'role_id', 'id');
|
||||
}
|
||||
|
||||
@ -25,7 +27,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
return LogOptions::defaults()
|
||||
->logOnly([
|
||||
'name',
|
||||
'description'
|
||||
'description',
|
||||
]) // kolom yang dicatat
|
||||
->useLogName('user_role') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
@ -33,7 +35,7 @@ public function getActivitylogOptions(): LogOptions
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class SubClassification extends Model
|
||||
{
|
||||
use SoftDeletes, LogsActivity;
|
||||
use LogsActivity, SoftDeletes;
|
||||
|
||||
protected $table = 'sub_classifications';
|
||||
|
||||
@ -18,32 +18,35 @@ class SubClassification extends Model
|
||||
'status',
|
||||
'description',
|
||||
'classification_id',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function classification(){
|
||||
public function classification()
|
||||
{
|
||||
return $this->belongsTo(Classification::class, 'classification_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function issues(){
|
||||
public function issues()
|
||||
{
|
||||
return $this->hasMany(IssueManagement::class, 'sub_classification_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([ 'name', 'status', 'description', 'classification_id', 'enhancer_id']) // kolom yang dicatat
|
||||
->logOnly(['name', 'status', 'description', 'classification_id', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('sub_classification') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class SubLocation extends Model
|
||||
{
|
||||
@ -17,32 +17,35 @@ class SubLocation extends Model
|
||||
'status',
|
||||
'description',
|
||||
'location_id',
|
||||
'enhancer_id'
|
||||
'enhancer_id',
|
||||
];
|
||||
|
||||
public function location(){
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(Location::class, 'location_id', 'id');
|
||||
}
|
||||
|
||||
public function issues(){
|
||||
public function issues()
|
||||
{
|
||||
return $this->hasMany(IssueManagement::class, 'sub_location_id', 'id');
|
||||
}
|
||||
|
||||
public function enhancer(){
|
||||
public function enhancer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly([ 'name', 'status', 'description', 'location_id', 'enhancer_id']) // kolom yang dicatat
|
||||
->logOnly(['name', 'status', 'description', 'location_id', 'enhancer_id']) // kolom yang dicatat
|
||||
->useLogName('sub_location') // nama log
|
||||
->logOnlyDirty(); // hanya log kalau ada perubahan
|
||||
}
|
||||
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
switch($eventName){
|
||||
switch ($eventName) {
|
||||
case 'created':
|
||||
$eventName = 'dibuat';
|
||||
break;
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@ -25,7 +23,7 @@ class User extends Authenticatable
|
||||
'email',
|
||||
'password',
|
||||
'status',
|
||||
'role_id'
|
||||
'role_id',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -54,16 +52,18 @@ protected function casts(): array
|
||||
public function announcements()
|
||||
{
|
||||
return $this->belongsToMany(Announcement::class, 'announcements_users', 'user_id', 'announcement_id')
|
||||
->using(AnnouncementUser::class)
|
||||
->withPivot(['status', 'category'])
|
||||
->withTimestamps();
|
||||
->using(AnnouncementUser::class)
|
||||
->withPivot(['status', 'category'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function role(){
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id', 'id');
|
||||
}
|
||||
|
||||
public function company(){
|
||||
public function company()
|
||||
{
|
||||
return $this->hasOne(Company::class, 'user_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
@ -79,7 +79,8 @@ public function media()
|
||||
);
|
||||
}
|
||||
|
||||
public function loginHistories(){
|
||||
public function loginHistories()
|
||||
{
|
||||
return $this->hasMany(LoginHistory::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ class Visitor extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'date',
|
||||
'visitors'
|
||||
'visitors',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ class MatchCurrentPasswordRule implements ValidationRule
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
$user = User::find(Auth::id());
|
||||
if (!Hash::check($value, $user->password)) {
|
||||
if (! Hash::check($value, $user->password)) {
|
||||
$fail('Kata sandi saat ini tidak sesuai.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
use App\Http\Middleware\AuthenticatedMiddleware;
|
||||
use App\Http\Middleware\RoleMiddleware;
|
||||
use App\Http\Middleware\VisitorCounterMiddleware;
|
||||
use Illuminate\Auth\Middleware\Authenticate;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
@ -81,7 +81,6 @@
|
||||
]) : [],
|
||||
],
|
||||
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
|
||||
@ -15,153 +15,136 @@
|
||||
return [
|
||||
|
||||
/**
|
||||
*
|
||||
* The site key
|
||||
* get site key @ www.google.com/recaptcha/admin
|
||||
*
|
||||
*/
|
||||
'api_site_key' => env('RECAPTCHA_SITE_KEY', ''),
|
||||
'api_site_key' => env('RECAPTCHA_SITE_KEY', ''),
|
||||
|
||||
/**
|
||||
*
|
||||
* The secret key
|
||||
* get secret key @ www.google.com/recaptcha/admin
|
||||
*
|
||||
*/
|
||||
'api_secret_key' => env('RECAPTCHA_SECRET_KEY', ''),
|
||||
'api_secret_key' => env('RECAPTCHA_SECRET_KEY', ''),
|
||||
|
||||
/**
|
||||
*
|
||||
* ReCATCHA version
|
||||
* Supported: "v2", "invisible", "v3",
|
||||
*
|
||||
* get more info @ https://developers.google.com/recaptcha/docs/versions
|
||||
*
|
||||
*/
|
||||
'version' => 'v2',
|
||||
'version' => 'v2',
|
||||
|
||||
/**
|
||||
*
|
||||
* The curl timout in seconds to validate a recaptcha token
|
||||
* @since v3.5.0
|
||||
*
|
||||
* @since v3.5.0
|
||||
*/
|
||||
'curl_timeout' => 10,
|
||||
'curl_timeout' => 10,
|
||||
|
||||
/**
|
||||
*
|
||||
* IP addresses for which validation will be skipped
|
||||
* IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
|
||||
*
|
||||
*/
|
||||
'skip_ip' => env('RECAPTCHA_SKIP_IP', []),
|
||||
'skip_ip' => env('RECAPTCHA_SKIP_IP', []),
|
||||
|
||||
/**
|
||||
*
|
||||
* Default route called to check the Google reCAPTCHA token
|
||||
* @since v3.2.0
|
||||
*
|
||||
* @since v3.2.0
|
||||
*/
|
||||
'default_validation_route' => 'biscolab-recaptcha/validate',
|
||||
'default_validation_route' => 'biscolab-recaptcha/validate',
|
||||
|
||||
/**
|
||||
*
|
||||
* The name of the parameter used to send Google reCAPTCHA token to verify route
|
||||
* @since v3.2.0
|
||||
*
|
||||
* @since v3.2.0
|
||||
*/
|
||||
'default_token_parameter_name' => 'token',
|
||||
|
||||
/**
|
||||
*
|
||||
* The default Google reCAPTCHA language code
|
||||
* It has no effect with v3
|
||||
*
|
||||
* @see https://developers.google.com/recaptcha/docs/language
|
||||
* @since v3.6.0
|
||||
*
|
||||
*/
|
||||
'default_language' => null,
|
||||
'default_language' => null,
|
||||
|
||||
/**
|
||||
*
|
||||
* The default form ID. Only for "invisible" reCAPTCHA
|
||||
* @since v4.0.0
|
||||
*
|
||||
* @since v4.0.0
|
||||
*/
|
||||
'default_form_id' => 'biscolab-recaptcha-invisible-form',
|
||||
'default_form_id' => 'biscolab-recaptcha-invisible-form',
|
||||
|
||||
/**
|
||||
*
|
||||
* Deferring the render can be achieved by specifying your onload callback function and adding parameters to the JavaScript resource.
|
||||
* It has no effect with v3 and invisible
|
||||
*
|
||||
* @see https://developers.google.com/recaptcha/docs/display#explicit_render
|
||||
* @since v4.0.0
|
||||
* Supported true, false
|
||||
*
|
||||
*/
|
||||
'explicit' => false,
|
||||
'explicit' => false,
|
||||
|
||||
/**
|
||||
*
|
||||
* Set API domain. You can use "www.recaptcha.net" in case "www.google.com" is not accessible.
|
||||
* (no check will be made on the entered value)
|
||||
*
|
||||
* @see https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally
|
||||
* @since v4.3.0
|
||||
* Default 'www.google.com' (ReCaptchaBuilder::DEFAULT_RECAPTCHA_API_DOMAIN)
|
||||
*
|
||||
*/
|
||||
'api_domain' => 'www.google.com',
|
||||
'api_domain' => 'www.google.com',
|
||||
|
||||
/**
|
||||
*
|
||||
* Set `true` when the error message must be null
|
||||
*
|
||||
* @since v5.1.0
|
||||
* Default false
|
||||
*
|
||||
*/
|
||||
'empty_message' => false,
|
||||
|
||||
/**
|
||||
*
|
||||
* Set either the error message or the errom message translation key
|
||||
*
|
||||
* @since v5.1.0
|
||||
* Default 'validation.recaptcha'
|
||||
*
|
||||
*/
|
||||
'error_message_key' => 'validation.recaptcha',
|
||||
|
||||
/**
|
||||
*
|
||||
* g-recaptcha tag attributes and grecaptcha.render parameters (v2 only)
|
||||
*
|
||||
* @see https://developers.google.com/recaptcha/docs/display#render_param
|
||||
* @since v4.0.0
|
||||
*/
|
||||
'tag_attributes' => [
|
||||
'tag_attributes' => [
|
||||
|
||||
/**
|
||||
* The color theme of the widget.
|
||||
* Supported "light", "dark"
|
||||
*/
|
||||
'theme' => 'light',
|
||||
'theme' => 'light',
|
||||
|
||||
/**
|
||||
* The size of the widget.
|
||||
* Supported "normal", "compact"
|
||||
*/
|
||||
'size' => 'normal',
|
||||
'size' => 'normal',
|
||||
|
||||
/**
|
||||
* The tabindex of the widget and challenge.
|
||||
* If other elements in your page use tabindex, it should be set to make user navigation easier.
|
||||
*/
|
||||
'tabindex' => 0,
|
||||
'tabindex' => 0,
|
||||
|
||||
/**
|
||||
* The name of your callback function, executed when the user submits a successful response.
|
||||
* The g-recaptcha-response token is passed to your callback.
|
||||
* DO NOT SET "biscolabOnloadCallback"
|
||||
*/
|
||||
'callback' => null,
|
||||
'callback' => null,
|
||||
|
||||
/**
|
||||
* The name of your callback function, executed when the reCAPTCHA response expires and the user needs to re-verify.
|
||||
@ -174,6 +157,6 @@
|
||||
* If you specify a function here, you are responsible for informing the user that they should retry.
|
||||
* DO NOT SET "biscolabOnloadCallback"
|
||||
*/
|
||||
'error-callback' => null,
|
||||
]
|
||||
'error-callback' => null,
|
||||
],
|
||||
];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user