feat: filter data

feat: export data
This commit is contained in:
myuqinurrohman 2025-04-22 08:27:43 +07:00
parent a9278afa77
commit 04a464a2f9
9 changed files with 630 additions and 71 deletions

View File

@ -0,0 +1,151 @@
<?php
namespace App\Exports;
use App\Models\MediaMonitoring;
use Carbon\Carbon;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class MediaMonitoringExport implements FromCollection, WithHeadings, WithStyles, WithMapping
{
/**
* @return \Illuminate\Support\Collection
*/
protected $no = 1;
protected $news_title;
protected $channel;
protected $issue_status;
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, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date)
{
$this->news_title = $news_title;
$this->channel = $channel;
$this->issue_status = $issue_status;
$this->input_year = $input_year;
$this->input_month = $input_month;
$this->input_date = $input_date;
$this->release_year = $release_year;
$this->release_month = $release_month;
$this->release_date = $release_date;
}
public function collection()
{
$query = MediaMonitoring::with(['enhancer', 'issue']);
if($this->news_title){
$query->where('title', 'LIKE', '%'. $this->news_title.'%');
}
if($this->channel && $this->channel !== 'all'){
$query->where('channel', $this->channel);
}
if ($this->issue_status && $this->issue_status !== 'all') {
if ($this->issue_status === 'added') {
$query->whereHas('issue');
} elseif ($this->issue_status === 'not_added') {
$query->whereDoesntHave('issue');
}
}
if ($this->input_year) {
$query->whereYear('created_at', $this->input_year);
}
if ($this->input_month) {
$monthYear = Carbon::parse($this->input_month);
$query->whereYear('created_at', $monthYear->year)
->whereMonth('created_at', $monthYear->month);
}
if ($this->input_date) {
$query->whereDate('created_at', $this->input_date);
}
if ($this->release_year) {
$query->whereYear('release_date', $this->release_year);
}
if ($this->release_month) {
$monthYear = Carbon::parse($this->release_month);
$query->whereYear('release_date', $monthYear->year)
->whereMonth('release_date', $monthYear->month);
}
if ($this->release_date) {
$query->whereDate('release_date', $this->release_date);
}
return $query->get();
}
public function map($mediaMonitoring): array
{
return [
$this->no++,
$mediaMonitoring->code,
$mediaMonitoring->title,
$mediaMonitoring->media_name,
$mediaMonitoring->theme,
$mediaMonitoring->writter,
$mediaMonitoring->channel,
$mediaMonitoring->keyword,
$mediaMonitoring->influencer,
$mediaMonitoring->link,
$mediaMonitoring->news_page,
$mediaMonitoring->release_date,
$mediaMonitoring->issue ? 'Sudah Ditambahkan' : 'Belum Ditambahkan',
$mediaMonitoring->enhancer->name ?? 'Admin',
Carbon::parse($mediaMonitoring->created_at)->locale('id')->translatedFormat('l, d F Y'),
];
}
public function headings(): array
{
return [
['Data Rekap Konten', '', '', '', '', '', '', '', '', '', '', '', '', ''],
['NO', 'Kode', 'Judul Berita', 'Media', 'Tema', 'Penulis', 'Channel', 'Kata Kunci', 'Influencer', 'Link', 'Halaman Berita', 'Tanggal Rilis', 'Status Isu', 'Oleh',
'Tanggal Input']
];
}
public function styles(Worksheet $sheet)
{
$sheet->mergeCells('A1:N1'); // A1 sampai D1 digabung
// Set alignment untuk pusat horizontal dan vertikal
$sheet->getStyle('A1:N1')->getAlignment()->setHorizontal('center');
$sheet->getStyle('A1:N1')->getAlignment()->setVertical('center');
$sheet->getColumnDimension('A')->setWidth(7); // Set column A width
$sheet->getColumnDimension('B')->setAutoSize(true);
$sheet->getColumnDimension('C')->setAutoSize(true);
$sheet->getColumnDimension('D')->setAutoSize(true);
$sheet->getColumnDimension('E')->setAutoSize(true);
$sheet->getColumnDimension('F')->setAutoSize(true);
$sheet->getColumnDimension('G')->setAutoSize(true);
$sheet->getColumnDimension('H')->setAutoSize(true);
$sheet->getColumnDimension('I')->setAutoSize(true);
$sheet->getColumnDimension('J')->setAutoSize(true);
$sheet->getColumnDimension('K')->setAutoSize(true);
$sheet->getColumnDimension('L')->setAutoSize(true);
$sheet->getColumnDimension('M')->setAutoSize(true);
$sheet->getColumnDimension('N')->setAutoSize(true);
// Menambahkan gaya lain jika diperlukan
$sheet->getStyle('A1:N1')->getFont()->setBold(true);
$sheet->getStyle('A1:N1')->getFont()->setSize(14);
}
}

View File

@ -2193,9 +2193,68 @@ public function contentRecap(Request $request){
public function mediaMonitoring(Request $request){
if ($request->ajax()) {
$news_title = $request->input('news_title', null);
$channel = $request->input('channel', null);
$issue_status = $request->input('issue_status', null);
$keyword = $request->input('keyword', null);
$input_year = $request->input('input_year', null);
$input_month = $request->input('input_month', null);
$input_date = $request->input('input_date', null);
$release_year = $request->input('release_year', null);
$release_month = $request->input('release_month', null);
$release_date = $request->input('release_date', null);
$query = MediaMonitoring::with(['enhancer', 'issue']);
$data = MediaMonitoring::with(['enhancer'])->get();
if($news_title){
$query->where('title', 'LIKE', '%'. $news_title.'%');
}
if($channel && $channel !== 'all'){
$query->where('channel', $channel);
}
if ($issue_status && $issue_status !== 'all') {
if ($issue_status === 'added') {
$query->whereHas('issue');
} elseif ($issue_status === 'not_added') {
$query->whereDoesntHave('issue');
}
}
if($keyword){
$query->where('keyword', 'LIKE', '%'. $keyword.'%');
}
if ($input_year) {
$query->whereYear('created_at', $input_year);
}
if ($input_month) {
$monthYear = Carbon::parse($input_month);
$query->whereYear('created_at', $monthYear->year)
->whereMonth('created_at', $monthYear->month);
}
if ($input_date) {
$query->whereDate('created_at', $input_date);
}
if ($release_year) {
$query->whereYear('release_date', $release_year);
}
if ($release_month) {
$monthYear = Carbon::parse($release_month);
$query->whereYear('release_date', $monthYear->year)
->whereMonth('release_date', $monthYear->month);
}
if ($release_date) {
$query->whereDate('release_date', $release_date);
}
$data = $query->get();
return DataTables::of($data)
->addIndexColumn()
@ -2203,10 +2262,11 @@ public function mediaMonitoring(Request $request){
return $data->enhancer ? $data->enhancer->name : 'Undefined';
})
->addColumn('input_date', function ($data) {
return idn_date($data->input_date, 'd F Y');
return idn_date($data->created_at, 'd F Y');
})
->addColumn('title', function ($data) {
return shorten_text($data->title, 40);
return '<span title="'.$data->title.'">'.shorten_text($data->title, 40).'</span>';
// return shorten_text($data->title, 40);
})
->addColumn('link', function ($data) {
if(filled($data->link)){
@ -2215,6 +2275,9 @@ public function mediaMonitoring(Request $request){
return '-';
}
})
->addColumn('channel', function ($data) {
return ucfirst($data->channel);
})
->addColumn('issue_status', function ($data) {
if ($data->issue) {
return '<span class="badge bg-primary" style="display:inline-block;font-size:0.8rem;">Sudah Ditambahkan</span>';
@ -2257,7 +2320,7 @@ public function mediaMonitoring(Request $request){
return $dropdown;
})
->rawColumns(['issue_status', 'link', 'action'])
->rawColumns(['title', 'issue_status', 'link', 'action'])
->make(true);
}

View File

@ -2,17 +2,30 @@
namespace App\Http\Controllers\Dashboard;
use App\Exports\MediaMonitoringExport;
use App\Http\Controllers\Controller;
use App\Http\Requests\MediaMonitoringRequest;
use App\Models\MediaMonitoring;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel;
class MediaMonitoringController extends Controller
{
public function index(){
public function index(Request $request){
return view('dashboard.media-monitorings.index', [
'title' => 'Monitoring Media'
'title' => 'Monitoring Media',
'news_title' => $request->input('news_title', null),
'channel' => $request->input('channel', null),
'issue_status' => $request->input('issue_status', null),
'keyword' => $request->input('keyword', null),
'input_year' => $request->input('input_year', null),
'input_month' => $request->input('input_month', null),
'input_date' => $request->input('input_date', null),
'release_year' => $request->input('release_year', null),
'release_month' => $request->input('release_month', null),
'release_date' => $request->input('release_date', null),
]);
}
@ -107,4 +120,37 @@ public function checkLink(Request $request)
'exists' => $linkExists
]);
}
public function filter(Request $request){
$filteredRequest = $request->except('_token');
// if(!$request->has('news_title')){
// unset($filteredRequest['news_title']);
// }
$filterField = array_filter($filteredRequest, function ($value) {
return filled($value);
});
return redirect()->route('dashboard.media.monitorings.index', $filterField);
}
public function export(Request $request)
{
$news_title = $request->input('news_title', null);
$channel = $request->input('channel', 'all');
$issue_status = $request->input('issue_status', 'all');
$keywords = $request->input('keywords', 'all');
$input_year = $request->input('input_year', null);
$input_month = $request->input('input_month', null);
$input_date = $request->input('input_date', null);
$release_year = $request->input('release_year', null);
$release_month = $request->input('release_month', null);
$release_date = $request->input('release_date', null);
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
return Excel::download(new MediaMonitoringExport($news_title, $channel, $issue_status, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date), 'media-monitoring-'.$formattedNow.'.xlsx');
}
}

View File

@ -27,11 +27,12 @@ public function rules(): array
'theme' => ['required', 'max:100'],
'title' => ['required'],
'link' => ['nullable', 'url'],
'writter' => ['required'],
'news_page' => ['nullable'],
'writter' => ['required', 'max:100'],
'channel'=> ['required', 'in:website,tiktok,youtube,instagram,facebook,twitter,cetak'],
'content' => ['required'],
'influencer' => ['nullable'],
'keyword' => ['required'],
'influencer' => ['nullable', 'max:100'],
'keyword' => ['required', 'max:100'],
'quote' => ['nullable'],
'release_date' => ['required', 'date'],
];
@ -45,40 +46,50 @@ public function rules(): array
return $rules;
}
protected function prepareForValidation()
{
$this->merge([
'link' => filled($this->link) ? $this->link : null,
'influencer' => filled($this->influencer) ? $this->influencer : null,
'quote' => filled($this->quote) ? $this->quote : null,
]);
}
public function messages()
{
return [
'media_name.required' => 'Nama media wajib diisi.',
'media_name.max' => 'Nama media tidak boleh lebih dari 100 karakter.',
{
return [
'media_name.required' => 'Nama media wajib diisi.',
'media_name.max' => 'Nama media tidak boleh lebih dari 100 karakter.',
'theme.required' => 'Tema wajib diisi.',
'theme.max' => 'Tema tidak boleh lebih dari 100 karakter.',
'theme.required' => 'Tema wajib diisi.',
'theme.max' => 'Tema tidak boleh lebih dari 100 karakter.',
'title.required' => 'Judul wajib diisi.',
'title.required' => 'Judul wajib diisi.',
'link.url' => 'Link harus dalam format URL yang valid.',
'link.url' => 'Link harus berupa URL yang valid.',
'writter.required' => 'Nama penulis wajib diisi.',
'writter.required' => 'Nama penulis wajib diisi.',
'writter.max' => 'Nama penulis tidak boleh lebih dari 100 karakter.',
'channel.required' => 'Channel wajib dipilih.',
'channel.in' => 'Channel yang dipilih tidak valid.',
'channel.required' => 'Channel wajib dipilih.',
'channel.in' => 'Channel yang dipilih tidak valid. Pilih salah satu dari: website, tiktok, youtube, instagram, facebook, twitter, atau cetak.',
'content.required' => 'Konten wajib diisi.',
'content.required' => 'Konten wajib diisi.',
'influencer.nullable' => 'Nama influencer boleh dikosongkan.',
'influencer.max' => 'Nama influencer tidak boleh lebih dari 100 karakter.',
'keyword.required' => 'Keyword wajib diisi.',
'keyword.required' => 'Keyword wajib diisi.',
'keyword.max' => 'Keyword tidak boleh lebih dari 100 karakter.',
'quote.nullable' => 'Quote boleh dikosongkan.',
'release_date.required' => 'Tanggal rilis wajib diisi.',
'release_date.date' => 'Tanggal rilis harus dalam format tanggal yang valid.',
'release_date.required' => 'Tanggal rilis wajib diisi.',
'release_date.date' => 'Tanggal rilis harus dalam format tanggal yang valid.',
'image.required' => 'Gambar wajib diunggah.',
'image.image' => 'File yang diunggah harus berupa gambar.',
'image.mimes' => 'Gambar hanya boleh berformat PNG, JPG, atau JPEG.',
'image.max' => 'Ukuran gambar tidak boleh lebih dari 2MB.',
];
}
'image.required' => 'Gambar wajib diunggah.',
'image.image' => 'File yang diunggah harus berupa gambar.',
'image.mimes' => 'Gambar hanya boleh berformat PNG, JPG, atau JPEG.',
'image.max' => 'Gambar tidak boleh lebih dari 2MB.',
];
}
}

View File

@ -10,16 +10,19 @@
<div class="card card-bordered card-preview">
<div class="card-inner">
<div class="card-head">
<h5 class="card-title">{{$title}}</h5>
<div class="nk-block-head">
<h5 class="title">Buat Monitoring Media Baru</h5>
<p>Masukkan informasi yang diperlukan untuk membuat monitoring media.</p>
</div>
</div>
<form action="{{route('dashboard.media.monitorings.store')}}" method="post" enctype="multipart/form-data">
<form action="{{route('dashboard.media.monitorings.store')}}" method="post" enctype="multipart/form-data" id="myForm">
@csrf
<div class="row g-4">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="media_name">Nama Media<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('media_name') border-danger @enderror" id="media_name" name="media_name" placeholder="Masukan nama media" value="{{old('media_name')}}">
<input type="text" class="form-control" id="media_name" name="media_name" placeholder="Contoh: Tribunews.com" value="{{old('media_name')}}">
</div>
@error('media_name')
<span class="validation-error">{{$message}}</span>
@ -30,18 +33,18 @@
<div class="form-group">
<label class="form-label" for="theme">Tema<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('theme') border-danger @enderror" id="theme" name="theme" placeholder="Masukan tema" value="{{old('theme')}}">
<input type="text" class="form-control" id="theme" name="theme" placeholder="Contoh: Bencana Alam, Wisata" value="{{old('theme')}}">
</div>
@error('theme')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="title">Judul Berita<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('title') border-danger @enderror" id="title" name="title" placeholder="Masukan judul berita" value="{{old('title')}}">
<input type="text" class="form-control" id="title" name="title" placeholder="Contoh: Air Mancur Sri Baduga Purwakarta Tak Beroperasi saat Malam Tahun Baru, Ini Sebabnya" value="{{old('title')}}">
</div>
@error('title')
<span class="validation-error">{{$message}}</span>
@ -52,7 +55,7 @@
<div class="form-group">
<label class="form-label" for="link">Link</label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('link') border-danger @enderror" id="mediaMonitoringLink" name="link" placeholder="Masukan link" value="{{old('link')}}">
<input type="text" class="form-control" id="mediaMonitoringLink" name="link" placeholder="Contoh: https://instagram.com/abc" value="{{old('link')}}">
<small id="mediaMonitoringLinkFeedback" class="d-none"></small>
</div>
@error('link')
@ -64,7 +67,7 @@
<div class="form-group">
<label class="form-label" for="writter">Penulis<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('writter') border-danger @enderror" id="writter" name="writter" placeholder="Masukan penulis" value="{{old('writter')}}">
<input type="text" class="form-control" id="writter" name="writter" placeholder="Contoh: Mr. X" value="{{old('writter')}}">
</div>
@error('writter')
<span class="validation-error">{{$message}}</span>
@ -76,6 +79,7 @@
<label class="form-label">Kanal<span class="required-input">*</span></label>
<div class="form-control-wrap">
<select class="form-select js-select2" name="channel" data-search="on">
<option value="select" selected disabled>Pilih Kanal</option>
<option value="website" {{old('channel') == 'website' ? 'selected' : ''}}>Website</option>
<option value="tiktok" {{old('channel') == 'tiktok' ? 'selected' : ''}}>Tiktok</option>
<option value="youtube" {{old('channel') == 'youtube' ? 'selected' : ''}}>YouTube</option>
@ -85,6 +89,20 @@
<option value="cetak" {{old('channel') == 'cetak' ? 'selected' : ''}}>Cetak</option>
</select>
</div>
@error('channel')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="news_page">Halaman Berita</label>
<div class="form-control-wrap">
<input type="text" class="form-control" id="news_page" name="news_page" placeholder="Contoh: Halaman 5, Halaman 2 s.d. 4" value="{{old('news_page')}}">
</div>
@error('news_page')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-12">
@ -102,7 +120,7 @@
<div class="form-group">
<label class="form-label" for="influencer">Influencer</label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('influencer') border-danger @enderror" id="influencer" name="influencer" placeholder="Masukan influencer" value="{{old('influencer')}}">
<input type="text" class="form-control" id="influencer" name="influencer" placeholder="Contoh: Sekretariat Daerah" value="{{old('influencer')}}">
</div>
@error('influencer')
<span class="validation-error">{{$message}}</span>
@ -113,7 +131,7 @@
<div class="form-group">
<label class="form-label" for="keyword">Kata Kunci<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('keyword') border-danger @enderror" id="keyword" name="keyword" placeholder="Masukan kata kunci" value="{{old('keyword')}}">
<input type="text" class="form-control" id="keyword" name="keyword" placeholder="Contoh: Purwakarta" value="{{old('keyword')}}">
</div>
@error('keyword')
<span class="validation-error">{{$message}}</span>
@ -132,7 +150,7 @@
<div class="form-group">
<label class="form-label" for="release_date">Tanggal Rilis<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="date" class="form-control @error('release_date') border-danger @enderror" id="release_date" name="release_date" placeholder="Masukan Tanggal rilis" value="{{old('release_date')}}">
<input type="date" class="form-control" id="release_date" name="release_date" placeholder="Masukan Tanggal rilis" value="{{old('release_date')}}">
</div>
@error('release_date')
<span class="validation-error">{{$message}}</span>
@ -143,7 +161,10 @@
<div class="form-group">
<label class="form-label" for="image">Gambar<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="file" class="form-control @error('image') border-danger @enderror" id="image" name="image" accept="image/*">
<div class="form-file">
<input type="file" accept="image/*" class="form-file-input" id="image" name="image">
<label class="form-file-label" for="image">Unggah gambar</label>
</div>
</div>
@error('image')
<span class="validation-error">{{$message}}</span>
@ -154,7 +175,7 @@
<hr>
<div class="form-group d-flex justify-content-end">
<a href="{{route('dashboard.media.monitorings.index')}}" class="btn btn-white btn-dim btn-outline-light mx-2"><span>Kembali</span></a>
<button type="submit" class="btn btn-md btn-primary">Tambahkan</button>
<button type="button" class="btn btn-md btn-primary" id="submitButton">Tambahkan</button>
</div>
</div>
</div>

View File

@ -10,9 +10,12 @@
<div class="card card-bordered card-preview">
<div class="card-inner">
<div class="card-head">
<h5 class="card-title">{{$title}}</h5>
<div class="nk-block-head">
<h5 class="title">Ubah Monitoring Media</h5>
<p>Perbarui informasi monitoring media ini.</p>
</div>
</div>
<form action="{{route('dashboard.media.monitorings.update', ['id' => encrypt_id($mediaMonitoring->id)])}}" method="post" enctype="multipart/form-data">
<form action="{{route('dashboard.media.monitorings.update', ['id' => encrypt_id($mediaMonitoring->id)])}}" method="post" enctype="multipart/form-data" id="myForm">
@csrf
@method('put')
<div class="row g-4">
@ -20,7 +23,7 @@
<div class="form-group">
<label class="form-label" for="media_name">Nama Media<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('media_name') border-danger @enderror" id="media_name" name="media_name" placeholder="Masukan nama media" value="{{$mediaMonitoring->media_name}}">
<input type="text" class="form-control @error('media_name') border-danger @enderror" id="media_name" name="media_name" placeholder="Contoh: Tribunews.com" value="{{$mediaMonitoring->media_name}}">
</div>
@error('media_name')
<span class="validation-error">{{$message}}</span>
@ -31,18 +34,18 @@
<div class="form-group">
<label class="form-label" for="theme">Tema<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('theme') border-danger @enderror" id="theme" name="theme" placeholder="Masukan tema" value="{{$mediaMonitoring->theme}}">
<input type="text" class="form-control @error('theme') border-danger @enderror" id="theme" name="theme" placeholder="Contoh: Bencana Alam, Wisata" value="{{$mediaMonitoring->theme}}">
</div>
@error('theme')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="title">Judul Berita<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('title') border-danger @enderror" id="title" name="title" placeholder="Masukan judul berita" value="{{$mediaMonitoring->title}}">
<input type="text" class="form-control @error('title') border-danger @enderror" id="title" name="title" placeholder="Contoh: Air Mancur Sri Baduga Purwakarta Tak Beroperasi saat Malam Tahun Baru, Ini Sebabnya" value="{{$mediaMonitoring->title}}">
</div>
@error('title')
<span class="validation-error">{{$message}}</span>
@ -53,7 +56,7 @@
<div class="form-group">
<label class="form-label" for="link">Link</label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('link') border-danger @enderror" id="link" name="link" placeholder="Masukan link" value="{{$mediaMonitoring->link}}">
<input type="text" class="form-control @error('link') border-danger @enderror" id="link" name="link" placeholder="Contoh: https://instagram.com/abc" value="{{$mediaMonitoring->link}}">
<small id="linkFeedback" class="d-none"></small>
</div>
@error('link')
@ -65,7 +68,7 @@
<div class="form-group">
<label class="form-label" for="writter">Penulis<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('writter') border-danger @enderror" id="writter" name="writter" placeholder="Masukan penulis" value="{{$mediaMonitoring->writter}}">
<input type="text" class="form-control @error('writter') border-danger @enderror" id="writter" name="writter" placeholder="Contoh: Mr. X" value="{{$mediaMonitoring->writter}}">
</div>
@error('writter')
<span class="validation-error">{{$message}}</span>
@ -86,6 +89,20 @@
<option value="cetak" {{$mediaMonitoring->channel == 'cetak' ? 'selected' : ''}}>Cetak</option>
</select>
</div>
@error('channel')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="news_page">Halaman Berita</label>
<div class="form-control-wrap">
<input type="text" class="form-control" id="news_page" name="news_page" placeholder="Contoh: Halaman 5, Halaman 2 s.d. 4" value="{{$mediaMonitoring->news_page}}">
</div>
@error('news_page')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-12">
@ -103,7 +120,7 @@
<div class="form-group">
<label class="form-label" for="influencer">Influencer</label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('influencer') border-danger @enderror" id="influencer" name="influencer" placeholder="Masukan influencer" value="{{$mediaMonitoring->influencer}}">
<input type="text" class="form-control @error('influencer') border-danger @enderror" id="influencer" name="influencer" placeholder="Contoh: Sekretariat Daerah" value="{{$mediaMonitoring->influencer}}">
</div>
@error('influencer')
<span class="validation-error">{{$message}}</span>
@ -114,7 +131,7 @@
<div class="form-group">
<label class="form-label" for="keyword">Kata Kunci<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('keyword') border-danger @enderror" id="keyword" name="keyword" placeholder="Masukan kata kunci" value="{{$mediaMonitoring->keyword}}">
<input type="text" class="form-control @error('keyword') border-danger @enderror" id="keyword" name="keyword" placeholder="Contoh: Purwakarta" value="{{$mediaMonitoring->keyword}}">
</div>
@error('keyword')
<span class="validation-error">{{$message}}</span>
@ -142,9 +159,22 @@
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="image">Gambar</label>
<label class="form-label" for="image">Gambar @if (filled($mediaMonitoring->image))
<span>
<a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#modalDefault">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-eye">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
<path d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
</svg>
</a>
</span>
@endif</label>
<div class="form-control-wrap">
<input type="file" class="form-control @error('image') border-danger @enderror" id="image" name="image" accept="image/*">
<div class="form-file">
<input type="file" accept="image/*" class="form-file-input" id="image" name="image">
<label class="form-file-label" for="image">{{!filled($mediaMonitoring->image) ? 'Tidak ada sampul' : $mediaMonitoring->image}}</label>
</div>
</div>
@error('image')
<span class="validation-error">{{$message}}</span>
@ -155,11 +185,26 @@
<hr>
<div class="form-group d-flex justify-content-end">
<a href="{{route('dashboard.media.monitorings.index')}}" class="btn btn-white btn-dim btn-outline-light mx-2"><span>Kembali</span></a>
<button type="submit" class="btn btn-md btn-primary">Tambahkan</button>
<button type="button" class="btn btn-md btn-primary" id="submitButton">Simpan</button>
</div>
</div>
</div>
</form>
<div class="modal fade" tabindex="-1" id="modalDefault">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Preview Gambar</h5>
<a href="#" class="close" data-bs-dismiss="modal" aria-label="Close">
<em class="icon ni ni-cross"></em>
</a>
</div>
<div class="modal-body">
<img src="{{asset(display_image($mediaMonitoring->image, 'media-monitorings'))}}" alt="Media Monitoring Image">
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -16,18 +16,25 @@
<a href="#" class="btn btn-icon btn-trigger toggle-expand me-n1" data-target="pageMenu"><em class="icon ni ni-more-v"></em></a>
<div class="toggle-expand-content" data-content="pageMenu">
<ul class="nk-block-tools g-3">
{{-- <li>
<div class="drodown">
<a href="#" class="dropdown-toggle btn btn-white btn-dim btn-outline-light" data-bs-toggle="dropdown"><em class="d-none d-sm-inline icon ni ni-calender-date"></em><span><span class="d-none d-md-inline">Last</span> 30 Days</span><em class="dd-indc icon ni ni-chevron-right"></em></a>
<div class="dropdown-menu dropdown-menu-end">
<ul class="link-list-opt no-bdr">
<li><a href="#"><span>Last 30 Days</span></a></li>
<li><a href="#"><span>Last 6 Months</span></a></li>
<li><a href="#"><span>Last 1 Years</span></a></li>
</ul>
</div>
<li>
@if (filled(value: $news_title) || filled(value: $channel)
|| filled($issue_status) || filled($input_year) || filled($input_month) || filled($input_date)
)
<span class="mx-1">
<a href="{{route('dashboard.media.monitorings.index')}}" class="text-secondary">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-xbox-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10 -10 10s-10 -4.477 -10 -10s4.477 -10 10 -10m3.6 5.2a1 1 0 0 0 -1.4 .2l-2.2 2.933l-2.2 -2.933a1 1 0 1 0 -1.6 1.2l2.55 3.4l-2.55 3.4a1 1 0 1 0 1.6 1.2l2.2 -2.933l2.2 2.933a1 1 0 0 0 1.6 -1.2l-2.55 -3.4l2.55 -3.4a1 1 0 0 0 -.2 -1.4" /></svg>
</a>
</span>
@endif
<div>
<a href="javascript: void(0);" class="btn btn-white btn-dim btn-outline-light" data-bs-toggle="modal" data-bs-target="#modalFilter"><em class="d-none d-sm-inline icon ni ni-filter"></em><span><span class="d-none d-md-inline">Filter</a>
</div>
</li> --}}
</li>
<li>
<div>
<a href="javascript: void(0);" class="btn btn-info" data-bs-toggle="modal" data-bs-target="#modalExport"><em class="d-none d-sm-inline icon ni ni-upload"></em><span><span class="d-none d-md-inline">Export</a>
</div>
</li>
<li class="nk-block-tools-opt"><a href="{{route('dashboard.media.monitorings.create')}}" class="btn btn-primary"><em class="icon ni ni-plus"></em><span>Tambah</span></a></li>
</ul>
</div>
@ -35,6 +42,7 @@
</div>
</div><!-- .nk-block-between -->
</div><!-- .nk-block-head -->
{{-- {{asset('assets/dashboard/css/custom.css')}} --}}
<div class="nk-block nk-block-lg">
<div class="card card-bordered card-preview">
<div class="card-inner">
@ -48,6 +56,9 @@
<th>Tanggal Input</th>
<th style="width: 30% !important;">Judul</th>
<th>Media</th>
<th>Kanal</th>
<th>Tema</th>
<th>Penulis</th>
<th>Link</th>
<th>Issue</th>
<th style="width: 10% !important;"></th>
@ -58,6 +69,196 @@
</div>
</div>
</div>
<div class="modal fade" id="modalExport">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Export</h5>
<a href="javascript:void(0);" class="close" data-bs-dismiss="modal" aria-label="Close">
<em class="icon ni ni-cross"></em>
</a>
</div>
<form action="{{route('dashboard.media.monitorings.export')}}" class="form-validate is-alter" method="post">
@csrf
<div class="modal-body">
<div class="form-group">
<label class="form-label" for="news_title">Judul</label>
<div class="form-control-wrap">
<input type="text" class="form-control" id="news_title" placeholder="Cari..." name="news_title" value="{{ old('news_title') }}">
</div>
</div>
<div class="form-group">
<label class="form-label">Kanal</label>
<div class="form-control-wrap">
<select class="form-select js-select2" name="channel">
<option value="all">Semua</option>
<option value="website">Website</option>
<option value="tiktok">Tiktok</option>
<option value="youtube">YouTube</option>
<option value="instagram">Instagram</option>
<option value="facebook">Facebook</option>
<option value="twitter">Twitter</option>
<option value="cetak">Cetak</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label">Status Isu</label>
<div class="form-control-wrap">
<select class="form-select js-select2" name="issue_status">
<option value="all">Semua</option>
<option value="added">Sudah Ditambahkan</option>
<option value="not_added">Belum Ditambahkan</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label" for="keyword">Kata Kunci</label>
<div class="form-control-wrap">
<input type="text" class="form-control" id="keyword" placeholder="Cari..." name="keyword" value="{{ old('keyword') }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="input_year">Tahun Input</label>
<div class="form-control-wrap">
<input type="number" class="form-control" id="input_year" placeholder="Data monitoring media pada tahun" name="input_year">
</div>
</div>
<div class="form-group">
<label class="form-label" for="input_month">Bulan Input</label>
<div class="form-control-wrap">
<input type="month" class="form-control" id="input_month" placeholder="Data monitoring media pada bulan dan tahun" name="input_month">
</div>
</div>
<div class="form-group">
<label class="form-label" for="input_date">Tanggal Input</label>
<div class="form-control-wrap">
<input type="date" class="form-control" id="input_date" placeholder="Data monitoring media pada bulan dan tahun" name="input_date">
</div>
</div>
<div class="form-group">
<label class="form-label" for="release_year">Tahun Rilis</label>
<div class="form-control-wrap">
<input type="number" class="form-control" id="release_year" placeholder="Data monitoring media pada tahun" name="release_year">
</div>
</div>
<div class="form-group">
<label class="form-label" for="release_month">Bulan Rilis</label>
<div class="form-control-wrap">
<input type="month" class="form-control" id="release_month" placeholder="Data monitoring media pada bulan dan tahun" name="release_month">
</div>
</div>
<div class="form-group">
<label class="form-label" for="release_date">Tanggal Rilis</label>
<div class="form-control-wrap">
<input type="date" class="form-control" id="release_date" placeholder="Data monitoring media pada bulan dan tahun" name="release_date">
</div>
</div>
</div>
<div class="modal-footer bg-light">
<span class="sub-text">
<button type="submit" class="btn btn-sm btn-primary">Export</button>
</span>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="modalFilter">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Filter</h5>
<a href="javascript:void(0);" class="close" data-bs-dismiss="modal" aria-label="Close">
<em class="icon ni ni-cross"></em>
</a>
</div>
<form action="{{route('dashboard.media.monitorings.filter')}}" class="form-validate is-alter" method="post">
@csrf
<div class="modal-body">
<div class="form-group">
<label class="form-label" for="news_title">Judul</label>
<div class="form-control-wrap">
<input type="text" class="form-control" id="news_title" placeholder="Cari..." name="news_title" value="{{ old('news_title', $news_title ?? '') }}">
</div>
</div>
<div class="form-group">
<label class="form-label">Kanal</label>
<div class="form-control-wrap">
<select class="form-select js-select2" name="channel">
<option value="all" {{$channel == 'all' ? 'selected' : ''}}>Semua</option>
<option value="website" {{$channel == 'website' ? 'selected' : ''}}>Website</option>
<option value="tiktok" {{$channel == 'tiktok' ? 'selected' : ''}}>Tiktok</option>
<option value="youtube" {{$channel == 'youtube' ? 'selected' : ''}}>YouTube</option>
<option value="instagram" {{$channel == 'instagram' ? 'selected' : ''}}>Instagram</option>
<option value="facebook" {{$channel == 'facebook' ? 'selected' : ''}}>Facebook</option>
<option value="twitter" {{$channel == 'twitter' ? 'selected' : ''}}>Twitter</option>
<option value="cetak" {{$channel == 'cetak' ? 'selected' : ''}}>Cetak</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label">Status Isu</label>
<div class="form-control-wrap">
<select class="form-select js-select2" name="issue_status">
<option value="all" {{$issue_status == 'all' ? 'selected' : ''}}>Semua</option>
<option value="added" {{$issue_status == 'added' ? 'selected' : ''}}>Sudah Ditambahkan</option>
<option value="not_added" {{$issue_status == 'addenot_addedd' ? 'selected' : ''}}>Belum Ditambahkan</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label" for="keyword">Kata Kunci</label>
<div class="form-control-wrap">
<input type="text" class="form-control" id="keyword" placeholder="Cari..." name="keyword" value="{{ $keyword }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="input_year">Tahun Input</label>
<div class="form-control-wrap">
<input type="number" class="form-control" id="input_year" placeholder="Data berita pada tahun" name="input_year" value="{{ old('input_year', $input_year ?? '') }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="input_month">Bulan Input</label>
<div class="form-control-wrap">
<input type="month" class="form-control" id="input_month" placeholder="Data berita pada bulan dan tahun" name="input_month" value="{{ old('input_month', $input_month ?? '') }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="input_date">Tanggal Input</label>
<div class="form-control-wrap">
<input type="date" class="form-control" id="input_date" placeholder="Data berita pada bulan dan tahun" name="input_date" value="{{ old('input_date', $input_date ?? '') }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="release_year">Tahun Rilis</label>
<div class="form-control-wrap">
<input type="number" class="form-control" id="release_year" placeholder="Data berita pada tahun" name="release_year" value="{{ old('release_year', $release_year ?? '') }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="release_month">Bulan Rilis</label>
<div class="form-control-wrap">
<input type="month" class="form-control" id="release_month" placeholder="Data berita pada bulan dan tahun" name="release_month" value="{{ old('release_month', $release_month ?? '') }}">
</div>
</div>
<div class="form-group">
<label class="form-label" for="release_date">Tanggal Rilis</label>
<div class="form-control-wrap">
<input type="date" class="form-control" id="release_date" placeholder="Data berita pada bulan dan tahun" name="release_date" value="{{ old('release_date', $release_date ?? '') }}">
</div>
</div>
</div>
<div class="modal-footer bg-light">
<span class="sub-text">
<button type="submit" class="btn btn-sm btn-primary">Filter</button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1041,7 +1041,22 @@
$('#mediaMonitoringsTable').DataTable({
processing: true,
serverSide: true,
ajax: '{{ route('dashboard.media.monitorings.data') }}',
ajax: {
url: '{{ route('dashboard.media.monitorings.data') }}',
type: 'GET',
data: function(d) {
d.news_title = '{{ $news_title }}';
d.channel = '{{ $channel }}';
d.issue_status = '{{ $issue_status }}';
d.keyword = '{{ $keyword }}';
d.input_year = '{{ $input_year }}';
d.input_month = '{{ $input_month }}';
d.input_date = '{{ $input_date }}';
d.release_year = '{{ $release_year }}';
d.release_month = '{{ $release_month }}';
d.release_date = '{{ $release_date }}';
}
},
columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false },
{ data: 'enhancer', name: 'enhancer' },
@ -1049,6 +1064,9 @@
{ data: 'input_date', name: 'input_date' },
{ data: 'title', name: 'title' },
{ data: 'media_name', name: 'media_name' },
{ data: 'channel', name: 'channel' },
{ data: 'theme', name: 'theme' },
{ data: 'writter', name: 'writter' },
{ data: 'link', name: 'link' },
{ data: 'issue_status', name: 'issue_status' },
{ data: 'action', name: 'action', orderable: false, searchable: false },
@ -1058,7 +1076,7 @@
language: datatableLanguage,
// responsive: true,
autoWidth: false,
order: [[9, 'desc']],
order: [[11, 'desc']],
pagingType: "simple",
lengthMenu: [[10, 25, 50, 100, -1], ['Tampilkan 10 data', 'Tampilkan 25 data', 'Tampilkan 50 data', 'Tampilkan 100 data', 'Tampilkan semua']],
scrollX: true

View File

@ -516,6 +516,9 @@
Route::get('/{id}/edit', 'edit')->name('edit');
Route::put('/{id}', 'update')->name('update');
Route::delete('/{id}', 'destroy')->name('destroy');
Route::post('/export', 'export')->name('export');
Route::post('/filter', 'filter')->name('filter');
});
Route::get('/data', [DatatableController::class, 'mediaMonitoring'])->name('data');