refactoring: controller batch 1
This commit is contained in:
parent
b6f8848055
commit
00ec6dd4ca
@ -20,6 +20,7 @@ class MediaMonitoringExport implements FromCollection, WithHeadings, WithStyles,
|
||||
protected $news_title;
|
||||
protected $channel;
|
||||
protected $issue_status;
|
||||
protected $keyword;
|
||||
protected $input_year;
|
||||
protected $input_month;
|
||||
protected $input_date;
|
||||
@ -27,11 +28,12 @@ class MediaMonitoringExport implements FromCollection, WithHeadings, WithStyles,
|
||||
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)
|
||||
public function __construct($news_title, $channel, $issue_status, $keyword, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date)
|
||||
{
|
||||
$this->news_title = $news_title;
|
||||
$this->channel = $channel;
|
||||
$this->issue_status = $issue_status;
|
||||
$this->keyword = $keyword;
|
||||
$this->input_year = $input_year;
|
||||
$this->input_month = $input_month;
|
||||
$this->input_date = $input_date;
|
||||
@ -60,6 +62,10 @@ public function collection()
|
||||
}
|
||||
}
|
||||
|
||||
if($this->keyword){
|
||||
$query->where('keyword', 'LIKE', '%'. $this->keyword.'%');
|
||||
}
|
||||
|
||||
if ($this->input_year) {
|
||||
$query->whereYear('created_at', $this->input_year);
|
||||
}
|
||||
|
||||
@ -17,110 +17,182 @@
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (! function_exists('store_file')) {
|
||||
// function store_file($file = null, $path, $disk = null)
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
// if (filled($file) && $file instanceof \Illuminate\Http\UploadedFile) {
|
||||
// $randomFilename = Str::random(35) . time() . '.' . $file->getClientOriginalExtension();
|
||||
// $originalFileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
// $stored = $file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
// if ($stored) {
|
||||
// $url = Storage::disk($disk)->url($stored);
|
||||
|
||||
// return [
|
||||
// 'randomFileName' => $randomFilename,
|
||||
// 'originalFileName' => $originalFileName,
|
||||
// 'url' => $url,
|
||||
// 'isSuccess' => true,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// return [
|
||||
// 'randomFileName' => null,
|
||||
// 'originalFileName' => null,
|
||||
// 'url' => null,
|
||||
// 'isSuccess' => false,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
if (! function_exists('store_file')) {
|
||||
function store_file($file = null, $path, $disk = null)
|
||||
function store_file($file = null, $path, $disk = 'public')
|
||||
{
|
||||
$disk = $disk ?? env('FILESYSTEM_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();
|
||||
|
||||
if (filled($file) && $file instanceof \Illuminate\Http\UploadedFile) {
|
||||
$randomFilename = Str::random(35) . time() . '.' . $file->getClientOriginalExtension();
|
||||
$originalFileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) . '.' . $file->getClientOriginalExtension();
|
||||
$file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
$stored = $file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
if ($stored) {
|
||||
$url = Storage::disk($disk)->url($stored);
|
||||
|
||||
return [
|
||||
'randomFileName' => $randomFilename,
|
||||
'originalFileName' => $originalFileName,
|
||||
'url' => $url,
|
||||
'isSuccess' => true,
|
||||
];
|
||||
}
|
||||
return [
|
||||
'randomFileName' => $randomFilename,
|
||||
'originalFileName' => $originalFileName,
|
||||
'isSuccess' => true,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'randomFileName' => null,
|
||||
'originalFileName' => null,
|
||||
'isSuccess' => false,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'randomFileName' => null,
|
||||
'originalFileName' => null,
|
||||
'url' => null,
|
||||
'isSuccess' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('display_file')) {
|
||||
function display_file($dir, $filename, $disk = null, $expirationMinutes = 60): string
|
||||
{
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
// if (!function_exists('display_file')) {
|
||||
// function display_file($dir, $filename, $disk = null, $expirationMinutes = 60): string
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
if (!filled($filename)) {
|
||||
// if (!filled($filename)) {
|
||||
// return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
// }
|
||||
|
||||
// $path = "uploads/{$dir}/{$filename}";
|
||||
|
||||
// try {
|
||||
// $fileExists = is_file_exists($path, $disk);
|
||||
|
||||
// if (!$fileExists) {
|
||||
// return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
// }
|
||||
|
||||
// if ($disk === 's3') {
|
||||
// $fileUrl = Storage::disk($disk)->temporaryUrl($path, now()->addMinutes($expirationMinutes));
|
||||
// } else {
|
||||
// $fileUrl = Storage::disk($disk)->url($path);
|
||||
// }
|
||||
|
||||
// $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
// $mimeType = match ($ext) {
|
||||
// 'jpg', 'jpeg', 'png', 'gif', 'webp' => 'image/' . $ext,
|
||||
// 'pdf' => 'application/pdf',
|
||||
// default => 'unknown',
|
||||
// };
|
||||
|
||||
// if (str_contains($mimeType, 'image')) {
|
||||
// return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
// } elseif ($mimeType === 'application/pdf') {
|
||||
// return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
// }
|
||||
|
||||
// return '<p class="text-center">Format file tidak didukung</p>';
|
||||
// } catch (\Exception $e) {
|
||||
// return '<p class="text-center text-danger">Terjadi kesalahan saat menampilkan file.</p>';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!function_exists('display_file')) {
|
||||
function display_file($dir, $filename)
|
||||
{
|
||||
$path = storage_path("app/public/uploads/{$dir}/{$filename}");
|
||||
|
||||
if(!filled($filename)){
|
||||
return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
}
|
||||
|
||||
$path = "uploads/{$dir}/{$filename}";
|
||||
|
||||
try {
|
||||
$fileExists = is_file_exists($path, $disk);
|
||||
|
||||
if (!$fileExists) {
|
||||
return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
}
|
||||
|
||||
if ($disk === 's3') {
|
||||
$fileUrl = Storage::disk($disk)->temporaryUrl($path, now()->addMinutes($expirationMinutes));
|
||||
} else {
|
||||
$fileUrl = Storage::disk($disk)->url($path);
|
||||
}
|
||||
|
||||
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$mimeType = match ($ext) {
|
||||
'jpg', 'jpeg', 'png', 'gif', 'webp' => 'image/' . $ext,
|
||||
'pdf' => 'application/pdf',
|
||||
default => 'unknown',
|
||||
};
|
||||
|
||||
if (str_contains($mimeType, 'image')) {
|
||||
return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
} elseif ($mimeType === 'application/pdf') {
|
||||
return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
}
|
||||
|
||||
return '<p class="text-center">Format file tidak didukung</p>';
|
||||
} catch (\Exception $e) {
|
||||
return '<p class="text-center text-danger">Terjadi kesalahan saat menampilkan file.</p>';
|
||||
if (!file_exists($path)) {
|
||||
return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
}
|
||||
|
||||
$mimeType = mime_content_type($path);
|
||||
$fileUrl = asset("storage/uploads/{$dir}/{$filename}");
|
||||
|
||||
if (str_contains($mimeType, 'image')) {
|
||||
return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
} elseif ($mimeType === 'application/pdf') {
|
||||
return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
}
|
||||
|
||||
return '<p class="text-center">Format file tidak didukung</p>';
|
||||
}
|
||||
}
|
||||
|
||||
// if (! function_exists('delete_file')) {
|
||||
// function delete_file($path, $disk = null): bool
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
// try {
|
||||
// if(is_file_exists($path)){
|
||||
// return Storage::disk($disk)->delete($path);
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (! function_exists('delete_file')) {
|
||||
function delete_file($path, $disk = null): bool
|
||||
function delete_file($path)
|
||||
{
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
// Menggunakan public_path untuk file yang berada di dalam storage/public
|
||||
$fullPath = public_path('storage/' . $path);
|
||||
|
||||
try {
|
||||
if(is_file_exists($path)){
|
||||
return Storage::disk($disk)->delete($path);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
if (File::exists($fullPath)) {
|
||||
File::delete($fullPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_file_exists')) {
|
||||
function is_file_exists($path, $disk = null): bool
|
||||
{
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
// if (!function_exists('is_file_exists')) {
|
||||
// function is_file_exists($path, $disk = null): bool
|
||||
// {
|
||||
// $disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
try {
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
return !empty($file);
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
// try {
|
||||
// $file = Storage::disk($disk)->get($path);
|
||||
// return !empty($file);
|
||||
// } catch (\Throwable $e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (! function_exists('is_file_exists')) {
|
||||
function is_file_exists($path)
|
||||
{
|
||||
return File::exists(public_path('storage/' . $path));
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,7 +231,7 @@ function shorten_text($text, $maxLength = 100) {
|
||||
if (! function_exists('is_role')) {
|
||||
function is_role($roles) {
|
||||
if (Auth::check()) {
|
||||
return in_array(Auth::user()->role_id, (array) $roles);
|
||||
return in_array(Auth::user()->role_id, (array) $roles) || Auth::user()->role_id === '4';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -5,9 +5,7 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AiringProofThemeRequest;
|
||||
use App\Models\AiringProofTheme;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AiringProofThemeController extends Controller
|
||||
{
|
||||
@ -26,25 +24,27 @@ public function create(){
|
||||
public function store(AiringProofThemeRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
|
||||
try{
|
||||
$slug = $validatedData['slug'];
|
||||
$existing = AiringProofTheme::withTrashed()
|
||||
->where('slug', $validatedData['slug'])
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if ($existing?->trashed()) {
|
||||
return redirect()->back()->with('data-exists', $validatedData['slug']);
|
||||
return redirect()->back()->with('data-exists', $slug);
|
||||
} elseif ($existing) {
|
||||
return redirect()->back()
|
||||
->with('failed-status', 'Tema dengan nama dan tahun tersebut sudah ada.');
|
||||
}
|
||||
|
||||
$createdAiringProofTheme = AiringProofTheme::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.airing.proof.themes.index')->with('success-status', 'Berhasil membuat tema bukti tayang baru.')
|
||||
->with('new_data', encrypt_id($createdAiringProofTheme->id));
|
||||
}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){
|
||||
@ -62,11 +62,12 @@ public function update(AiringProofThemeRequest $request, $id){
|
||||
try{
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->update($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.airing.proof.themes.show', ['id' => encrypt_id($airingProofTheme->id)])->with('success-status', 'Berhasil mengubah tema bukti tayang.');
|
||||
}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){
|
||||
@ -82,16 +83,16 @@ public function destroy($id){
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus tema bukti tayang.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Airing Proof Themes (destroy): ". $e);
|
||||
return response()->json(['message' => 'Gagal menghapus tema bukti tayang.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus tema bukti tayang.']);
|
||||
}
|
||||
|
||||
public function restore($slug)
|
||||
{
|
||||
|
||||
try{
|
||||
$airingProofTheme = AiringProofTheme::withTrashed()
|
||||
->where('slug', $slug)
|
||||
@ -105,11 +106,12 @@ public function restore($slug)
|
||||
$airingProofTheme->restore();
|
||||
return redirect()->route('dashboard.airing.proof.themes.index')->with('success-status', 'Tema berhasil dipulihkan.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('info-status', 'Tema sudah aktif.');
|
||||
}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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,16 +10,14 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AnnouncementController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
|
||||
$category = $request->input('category', 'general');
|
||||
|
||||
$data = [
|
||||
'title' => 'Pengumuman',
|
||||
'category' => $category
|
||||
'category' => $request->input('category', 'general')
|
||||
];
|
||||
|
||||
if(is_role(['1'])){
|
||||
@ -40,7 +38,6 @@ public function store(AnnouncementRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements')['randomFileName'];
|
||||
}
|
||||
@ -49,7 +46,6 @@ public function store(AnnouncementRequest $request){
|
||||
$announcement = Announcement::create($validatedData);
|
||||
$announcement->users()->attach($validatedData['user_ids']);
|
||||
|
||||
|
||||
if($announcement->users()->count() < 1){
|
||||
throw new \Exception("Data tidak valid.");
|
||||
}
|
||||
@ -58,6 +54,7 @@ public function store(AnnouncementRequest $request){
|
||||
});
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("Announcements (store): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat pengumuman baru');
|
||||
}
|
||||
|
||||
@ -79,12 +76,11 @@ public function update(AnnouncementRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
try{
|
||||
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
DB::transaction(function () use($request, $validatedData, $announcement){
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements')['randomFileName'];
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], 'uploads/announcements')['randomFileName'];
|
||||
delete_file('uploads/announcements/'.$announcement->attachment);
|
||||
}else{
|
||||
$validatedData['attachment'] = $announcement->attachment;
|
||||
@ -100,12 +96,12 @@ public function update(AnnouncementRequest $request, $id){
|
||||
$announcement->users()->sync($mediaData);
|
||||
}
|
||||
});
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengumuman.');
|
||||
}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){
|
||||
@ -122,21 +118,21 @@ public function show($id){
|
||||
public function destroy($id){
|
||||
try {
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$announcement->users()->detach();
|
||||
$announcement->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus pengumuman.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Announcements (destroy): ". $e);
|
||||
return response()->json(['message' => 'Gagal menghapus pengumuman.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus pengumuman.']);
|
||||
}
|
||||
|
||||
public function read($id){
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if(!in_array(Auth::id(), $announcement->users->pluck('id')->toArray())){
|
||||
abort(404, "Pengumuman tidak ditemukan.");
|
||||
abort(404);
|
||||
}
|
||||
|
||||
try{
|
||||
@ -144,6 +140,7 @@ public function read($id){
|
||||
'status' => '1',
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
Log::error("Announcements (read): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal membaca pengumuman.');
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ClassificationController extends Controller
|
||||
@ -31,13 +32,13 @@ public function store(ClassificationRequest $request){
|
||||
|
||||
try{
|
||||
$createdClassification = Classification::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.classifications.index')->with('success-status', 'Berhasil membuat klasifikasi baru.')
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}catch (\Exception $e){
|
||||
Log::error("Classifications (store): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat klasifikasi baru.');
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.classifications.index')->with('success-status', 'Berhasil membuat klasifikasi baru.')
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
@ -56,6 +57,7 @@ public function update(ClassificationRequest $request, $id){
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
$classification->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("Classifications (update): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah klasifikasi.');
|
||||
}
|
||||
|
||||
@ -76,20 +78,20 @@ public function destroy($id)
|
||||
try {
|
||||
$classification = Classification::findOrFail(decrypt_id($id));
|
||||
$classification->delete();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Berhasil menghapus klasifikasi.',
|
||||
'id' => encrypt_id($classification->id), // untuk digunakan saat Undo
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Classifications (destroy): ". $e);
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Gagal menghapus klasifikasi.',
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Berhasil menghapus klasifikasi.',
|
||||
'id' => encrypt_id($classification->id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function restore($id)
|
||||
{
|
||||
@ -104,17 +106,18 @@ public function restore($id)
|
||||
}
|
||||
|
||||
$classification->restore();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Klasifikasi berhasil dikembalikan.',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Classifications (restore): ". $e);
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'Gagal mengembalikan klasifikasi.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Klasifikasi berhasil dikembalikan.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
@ -66,12 +68,13 @@ public function editRequestAction(Request $request){
|
||||
]);
|
||||
|
||||
$user = User::with(['company'])->findOrFail(Auth::id());
|
||||
$updatedCompany = $user->company->update([
|
||||
$user->company->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description']
|
||||
]);
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (editRequestAction): ". $e);
|
||||
return redirect()->route('dashboard.companies.index')->with('failed-status', 'Gagal melakukan permohonan edit data perusahaan.');
|
||||
}
|
||||
|
||||
@ -123,32 +126,35 @@ public function update(CompanyRequest $request){
|
||||
}
|
||||
}
|
||||
|
||||
$updatedCompany = $company->update([
|
||||
'name' => $validatedData['company_name'],
|
||||
'email' => $validatedData['company_email'],
|
||||
'address' => $validatedData['company_address'],
|
||||
'director_name' => $validatedData['company_director_name'],
|
||||
'director_nik' => $validatedData['company_director_nik'],
|
||||
'director_nik_doc' => $companyFileNames['company_director_nik_doc'],
|
||||
'deed_incorporation' => $validatedData['company_deed_incorporation'],
|
||||
'deed_incorporation_doc' => $companyFileNames['company_deed_incorporation_doc'],
|
||||
'trade_license' => $validatedData['company_trade_license'],
|
||||
'trade_license_doc' => $companyFileNames['company_trade_license_doc'],
|
||||
'tax_id_number' => $validatedData['company_tax_id_number'],
|
||||
'tax_id_number_doc' => $companyFileNames['company_tax_id_number_doc'],
|
||||
'taxable_enterprise' => $validatedData['company_taxable_enterprise'],
|
||||
'taxable_enterprise_doc' => $companyFileNames['company_taxable_enterprise_doc'],
|
||||
'annual_tax_return' => $validatedData['company_annual_tax_return'],
|
||||
'annual_tax_return_doc' => $companyFileNames['company_annual_tax_return_doc'],
|
||||
'domicile_certificate' => $validatedData['company_domicile_certificate'],
|
||||
'domicile_certificate_doc' => $companyFileNames['company_domicile_certificate_doc'],
|
||||
'profile' => $validatedData['company_profile'],
|
||||
'profile_doc' => $companyFileNames['company_profile_doc'],
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
DB::transaction(function()use($company, $validatedData, $companyFileNames){
|
||||
$company->update([
|
||||
'name' => $validatedData['company_name'],
|
||||
'email' => $validatedData['company_email'],
|
||||
'address' => $validatedData['company_address'],
|
||||
'director_name' => $validatedData['company_director_name'],
|
||||
'director_nik' => $validatedData['company_director_nik'],
|
||||
'director_nik_doc' => $companyFileNames['company_director_nik_doc'],
|
||||
'deed_incorporation' => $validatedData['company_deed_incorporation'],
|
||||
'deed_incorporation_doc' => $companyFileNames['company_deed_incorporation_doc'],
|
||||
'trade_license' => $validatedData['company_trade_license'],
|
||||
'trade_license_doc' => $companyFileNames['company_trade_license_doc'],
|
||||
'tax_id_number' => $validatedData['company_tax_id_number'],
|
||||
'tax_id_number_doc' => $companyFileNames['company_tax_id_number_doc'],
|
||||
'taxable_enterprise' => $validatedData['company_taxable_enterprise'],
|
||||
'taxable_enterprise_doc' => $companyFileNames['company_taxable_enterprise_doc'],
|
||||
'annual_tax_return' => $validatedData['company_annual_tax_return'],
|
||||
'annual_tax_return_doc' => $companyFileNames['company_annual_tax_return_doc'],
|
||||
'domicile_certificate' => $validatedData['company_domicile_certificate'],
|
||||
'domicile_certificate_doc' => $companyFileNames['company_domicile_certificate_doc'],
|
||||
'profile' => $validatedData['company_profile'],
|
||||
'profile_doc' => $companyFileNames['company_profile_doc'],
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
});
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (update): ". $e);
|
||||
return redirect()->route('dashboard.companies.index')->with('failed-status', 'Gagal mengubah data perusahaan.');
|
||||
}
|
||||
|
||||
@ -169,17 +175,26 @@ public function show($id, $type){
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch($type){
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,17 +219,27 @@ public function process(Request $request, $id, $type){
|
||||
'category' => $request->query('category', null)
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,6 +266,7 @@ public function processAcceptAction(Request $request, $id, $type, $category){
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (processAcceptAction): ". $e);
|
||||
return response()->json([
|
||||
'failed-status' => 'Gagal menyetujui'.($category === 'edit-request' ? ' permohonan edit' : '').' perusahaan.'
|
||||
]);
|
||||
@ -282,6 +308,7 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (processRejectAction): ". $e);
|
||||
return redirect()->back()->with('faileds-status', 'Gagal melakukan proses.');
|
||||
}
|
||||
|
||||
@ -290,36 +317,51 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
try{
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
|
||||
return Excel::download(new CompanyExport($status, $edit_status, $address, $register_year, $register_month, $register_date), 'companies-'.$formattedNow.'.xlsx');
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new CompanyExport($status, $edit_status, $address, $register_year, $register_month, $register_date), 'companies-'.$formattedNow.'.xlsx');
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (export): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
$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.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.companies.index', $filterField);
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
|
||||
$company = Company::with(['user.role'])->findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$company = Company::with(['user.role'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.companies.print', compact('company'));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.companies.print', compact('company'));
|
||||
|
||||
return $pdf->stream('perusahaan-'.slugify($company->name).'.pdf');
|
||||
return $pdf->stream('perusahaan-'.slugify($company->name).'.pdf');
|
||||
}catch(\Exception $e){
|
||||
Log::error("Company (printData): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
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
|
||||
@ -38,10 +39,12 @@ public function store(ContentRecapClassificationRequest $request){
|
||||
|
||||
$createdClassification = ContentRecapClassification::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecapClassifications (store): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan klasifikasi rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recap.classifications.index')->with('success-status', 'Berhasil menambahkan klasifikasi rekap konten.');
|
||||
return redirect()->route('dashboard.content.recap.classifications.index')->with('success-status', 'Berhasil menambahkan klasifikasi rekap konten.')
|
||||
->with('new_data', encrypt_id($createdClassification->id));
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
@ -58,12 +61,13 @@ public function update(ContentRecapClassificationRequest $request, $id){
|
||||
|
||||
try{
|
||||
$contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id));
|
||||
$updatedContentRecapClassification = $contentRecapClassification->update($validatedData);
|
||||
$contentRecapClassification->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecapClassifications (update): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah klasifikasi rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil 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){
|
||||
@ -78,30 +82,35 @@ public function show($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);
|
||||
return response()->json(['message' => 'Gagal menghapus klasifikasi rekap konten.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function restore($slug)
|
||||
{
|
||||
$recapContentClassification = ContentRecapClassification::withTrashed()
|
||||
|
||||
try{
|
||||
$recapContentClassification = ContentRecapClassification::withTrashed()
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
|
||||
if (!$recapContentClassification) {
|
||||
return redirect()->back()->with('failed-status', 'Klasifikasi tidak ditemukan.');
|
||||
}
|
||||
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.');
|
||||
}
|
||||
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.');
|
||||
return redirect()->back()->with('info-status', 'Klasifikasi sudah aktif.');
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecapClassifications (restore): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses pemulihan.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
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
|
||||
@ -37,23 +38,22 @@ public function create(){
|
||||
|
||||
public function store(ContentRecapRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
$createdContentRecap = ContentRecap::create($validatedData);
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.index')->with('success-status', 'Berhasil menambahkan rekap konten.')
|
||||
->with('new_data', encrypt_id($createdContentRecap->id));
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (store): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.index')->with('success-status', 'Berhasil menambahkan rekap konten.')
|
||||
->with('new_data', encrypt_id($createdContentRecap->id));
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
@ -68,23 +68,24 @@ public function edit($id){
|
||||
|
||||
public function update(ContentRecapRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
delete_file('app/public/uploads/content-recaps/'.$contentRecap->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $contentRecap->image;
|
||||
}
|
||||
|
||||
try{
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
delete_file('app/public/uploads/content-recaps/'.$contentRecap->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $contentRecap->image;
|
||||
}
|
||||
|
||||
$contentRecap->update($validatedData);
|
||||
return redirect()->route('dashboard.content.recaps.show', ['id' => encrypt_id($contentRecap->id)])->with('success-status', 'Berhasil mengubah rekap konten.');
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (update): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah rekap konten.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.show', ['id' => encrypt_id($contentRecap->id)])->with('success-status', 'Berhasil mengubah rekap konten.');
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
@ -101,10 +102,12 @@ public function destroy($id){
|
||||
$contentRecap = ContentRecap::findOrFail(decrypt_id($id));
|
||||
$contentRecap->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus rekap konten.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("ContentRecaps (destroy): ". $e);
|
||||
return response()->json(['message' => 'Gagal menghapus rekap konten.'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus rekap konten.']);
|
||||
}
|
||||
|
||||
public function checkLink(Request $request)
|
||||
@ -118,36 +121,51 @@ public function checkLink(Request $request)
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (filter): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filter data.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.content.recaps.index', $filterField);
|
||||
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$classification = $request->input('classification', 'all');
|
||||
$channel = $request->input('channel', 'all');
|
||||
$social_media = $request->input('social_media', 'all');
|
||||
$posted_year = $request->input('posted_year', null);
|
||||
$posted_month = $request->input('posted_month', null);
|
||||
$posted_date = $request->input('posted_date', null);
|
||||
try{
|
||||
$classification = $request->input('classification', 'all');
|
||||
$channel = $request->input('channel', 'all');
|
||||
$social_media = $request->input('social_media', 'all');
|
||||
$posted_year = $request->input('posted_year', null);
|
||||
$posted_month = $request->input('posted_month', null);
|
||||
$posted_date = $request->input('posted_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new ContentRecapExport($classification, $channel, $social_media, $posted_year, $posted_month, $posted_date), 'content-recaps-'.$formattedNow.'.xlsx');
|
||||
return Excel::download(new ContentRecapExport($classification, $channel, $social_media, $posted_year, $posted_month, $posted_date), 'content-recaps-'.$formattedNow.'.xlsx');
|
||||
}catch(\Exception $e){
|
||||
Log::error("ContentRecaps (export): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
|
||||
$contentRecap = ContentRecap::with(['enhancer', 'classification'])->findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$contentRecap = ContentRecap::with(['enhancer', 'classification'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.content-recaps.print', compact('contentRecap'));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.content-recaps.print', compact('contentRecap'));
|
||||
|
||||
return $pdf->stream(slugify('rekap konten '. $contentRecap->content_theme).'.pdf');
|
||||
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,27 +9,30 @@
|
||||
use App\Models\CooperationCompletion;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CooperationCompletionController extends Controller
|
||||
{
|
||||
public function store(CooperationCompletionRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$validatedData['payment_request_letter'] = store_file($validatedData['payment_request_letter'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
try{
|
||||
$validatedData['payment_request_letter'] = store_file($validatedData['payment_request_letter'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['invoice'] = store_file($validatedData['invoice'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
$validatedData['invoice'] = store_file($validatedData['invoice'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['other_document'] = store_file($validatedData['other_document'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
$validatedData['other_document'] = store_file($validatedData['other_document'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
|
||||
$createdCompletion = CooperationCompletion::create($validatedData);
|
||||
if($createdCompletion){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengirim formulir.');
|
||||
}else{
|
||||
CooperationCompletion::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationCompletions (store): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengirim formulir.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengirim formulir.');
|
||||
}
|
||||
|
||||
public function show($mediaOrderId, $id){
|
||||
@ -43,28 +46,32 @@ public function show($mediaOrderId, $id){
|
||||
}
|
||||
|
||||
public function accept($id){
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$acceptedCompletion = $completion->update([
|
||||
'status' => '1'
|
||||
]);
|
||||
try{
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerjasama <u>'. $completion->order->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui laporan formulir penyelesaian kerjasama Anda.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
$completion->update([
|
||||
'status' => '1'
|
||||
]);
|
||||
|
||||
if ($acceptedCompletion) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui penyelesaian kerjasama.');
|
||||
} else {
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerjasama <u>'. $completion->order->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui laporan formulir penyelesaian kerjasama Anda.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationCompletions (accept): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui penyelesaian kerjasama');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui penyelesaian kerjasama.');
|
||||
|
||||
}
|
||||
|
||||
public function reject($mediaOrderId, $id){
|
||||
@ -79,34 +86,36 @@ public function reject($mediaOrderId, $id){
|
||||
|
||||
public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
try{
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
$completion = CooperationCompletion::with(['order', 'media'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$rejectedCompletion = $completion->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
$completion->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerjasama <u>'. $completion->order->cooperation->name .'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan formulir penyelesaian kerjasama Anda.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir penyelesaian kerjasama <u>'. $completion->order->cooperation->name .'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan formulir penyelesaian kerjasama Anda.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($completion->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($rejectedCompletion) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak penyelesaian kerjasama.');
|
||||
} else {
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationCompletions (rejectAction): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak penyelesaian kerjasama');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak penyelesaian kerjasama.');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CooperationRequestController extends Controller
|
||||
{
|
||||
@ -50,48 +51,53 @@ public function mediaProposalShow($id){
|
||||
|
||||
public function accept(Request $request, $id){
|
||||
|
||||
if(!Auth::check() || Auth::user()->role_id !== 3){
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
$cooperation = Cooperation::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperation = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
// Pastikan data yang ingin diperbarui ada dan statusnya belum '3'
|
||||
if ($mediaCooperation->pivot->status == '0') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerjasama <u>'.$cooperation->name.'</u> <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name. '</u>',
|
||||
'content' => '<p>Ajuan Kerjasama <u>'.$cooperation->name.'</u> telah <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name.'</u></p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menerima kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menerima kerjasama.');
|
||||
try{
|
||||
if(!Auth::check() || Auth::user()->role_id !== 3){
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerjasama sudah diterima sebelumnya.');
|
||||
|
||||
$cooperation = Cooperation::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperation = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
// Pastikan data yang ingin diperbarui ada dan statusnya belum '3'
|
||||
if ($mediaCooperation->pivot->status == '0') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '1',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerjasama <u>'.$cooperation->name.'</u> <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name. '</u>',
|
||||
'content' => '<p>Ajuan Kerjasama <u>'.$cooperation->name.'</u> telah <span class="text-primary">diterima</span> oleh media <u>'.$mediaCooperation->name.'</u></p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menerima kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menerima kerjasama.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerjasama sudah diterima sebelumnya.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationRequest (accept): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
@ -114,34 +120,39 @@ public function createProposal($id){
|
||||
public function storeProposal(JournalistCooperationProposalRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
try{
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = decrypt_id($id);
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
|
||||
$createdCooperationProposal = CooperationProposal::create($validatedData);
|
||||
$createdCooperationProposal->journalists()->attach($validatedData['journalist_ids']);
|
||||
$createdCooperationProposal = CooperationProposal::create($validatedData);
|
||||
$createdCooperationProposal->journalists()->attach($validatedData['journalist_ids']);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.Auth::user()->company->media->name.'</u> telah mengirimkan formulir pengajuan kerjasama <u>'.$cooperation->name. '</u>',
|
||||
'content' => 'Media <u>'.Auth::user()->company->media->name.'</u> telah mengirimkan formulir pengajuan kerjasama <u>'.$cooperation->name. '</u> pada <b>'.idn_date($createdCooperationProposal->created_at, 'l, d F Y H:i').'</b>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.Auth::user()->company->media->name.'</u> telah mengirimkan formulir pengajuan kerjasama <u>'.$cooperation->name. '</u>',
|
||||
'content' => 'Media <u>'.Auth::user()->company->media->name.'</u> telah mengirimkan formulir pengajuan kerjasama <u>'.$cooperation->name. '</u> pada <b>'.idn_date($createdCooperationProposal->created_at, 'l, d F Y H:i').'</b>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($createdCooperationProposal->journalists()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.requests.index')->with('success-status', 'Berhasil melakukan pengajuan kerjasama.');
|
||||
} else {
|
||||
if ($createdCooperationProposal->journalists()->count() <= 0) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan pengajuan kerjasama');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.cooperations.requests.index')->with('success-status', 'Berhasil melakukan pengajuan kerjasama.');
|
||||
}
|
||||
|
||||
public function reject($id){
|
||||
@ -160,57 +171,62 @@ public function reject($id){
|
||||
|
||||
public function rejectAction(Request $request, $id){
|
||||
|
||||
if(!Auth::check() || Auth::user()->role_id !== 3){
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
try{
|
||||
if(!Auth::check() || Auth::user()->role_id !== 3){
|
||||
return abort(403, 'Unauthorized action.');
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$cooperation = Cooperation::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$mediaCooperation = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if (!$mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
|
||||
|
||||
if ($mediaCooperation->pivot->status != '3') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerjasama <u>'.$cooperation->name.'</u> <span class="text-danger fw-bold">ditolak</span> oleh media <u>'.$mediaCooperation->name. '</u>',
|
||||
'content' => '<p>Ajuan Kerjasama <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()
|
||||
];
|
||||
$cooperation = Cooperation::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
$mediaCooperation = $cooperation->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak kerjasama');
|
||||
if (!$mediaCooperation) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerjasama sudah ditolak sebelumnya.');
|
||||
|
||||
|
||||
if ($mediaCooperation->pivot->status != '3') {
|
||||
$affectedRows = $cooperation->media()->updateExistingPivot($mediaCooperation->id, [
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason'],
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan Kerjasama <u>'.$cooperation->name.'</u> <span class="text-danger fw-bold">ditolak</span> oleh media <u>'.$mediaCooperation->name. '</u>',
|
||||
'content' => '<p>Ajuan Kerjasama <u>'.$cooperation->name.'</u> <span class="text-danger">ditolak</span> oleh media <u>'.$mediaCooperation->name.'</u></p>
|
||||
<p>Alasan: <br> '.$validatedData['rejection_reason'].'</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak kerjasama');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerjasama sudah ditolak sebelumnya.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationRequest (rejectAction): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
@ -229,25 +245,30 @@ public function updateProposal(JournalistCooperationProposalRequest $request, $i
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $proposal->cooperation_id;
|
||||
try{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $proposal->cooperation_id;
|
||||
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
delete_file('app/public/uploads/cooperation-proposals/'.$proposal->image);
|
||||
}else{
|
||||
$validatedData['attachment'] = $proposal->attachment;
|
||||
}
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
delete_file('app/public/uploads/cooperation-proposals/'.$proposal->image);
|
||||
}else{
|
||||
$validatedData['attachment'] = $proposal->attachment;
|
||||
}
|
||||
|
||||
$proposal->update($validatedData);
|
||||
$proposal->update($validatedData);
|
||||
|
||||
if($request->has('journalist_ids')){
|
||||
$proposal->journalists()->sync($validatedData['journalist_ids']);
|
||||
}
|
||||
if($request->has('journalist_ids')){
|
||||
$proposal->journalists()->sync($validatedData['journalist_ids']);
|
||||
}
|
||||
|
||||
if ($proposal->journalists()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengajuan kerjasama.');
|
||||
} else {
|
||||
if ($proposal->journalists()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengajuan kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengajuan kerjasama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::error("CooperationRequest (updateProposal): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengajuan kerjasama');
|
||||
}
|
||||
|
||||
@ -262,6 +283,7 @@ public function destroyProposal($id){
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus ajuan kerjasama.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("CooperationRequest (destroyProposal): ". $e);
|
||||
return response()->json(['message' => 'Gagal menghapus ajuan kerjasama.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
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
|
||||
@ -26,7 +27,6 @@ public function create(){
|
||||
|
||||
public function store(GovernmentAgencyRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
try{
|
||||
$createdGovernmentAgency = GovernmentAgency::create($validatedData);
|
||||
@ -34,6 +34,7 @@ public function store(GovernmentAgencyRequest $request){
|
||||
return redirect()->route('dashboard.government.agencies.index')->with('success-status', 'Berhasil membuat OPD baru.')
|
||||
->with('new_data', encrypt_id($createdGovernmentAgency->id));
|
||||
}catch(\Exception $e){
|
||||
Log::error("GovernmentAgencies (store): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan OPD');
|
||||
}
|
||||
}
|
||||
@ -49,17 +50,17 @@ public function edit($id){
|
||||
|
||||
public function update(GovernmentAgencyRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
$updatedGovernmentAgency = $governmentAgency->update($validatedData);
|
||||
|
||||
if($updatedGovernmentAgency){
|
||||
return redirect()->route('dashboard.government.agencies.show', ['id' => encrypt_id($governmentAgency->id)])->with('success-status', 'Berhasil mengubah OPD.');
|
||||
}else{
|
||||
try{
|
||||
$governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
|
||||
$governmentAgency->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
Log::error("GovernmentAgencies (update): ". $e);
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah OPD');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.government.agencies.show', ['id' => encrypt_id($governmentAgency->id)])->with('success-status', 'Berhasil mengubah OPD.');
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
@ -79,6 +80,7 @@ public function destroy($id){
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus OPD']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("GovernmentAgencies (destroy): ". $e);
|
||||
return response()->json(['message' => 'Gagal menghapus OPD.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class IssueManagementController extends Controller
|
||||
@ -55,21 +56,27 @@ public function create(Request $request){
|
||||
}
|
||||
|
||||
public function store(IssueManagementRequest $request, $media_monitoring_id)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
$validatedData['media_monitoring_id'] = decrypt_id($media_monitoring_id);
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_monitoring_id'] = decrypt_id($media_monitoring_id);
|
||||
|
||||
$createdIssueManagement = IssueManagement::create($validatedData);
|
||||
try{
|
||||
$createdIssueManagement = DB::transaction(function()use($validatedData, $request){
|
||||
$createdIssueManagement = IssueManagement::create($validatedData);
|
||||
$createdIssueManagement->governmentAgencies()->attach($request->input('government_agencies'));
|
||||
|
||||
$createdIssueManagement->governmentAgencies()->attach($request->input('government_agencies'));
|
||||
return $createdIssueManagement;
|
||||
});
|
||||
|
||||
if ($createdIssueManagement->governmentAgencies()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan manajemen isu.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan manajemen isu');
|
||||
if ($createdIssueManagement->governmentAgencies()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan manajemen isu.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan manajemen isu');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan manajemen isu');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id) {
|
||||
@ -92,21 +99,22 @@ public function edit(Request $request, $id) {
|
||||
|
||||
public function update(IssueManagementRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location', 'subLocation', 'classification', 'subClassification', 'mediaMonitoring', 'enhancer'
|
||||
])->findOrFail(decrypt_id($id));
|
||||
$validatedData['media_monitoring_id'] = $issueManagement->media_monitoring_id;
|
||||
|
||||
$updatedIssueManagement = $issueManagement->update($validatedData);
|
||||
if ($request->has('government_agencies')) {
|
||||
$issueManagement->governmentAgencies()->sync($validatedData['government_agencies']);
|
||||
}
|
||||
try{
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location', 'subLocation', 'classification', 'subClassification', 'mediaMonitoring', 'enhancer'
|
||||
])->findOrFail(decrypt_id($id));
|
||||
$validatedData['media_monitoring_id'] = $issueManagement->media_monitoring_id;
|
||||
|
||||
if ($updatedIssueManagement) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah manajemen isu.');
|
||||
} else {
|
||||
$issueManagement->update($validatedData);
|
||||
if ($request->has('government_agencies')) {
|
||||
$issueManagement->governmentAgencies()->sync($validatedData['government_agencies']);
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah manajemen isu');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.issue.managements.show', ['id' => encrypt_id($issueManagement->id)])->with('success-status', 'Berhasil mengubah manajemen isu.');
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
@ -150,42 +158,56 @@ public function getSubClassifications($location_id)
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.issue.managements.index', $filterField);
|
||||
return redirect()->route('dashboard.issue.managements.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$classification = $request->input('classification', null);
|
||||
$sub_classification = $request->input('sub_classification', null);
|
||||
$location = $request->input('location', null);
|
||||
$sub_location = $request->input('sub_location', null);
|
||||
$government_agency = $request->input('government_agency', null);
|
||||
$issue = $request->input('issue', null);
|
||||
$response = $request->input('response', null);
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
try{
|
||||
$classification = $request->input('classification', null);
|
||||
$sub_classification = $request->input('sub_classification', null);
|
||||
$location = $request->input('location', null);
|
||||
$sub_location = $request->input('sub_location', null);
|
||||
$government_agency = $request->input('government_agency', null);
|
||||
$issue = $request->input('issue', null);
|
||||
$response = $request->input('response', null);
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
return Excel::download(new IssueManagementExport($classification, $sub_classification, $location, $sub_location, $government_agency, $issue, $response, $year, $month, $date), 'issue-managements-'.$formattedNow.'.xlsx');
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new IssueManagementExport($classification, $sub_classification, $location, $sub_location, $government_agency, $issue, $response, $year, $month, $date), 'issue-managements-'.$formattedNow.'.xlsx');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location', 'subLocation', 'classification', 'subClassification', 'governmentAgencies','enhancer', 'mediaMonitoring'
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
try{
|
||||
$issueManagement = IssueManagement::with([
|
||||
'location', 'subLocation', 'classification', 'subClassification', 'governmentAgencies','enhancer', 'mediaMonitoring'
|
||||
])->findOrFail(decrypt_id($id));
|
||||
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.issue-managements.print', compact('issueManagement'));
|
||||
$pdf = Pdf::loadView('dashboard.issue-managements.print', compact('issueManagement'));
|
||||
|
||||
return $pdf->stream(slugify('manajemen isu '. $issueManagement->mediaMonitoring->code).'.pdf');
|
||||
return $pdf->stream(slugify('manajemen isu '. $issueManagement->mediaMonitoring->code).'.pdf');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ public function create(){
|
||||
|
||||
public function store(LocationRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
try{
|
||||
$createdLocation = Location::create($validatedData);
|
||||
@ -49,7 +48,6 @@ public function edit($id){
|
||||
|
||||
public function update(LocationRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
try{
|
||||
$location = Location::findOrFail(decrypt_id($id));
|
||||
|
||||
@ -19,12 +19,17 @@ public function index(Request $request){
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.login.history.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan filtering data.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.login.history.index', $filterField);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,31 +53,32 @@ public function editRequest(){
|
||||
}
|
||||
|
||||
public function editRequestAction(Request $request){
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['0', '3'])){
|
||||
abort(404);
|
||||
}
|
||||
try{
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['0', '3'])){
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'edit_description' => ['required'],
|
||||
], [
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
$validatedData = $request->validate([
|
||||
'edit_description' => ['required'],
|
||||
], [
|
||||
'edit_description.required' => 'Deskripsi wajib diisi.',
|
||||
]);
|
||||
|
||||
if(!Auth::check()){
|
||||
abort(404);
|
||||
}
|
||||
if(!Auth::check()){
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$user = User::with(['company.media'])->findOrFail(Auth::id());
|
||||
$updatedMedia = $user->company->media->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description']
|
||||
]);
|
||||
|
||||
if($updatedMedia){
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil melakukan permohonan edit data media.');
|
||||
}else{
|
||||
$user = User::with(['company.media'])->findOrFail(Auth::id());
|
||||
$user->company->media->update([
|
||||
'edit_status' => '1',
|
||||
'edit_description' => $validatedData['edit_description']
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->route('dashboard.media.index')->with('failed-status', 'Gagal melakukan permohonan edit data media.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil melakukan permohonan edit data media.');
|
||||
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
@ -94,48 +95,49 @@ public function edit(){
|
||||
}
|
||||
|
||||
public function update(MediaRequest $request){
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['2'])){
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$media = User::with(['company.media'])->findOrFail(Auth::id())->company->media;
|
||||
|
||||
$fileFieldMap = [
|
||||
'media_journalism_organization_doc' => 'journalism_organization_doc',
|
||||
'media_press_council_certificate_doc' => 'press_council_certificate_doc',
|
||||
];
|
||||
|
||||
$mediaFileNames = [];
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$mediaFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/media')['randomFileName'];
|
||||
} else {
|
||||
$mediaFileNames[$requestKey] = $media->{$dbField};
|
||||
try{
|
||||
if(!in_array(Auth::user()->company->media->edit_status, ['2'])){
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
$updatedMedia = $media->update([
|
||||
'name' => $validatedData['media_name'],
|
||||
'address' => $validatedData['media_address'],
|
||||
'link' => $validatedData['media_link'],
|
||||
'type' => $validatedData['media_type'],
|
||||
'classification' => $validatedData['media_classification'],
|
||||
'journalism_organization' => $validatedData['media_journalism_organization'],
|
||||
'journalism_organization_doc' => $mediaFileNames['media_journalism_organization_doc'],
|
||||
'press_council_certificate' => $validatedData['media_press_council_certificate'],
|
||||
'press_council_certificate_doc' => $mediaFileNames['media_press_council_certificate_doc'],
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
|
||||
if($updatedMedia){
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil mengubah data media.');
|
||||
}else{
|
||||
$media = User::with(['company.media'])->findOrFail(Auth::id())->company->media;
|
||||
|
||||
$fileFieldMap = [
|
||||
'media_journalism_organization_doc' => 'journalism_organization_doc',
|
||||
'media_press_council_certificate_doc' => 'press_council_certificate_doc',
|
||||
];
|
||||
|
||||
$mediaFileNames = [];
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$mediaFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/media')['randomFileName'];
|
||||
} else {
|
||||
$mediaFileNames[$requestKey] = $media->{$dbField};
|
||||
}
|
||||
}
|
||||
|
||||
$updatedMedia = $media->update([
|
||||
'name' => $validatedData['media_name'],
|
||||
'address' => $validatedData['media_address'],
|
||||
'link' => $validatedData['media_link'],
|
||||
'type' => $validatedData['media_type'],
|
||||
'classification' => $validatedData['media_classification'],
|
||||
'journalism_organization' => $validatedData['media_journalism_organization'],
|
||||
'journalism_organization_doc' => $mediaFileNames['media_journalism_organization_doc'],
|
||||
'press_council_certificate' => $validatedData['media_press_council_certificate'],
|
||||
'press_council_certificate_doc' => $mediaFileNames['media_press_council_certificate_doc'],
|
||||
'edit_description' => null,
|
||||
'edit_status' => '0',
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->route('dashboard.media.index')->with('failed-status', 'Gagal mengubah data media.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.index')->with('success-status', 'Berhasil mengubah data media.');
|
||||
}
|
||||
|
||||
public function show($id, $type){
|
||||
@ -152,18 +154,29 @@ public function show($id, $type){
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // optional: menangani type yang tidak dikenal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function destroy(){}
|
||||
@ -187,17 +200,27 @@ public function process(Request $request, $id, $type){
|
||||
'category' => $request->query('category', null)
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // atau bisa redirect atau response lainnya jika $type tidak valid
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,38 +270,49 @@ public function processRejectAction(Request $request, $id, $type, $category){
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$type = $request->input('type', null);
|
||||
$classification = $request->input('classification', null);
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
try{
|
||||
$type = $request->input('type', null);
|
||||
$classification = $request->input('classification', null);
|
||||
$status = $request->input('status', null);
|
||||
$edit_status = $request->input('edit_status', null);
|
||||
$address = $request->input('address', null);
|
||||
$register_year = $request->input('register_year', null);
|
||||
$register_month = $request->input('register_month', null);
|
||||
$register_date = $request->input('register_date', null);
|
||||
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
$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');
|
||||
return Excel::download(new MediaExport($type, $classification, $status, $edit_status, $address, $register_year, $register_month, $register_date), 'media-'.$formattedNow.'.xlsx');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.media.index', $filterField);
|
||||
return redirect()->route('dashboard.media.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
|
||||
$media = Media::with(['user.role', 'company'])->findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$media = Media::with(['user.role', 'company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.media.print', compact('media'));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.media.print', compact('media'));
|
||||
|
||||
return $pdf->stream('media-'.slugify($media->name).'.pdf');
|
||||
return $pdf->stream('media-'.slugify($media->name).'.pdf');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
use App\Models\MediaOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MediaCooperationController extends Controller
|
||||
{
|
||||
@ -29,37 +30,44 @@ public function create(){
|
||||
|
||||
public function store(CooperationRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
try{
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
|
||||
$createdCooperation = Cooperation::create($validatedData);
|
||||
$createdCooperation->media()->attach($validatedData['media_ids']);
|
||||
$createdCooperation = DB::transaction(function()use($validatedData){
|
||||
$createdCooperation = Cooperation::create($validatedData);
|
||||
$createdCooperation->media()->attach($validatedData['media_ids']);
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan kerjasama baru: <u>'. $createdCooperation->name. '</u>',
|
||||
'content' => '<p>Kerjasama: <b>'. $validatedData['name']. '</b> </p>
|
||||
<p>Periode Pengajuan: <b>'.idn_date($createdCooperation->start_date).'</b> s.d. <b>'.idn_date($createdCooperation->end_date).'</b></p>
|
||||
<p>Deskripsi: <br>
|
||||
'.$createdCooperation->description.'
|
||||
</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Ajuan kerjasama baru: <u>'. $createdCooperation->name. '</u>',
|
||||
'content' => '<p>Kerjasama: <b>'. $validatedData['name']. '</b> </p>
|
||||
<p>Periode Pengajuan: <b>'.idn_date($createdCooperation->start_date).'</b> s.d. <b>'.idn_date($createdCooperation->end_date).'</b></p>
|
||||
<p>Deskripsi: <br>
|
||||
'.$createdCooperation->description.'
|
||||
</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($createdCooperation->media()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.index')->with('success-status', 'Berhasil menambahkan kerjasama.');
|
||||
} else {
|
||||
return $createdCooperation;
|
||||
});
|
||||
|
||||
if ($createdCooperation->media()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.index')->with('success-status', 'Berhasil menambahkan kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan kerjasama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan kerjasama');
|
||||
}
|
||||
}
|
||||
@ -76,54 +84,56 @@ public function edit($id){
|
||||
|
||||
public function update(CooperationRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
$oldCooperationName = $cooperation->name;
|
||||
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
try{
|
||||
$cooperation = Cooperation::with(['media'])->findOrFail(decrypt_id($id));
|
||||
$oldCooperationName = $cooperation->name;
|
||||
|
||||
if($request->hasFile('banner')){
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->banner);
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['banner'] = $cooperation->banner;
|
||||
}
|
||||
if($request->hasFile('banner')){
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->banner);
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['banner'] = $cooperation->banner;
|
||||
}
|
||||
|
||||
if($request->hasFile('offer_file_template')){
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->offer_file_template);
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['offer_file_template'] = $cooperation->offer_file_template;
|
||||
}
|
||||
if($request->hasFile('offer_file_template')){
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->offer_file_template);
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['offer_file_template'] = $cooperation->offer_file_template;
|
||||
}
|
||||
|
||||
$cooperation->update($validatedData);
|
||||
if ($request->has('media_ids')) {
|
||||
$cooperation->media()->sync($validatedData['media_ids']);
|
||||
}
|
||||
$cooperation->update($validatedData);
|
||||
if ($request->has('media_ids')) {
|
||||
$cooperation->media()->sync($validatedData['media_ids']);
|
||||
}
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
|
||||
$announcementData = [
|
||||
'headline' => 'Admin melakukan pembaruan pada ajuan kerjasama <u>'. $oldCooperationName. '</u>',
|
||||
'content' => '<p>Admin telah melakukan pembaruan pada kerjasama <u>' . $oldCooperationName . '</u>.
|
||||
Mohon untuk segera meninjau perubahan tersebut</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Admin melakukan pembaruan pada ajuan kerjasama <u>'. $oldCooperationName. '</u>',
|
||||
'content' => '<p>Admin telah melakukan pembaruan pada kerjasama <u>' . $oldCooperationName . '</u>.
|
||||
Mohon untuk segera meninjau perubahan tersebut</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($cooperation->media()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah kerjasama.');
|
||||
} else {
|
||||
if ($cooperation->media()->count() > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah kerjasama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah kerjasama');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
@ -154,26 +164,31 @@ public function mediaProposalShow($id, $proposalId){
|
||||
}
|
||||
|
||||
public function mediaProposalAccept($id, $proposalId){
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
$acceptedProposal = $proposal->update([
|
||||
'status' => '1'
|
||||
]);
|
||||
try{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerjasama <u>'. $proposal->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui formulir pengajuan kerjasama Anda.</p>
|
||||
<p>Sekarang, kerjasama ini sudah tersedia di menu <b>Kerjasama</b>. Harap tunggu hingga Admin menerbitkan <b>Media Order</b>.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
$acceptedProposal = $proposal->update([
|
||||
'status' => '1'
|
||||
]);
|
||||
|
||||
if ($acceptedProposal) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui pengajuan kerjasama.');
|
||||
} else {
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerjasama <u>'. $proposal->cooperation->name .'</u> telah <span class="text-primary">disetujui</span>',
|
||||
'content' => '<p>Admin telah menyetujui formulir pengajuan kerjasama Anda.</p>
|
||||
<p>Sekarang, kerjasama ini sudah tersedia di menu <b>Kerjasama</b>. Harap tunggu hingga Admin menerbitkan <b>Media Order</b>.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($acceptedProposal) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menyetujui pengajuan kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui pengajuan kerjasama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menyetujui pengajuan kerjasama');
|
||||
}
|
||||
|
||||
@ -196,29 +211,33 @@ public function mediaProposalRejectAction(Request $request, $id, $proposalId){
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
try{
|
||||
$proposal = CooperationProposal::with(['cooperation', 'media', 'journalists'])->findOrFail(decrypt_id($proposalId));
|
||||
|
||||
$rejectedProposal = $proposal->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
$rejectedProposal = $proposal->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerjasama <u>'. $proposal->cooperation->name .'</u> <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak formulir pengajuan kerjasama Anda.
|
||||
<p>Alasan penolakan:<br> '.$validatedData['rejection_reason'].' </p>
|
||||
</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Formulir ajuan kerjasama <u>'. $proposal->cooperation->name .'</u> <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak formulir pengajuan kerjasama Anda.
|
||||
<p>Alasan penolakan:<br> '.$validatedData['rejection_reason'].' </p>
|
||||
</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($proposal->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($rejectedProposal) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak pengajuan kerjasama.');
|
||||
} else {
|
||||
if ($rejectedProposal) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak pengajuan kerjasama.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak pengajuan kerjasama');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak pengajuan kerjasama');
|
||||
}
|
||||
|
||||
|
||||
@ -38,23 +38,22 @@ public function create(){
|
||||
|
||||
public function store(MediaMonitoringRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$latestCode = MediaMonitoring::max('code');
|
||||
$lastNumber = $latestCode ? intval(substr($latestCode, 3)) : 0;
|
||||
$newNumber = str_pad($lastNumber + 1, 6, '0', STR_PAD_LEFT);
|
||||
$code = 'ADN'.$newNumber;
|
||||
try{
|
||||
$latestCode = MediaMonitoring::max('code');
|
||||
$lastNumber = $latestCode ? intval(substr($latestCode, 3)) : 0;
|
||||
$newNumber = str_pad($lastNumber + 1, 6, '0', STR_PAD_LEFT);
|
||||
$code = 'ADN'.$newNumber;
|
||||
|
||||
$validatedData['code'] = $code;
|
||||
$validatedData['image'] = store_file($validatedData['image'], 'uploads/media-monitorings')['randomFileName'];
|
||||
$validatedData['code'] = $code;
|
||||
$validatedData['image'] = store_file($validatedData['image'], 'uploads/media-monitorings')['randomFileName'];
|
||||
|
||||
$createMediaMonitoring = MediaMonitoring::create($validatedData);
|
||||
|
||||
if($createMediaMonitoring){
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan monitoring media.');
|
||||
}else{
|
||||
MediaMonitoring::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan monitoring media.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan monitoring media.');
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
@ -70,24 +69,23 @@ public function edit($id){
|
||||
public function update(MediaMonitoringRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
$validatedData['code'] = $mediaMonitoring->code;
|
||||
try{
|
||||
$mediaMonitoring = MediaMonitoring::findOrFail(decrypt_id($id));
|
||||
$validatedData['code'] = $mediaMonitoring->code;
|
||||
|
||||
if($request->has('image')){
|
||||
delete_file('app/public/uploads/media-monitorings/'.$mediaMonitoring->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-monitorings')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $mediaMonitoring->image;
|
||||
}
|
||||
if($request->has('image')){
|
||||
delete_file('app/public/uploads/media-monitorings/'.$mediaMonitoring->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-monitorings')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $mediaMonitoring->image;
|
||||
}
|
||||
|
||||
$updatedMediaMonitoring = $mediaMonitoring->update($validatedData);
|
||||
|
||||
if($updatedMediaMonitoring){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah monitoring media.');
|
||||
}else{
|
||||
$mediaMonitoring->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah monitoring media.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.media.monitorings.show', ['id' => encrypt_id($mediaMonitoring->id)])->with('success-status', 'Berhasil mengubah monitoring media.');
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
@ -124,44 +122,54 @@ public function checkLink(Request $request)
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
// if(!$request->has('news_title')){
|
||||
// unset($filteredRequest['news_title']);
|
||||
// }
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
return redirect()->route('dashboard.media.monitorings.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses filter data.');
|
||||
}
|
||||
|
||||
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');
|
||||
try{
|
||||
$news_title = $request->input('news_title', null);
|
||||
$channel = $request->input('channel', 'all');
|
||||
$issue_status = $request->input('issue_status', 'all');
|
||||
$keyword = $request->input('keywords', 'all');
|
||||
$input_year = $request->input('input_year', null);
|
||||
$input_month = $request->input('input_month', null);
|
||||
$input_date = $request->input('input_date', null);
|
||||
$release_year = $request->input('release_year', null);
|
||||
$release_month = $request->input('release_month', null);
|
||||
$release_date = $request->input('release_date', null);
|
||||
|
||||
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');
|
||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||
|
||||
return Excel::download(new MediaMonitoringExport($news_title, $channel, $issue_status, $keyword, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date), 'media-monitoring-'.$formattedNow.'.xlsx');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan export data.');
|
||||
}
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
|
||||
$mediaMonitoring = MediaMonitoring::with(['enhancer', 'issue'])->findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$mediaMonitoring = MediaMonitoring::with(['enhancer', 'issue'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.media-monitorings.print', compact('mediaMonitoring'));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.media-monitorings.print', compact('mediaMonitoring'));
|
||||
return $pdf->stream(slugify('monitoring media '. $mediaMonitoring->code).'.pdf');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan print data.');
|
||||
}
|
||||
|
||||
return $pdf->stream(slugify('monitoring media '. $mediaMonitoring->code).'.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MediaOrderController extends Controller
|
||||
{
|
||||
@ -28,33 +29,41 @@ public function create($id){
|
||||
|
||||
public function store(OrderRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $cooperation->id;
|
||||
try{
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
$createdOrder = Order::create($validatedData);
|
||||
$createdOrder->media()->attach($validatedData['media_ids']);
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $cooperation->id;
|
||||
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
$createdOrder = DB::transaction(function()use($validatedData, $cooperation){
|
||||
$createdOrder = Order::create($validatedData);
|
||||
$createdOrder->media()->attach($validatedData['media_ids']);
|
||||
|
||||
$announcementData = [
|
||||
'headline' => '<p>Admin telah menerbitkan media order kerjasama <u>'. $cooperation->name .'</u></p>',
|
||||
'content' => '<p>Admin telah menerbitkan media order kerjasama '.$cooperation->name.'</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
// Announcements
|
||||
$userId = [];
|
||||
foreach($validatedData['media_ids'] as $mediaId){
|
||||
$userId[] = Media::find($mediaId)->company->user->id;
|
||||
}
|
||||
|
||||
if ($createdOrder->media()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.process', ['id' => encrypt_id($cooperation->id), 'process' => 'media-order'])->with('success-status', 'Berhasil membuat media order.');
|
||||
} else {
|
||||
$announcementData = [
|
||||
'headline' => '<p>Admin telah menerbitkan media order kerjasama <u>'. $cooperation->name .'</u></p>',
|
||||
'content' => '<p>Admin telah menerbitkan media order kerjasama '.$cooperation->name.'</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($userId, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
return $createdOrder;
|
||||
});
|
||||
|
||||
if ($createdOrder->media()->count() > 0) {
|
||||
return redirect()->route('dashboard.cooperations.process', ['id' => encrypt_id($cooperation->id), 'process' => 'media-order'])->with('success-status', 'Berhasil membuat media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat media order');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat media order');
|
||||
}
|
||||
}
|
||||
@ -79,29 +88,32 @@ public function edit($id){
|
||||
|
||||
public function update(OrderRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$mediaOrder = Order::findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$mediaOrder = Order::findOrFail(decrypt_id($id));
|
||||
|
||||
$validatedData['cooperation_id'] = $mediaOrder->cooperation_id;
|
||||
$validatedData['cooperation_id'] = $mediaOrder->cooperation_id;
|
||||
|
||||
if($request->hasFile('image')){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
if($request->hasFile('image')){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/media-orders/'.$mediaOrder->image);
|
||||
}else{
|
||||
$validatedData['image'] = $mediaOrder->image;
|
||||
}
|
||||
delete_file('app/public/uploads/media-orders/'.$mediaOrder->image);
|
||||
}else{
|
||||
$validatedData['image'] = $mediaOrder->image;
|
||||
}
|
||||
|
||||
$mediaOrder->update($validatedData);
|
||||
$mediaOrder->update($validatedData);
|
||||
|
||||
if ($request->has('media_ids')) {
|
||||
$mediaOrder->media()->sync($validatedData['media_ids']);
|
||||
}
|
||||
if ($request->has('media_ids')) {
|
||||
$mediaOrder->media()->sync($validatedData['media_ids']);
|
||||
}
|
||||
|
||||
if ($mediaOrder->media()->exists()) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah media order.');
|
||||
} else {
|
||||
if ($mediaOrder->media()->exists()) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah media order');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah media order');
|
||||
}
|
||||
}
|
||||
@ -158,46 +170,51 @@ public function reject(Request $request, $id){
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$order = Order::with('media')->findOrFail(decrypt_id($id));
|
||||
try{
|
||||
|
||||
$mediaOrder = $order->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
$order = Order::with('media')->findOrFail(decrypt_id($id));
|
||||
|
||||
if (!$mediaOrder) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
$mediaOrder = $order->media()
|
||||
->where('media.id', Auth::user()->company->media->id)
|
||||
->first();
|
||||
|
||||
if ($mediaOrder->pivot->status == '0') {
|
||||
$affectedRows = $order->media()->updateExistingPivot($mediaOrder->id, [
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.$mediaOrder->name.'</u> <span class="text-danger">menolak</span> media order kerjasama <u>'.$order->cooperation->name. '</u>',
|
||||
'content' => 'Media <u>'.$mediaOrder->name.'</u> <span class="text-danger">menolak</span> media order kerjasama <u>'.$order->cooperation->name.'</u>
|
||||
<p>Alasan: <br> '.$validatedData['rejection_reason'].'</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak media order.');
|
||||
if (!$mediaOrder) {
|
||||
return abort(404, 'Media not found for the cooperation.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerjasama sudah diterima sebelumnya.');
|
||||
|
||||
if ($mediaOrder->pivot->status == '0') {
|
||||
$affectedRows = $order->media()->updateExistingPivot($mediaOrder->id, [
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Media <u>'.$mediaOrder->name.'</u> <span class="text-danger">menolak</span> media order kerjasama <u>'.$order->cooperation->name. '</u>',
|
||||
'content' => 'Media <u>'.$mediaOrder->name.'</u> <span class="text-danger">menolak</span> media order kerjasama <u>'.$order->cooperation->name.'</u>
|
||||
<p>Alasan: <br> '.$validatedData['rejection_reason'].'</p>
|
||||
',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
|
||||
$adminIds = User::where('role_id', 1)->pluck('id')->mapWithKeys(function ($id) {
|
||||
return [$id => ['category' => 'system']];
|
||||
})->toArray();
|
||||
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($adminIds);
|
||||
// End Announcements
|
||||
|
||||
if ($affectedRows > 0) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak media order.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak media order.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Kerjasama sudah diterima sebelumnya.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak media order.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public function store(NewsRequest $request){
|
||||
if($request->has('image')){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
}
|
||||
$createdNews = News::create($validatedData);
|
||||
News::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat berita baru.');
|
||||
}
|
||||
@ -104,8 +104,8 @@ public function show($id){
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
DB::transaction(function () use ($id) {
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
DB::transaction(function () use ($id, $news) {
|
||||
|
||||
$newSlug = Str::limit($news->slug . '-deleted-' . now()->timestamp, 191);
|
||||
|
||||
@ -128,33 +128,49 @@ public function destroy($id)
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$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');
|
||||
try{
|
||||
$category = $request->input('category', 'all');
|
||||
$year = $request->input('year', null);
|
||||
$month = $request->input('month', null);
|
||||
$date = $request->input('date', null);
|
||||
|
||||
return Excel::download(new NewsExport($category, $year, $month, $date), 'news.xlsx');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses export data.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter(Request $request){
|
||||
|
||||
$filteredRequest = $request->except('_token');
|
||||
try{
|
||||
$filteredRequest = $request->except('_token');
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.news.index', $filterField);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('status-failed', 'Gagal melakukan proses filtering data.');
|
||||
}
|
||||
|
||||
$filterField = array_filter($filteredRequest, function ($value) {
|
||||
return filled($value);
|
||||
});
|
||||
|
||||
return redirect()->route('dashboard.news.index', $filterField);
|
||||
}
|
||||
|
||||
public function printData($slug){
|
||||
|
||||
$news = News::where('slug', $slug)->first();
|
||||
try{
|
||||
$news = News::where('slug', $slug)->first();
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.news.print', compact('news'));
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.news.print', compact('news'));
|
||||
return $pdf->stream('berita-'.$news->slug.'.pdf');
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal melakukan proses print data.');
|
||||
}
|
||||
|
||||
return $pdf->stream('berita-'.$news->slug.'.pdf');
|
||||
}
|
||||
|
||||
public function checkLink(Request $request)
|
||||
|
||||
@ -20,18 +20,18 @@ public function create($id){
|
||||
|
||||
public function store(ReportRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
try{
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
$createdReport = Report::create($validatedData);
|
||||
|
||||
if($createdReport){
|
||||
return redirect()->route('dashboard.cooperations.process', ['id' => $id, 'process' => 'reports'])->with('success-status', 'Berhasil menambahkan laporan.');
|
||||
}else{
|
||||
Report::create($validatedData);
|
||||
}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){
|
||||
@ -50,21 +50,25 @@ public function update(ReportRequest $request, $mediaOrderId, $id){
|
||||
$validatedData['order_id'] = decrypt_id($mediaOrderId);
|
||||
$validatedData['status'] = '0';
|
||||
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
if($request->hasFile('image')){
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
if($request->hasFile('image')){
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/reports/'.$report->proof);
|
||||
}else{
|
||||
$validatedData['proof'] = $report->proof;
|
||||
}
|
||||
delete_file('app/public/uploads/reports/'.$report->proof);
|
||||
}else{
|
||||
$validatedData['proof'] = $report->proof;
|
||||
}
|
||||
|
||||
$updatedReport = $report->update($validatedData);
|
||||
$updatedReport = $report->update($validatedData);
|
||||
|
||||
if($updatedReport){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah laporan.');
|
||||
}else{
|
||||
if($updatedReport){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah laporan.');
|
||||
}else{
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah laporan.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah laporan.');
|
||||
}
|
||||
}
|
||||
@ -120,26 +124,30 @@ public function rejectAction(Request $request, $mediaOrderId, $id){
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
try{
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
$rejectedReport = $report->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
$rejectedReport = $report->update([
|
||||
'status' => '2',
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Laporan bukti tayang kerjasama <u>'. $report->order->cooperation->name .'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan bukti tayang Anda.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
// Announcements
|
||||
$announcementData = [
|
||||
'headline' => 'Laporan bukti tayang kerjasama <u>'. $report->order->cooperation->name .'</u> telah <span class="text-danger">ditolak</span>',
|
||||
'content' => '<p>Admin telah menolak laporan bukti tayang Anda.</p>',
|
||||
'enhancer_id' => Auth::id()
|
||||
];
|
||||
$createdAnnouncement = Announcement::create($announcementData);
|
||||
$createdAnnouncement->users()->attach($report->media->company->user->id, ['category' => 'system']);
|
||||
// End Announcements
|
||||
|
||||
if ($rejectedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak laporan bukti tayang.');
|
||||
} else {
|
||||
if ($rejectedReport) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak laporan bukti tayang.');
|
||||
} else {
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menolak laporan bukti tayang');
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,45 +18,49 @@ public function index(){
|
||||
public function update(SettingRequest $request)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
$settings = app(AppSettings::class);
|
||||
|
||||
$files = ['app_icon', 'app_logo'];
|
||||
$validFile = [];
|
||||
try{
|
||||
$settings = app(AppSettings::class);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$savedFile = store_file($request->file($file), 'uploads/settings');
|
||||
$validFile[$file] = $savedFile['randomFileName'];
|
||||
} else {
|
||||
$validFile[$file] = $settings->$file;
|
||||
$files = ['app_icon', 'app_logo'];
|
||||
$validFile = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$savedFile = store_file($request->file($file), 'uploads/settings');
|
||||
$validFile[$file] = $savedFile['randomFileName'];
|
||||
} else {
|
||||
$validFile[$file] = $settings->$file;
|
||||
}
|
||||
}
|
||||
|
||||
$settings->fill([
|
||||
'app_name' => $validatedData['app_name'] ?? $settings->app_name,
|
||||
'app_title' => $validatedData['app_title'] ?? $settings->app_title,
|
||||
'app_description' => $validatedData['app_description'] ?? $settings->app_description,
|
||||
'app_keywords' => $validatedData['app_keywords'] ?? $settings->app_keywords,
|
||||
'app_icon' => $validFile['app_icon'] ?? $settings->app_icon,
|
||||
'app_logo' => $validFile['app_logo'] ?? $settings->app_logo,
|
||||
'contact_address' => $validatedData['contact_address'] ?? $settings->contact_address,
|
||||
'contact_address_link' => $validatedData['contact_address_link'] ?? $settings->contact_address_link,
|
||||
'contact_phone' => $validatedData['contact_phone'] ?? $settings->contact_phone,
|
||||
'contact_email' => $validatedData['contact_email'] ?? $settings->contact_email,
|
||||
'contact_facebook' => $validatedData['contact_facebook'] ?? $settings->contact_facebook,
|
||||
'contact_twitter' => $validatedData['contact_twitter'] ?? $settings->contact_twitter,
|
||||
'contact_instagram' => $validatedData['contact_instagram'] ?? $settings->contact_instagram,
|
||||
'contact_youtube' => $validatedData['contact_youtube'] ?? $settings->contact_youtube,
|
||||
'contact_whatsapp' => $validatedData['contact_whatsapp'] ?? $settings->contact_whatsapp,
|
||||
'contact_telegram' => $validatedData['contact_telegram'] ?? $settings->contact_telegram,
|
||||
'about_us' => $validatedData['about_us'] ?? $settings->about_us,
|
||||
]);
|
||||
|
||||
if ($settings->save()) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah informasi aplikasi.');
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah informasi aplikasi.');
|
||||
}
|
||||
|
||||
$settings->fill([
|
||||
'app_name' => $validatedData['app_name'] ?? $settings->app_name,
|
||||
'app_title' => $validatedData['app_title'] ?? $settings->app_title,
|
||||
'app_description' => $validatedData['app_description'] ?? $settings->app_description,
|
||||
'app_keywords' => $validatedData['app_keywords'] ?? $settings->app_keywords,
|
||||
'app_icon' => $validFile['app_icon'] ?? $settings->app_icon,
|
||||
'app_logo' => $validFile['app_logo'] ?? $settings->app_logo,
|
||||
'contact_address' => $validatedData['contact_address'] ?? $settings->contact_address,
|
||||
'contact_address_link' => $validatedData['contact_address_link'] ?? $settings->contact_address_link,
|
||||
'contact_phone' => $validatedData['contact_phone'] ?? $settings->contact_phone,
|
||||
'contact_email' => $validatedData['contact_email'] ?? $settings->contact_email,
|
||||
'contact_facebook' => $validatedData['contact_facebook'] ?? $settings->contact_facebook,
|
||||
'contact_twitter' => $validatedData['contact_twitter'] ?? $settings->contact_twitter,
|
||||
'contact_instagram' => $validatedData['contact_instagram'] ?? $settings->contact_instagram,
|
||||
'contact_youtube' => $validatedData['contact_youtube'] ?? $settings->contact_youtube,
|
||||
'contact_whatsapp' => $validatedData['contact_whatsapp'] ?? $settings->contact_whatsapp,
|
||||
'contact_telegram' => $validatedData['contact_telegram'] ?? $settings->contact_telegram,
|
||||
'about_us' => $validatedData['about_us'] ?? $settings->about_us,
|
||||
]);
|
||||
|
||||
if ($settings->save()) {
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah informasi aplikasi.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah informasi aplikasi.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -43,7 +43,6 @@ public function create(Request $request){
|
||||
|
||||
public function store(SubLocationRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
try{
|
||||
$createdSubLocation = SubLocation::create($validatedData);
|
||||
@ -67,7 +66,6 @@ public function edit($id){
|
||||
|
||||
public function update(SubLocationRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
try{
|
||||
$subLocation = SubLocation::findOrFail(decrypt_id($id));
|
||||
|
||||
@ -19,7 +19,7 @@ class UserController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
return view('dashboard.users.index', [
|
||||
'title' => 'Pengguna',
|
||||
'title' => 'Data Pengguna',
|
||||
'role' => $request->input('role', null),
|
||||
'status' => $request->input('status', null),
|
||||
]);
|
||||
@ -27,7 +27,7 @@ public function index(Request $request){
|
||||
|
||||
public function create(){
|
||||
return view('dashboard.users.create', [
|
||||
'title' => 'Tambah Pengguna',
|
||||
'title' => 'Buat Pengguna Baru',
|
||||
'roles' => Role::all()
|
||||
]);
|
||||
}
|
||||
@ -35,14 +35,13 @@ public function create(){
|
||||
public function store(UserRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$createdUser = User::create($validatedData);
|
||||
|
||||
if($createdUser){
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan pengguna.');
|
||||
}else{
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan pengguna.');
|
||||
try{
|
||||
User::create($validatedData);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal membuat pengguna baru.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil membuat pengguna baru.');
|
||||
|
||||
}
|
||||
|
||||
@ -59,20 +58,14 @@ public function edit($id){
|
||||
public function update(UserRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
if (isset($validatedData['password']) && !empty($validatedData['password'])) {
|
||||
$validatedData['password'] = $request->input('password');
|
||||
} else {
|
||||
unset($validatedData['password']);
|
||||
}
|
||||
|
||||
$user = User::findOrFail(decrypt_id($id));
|
||||
$updatedUser = $user->update($validatedData);
|
||||
|
||||
if($updatedUser){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengguna.');
|
||||
}else{
|
||||
try{
|
||||
$user = User::findOrFail(decrypt_id($id));
|
||||
$user->update($validatedData);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah pengguna.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah pengguna.');
|
||||
}
|
||||
|
||||
public function show($id, $type){
|
||||
@ -86,18 +79,27 @@ public function show($id, $type){
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function resetPassword($id){
|
||||
@ -113,15 +115,15 @@ public function resetPassword($id){
|
||||
public function resetPasswordAction(ResetPasswordRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$updatedUser = User::findOrFail(decrypt_id($id))->update([
|
||||
'password' => $validatedData['password']
|
||||
]);
|
||||
|
||||
if($updatedUser){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mereset password pengguna.');
|
||||
}else{
|
||||
try{
|
||||
User::findOrFail(decrypt_id($id))->update([
|
||||
'password' => $validatedData['password']
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mereset password pengguna.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mereset password pengguna.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
@ -165,17 +167,27 @@ public function profile($type){
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', Auth::user()->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', Auth::user()->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // atau bisa redirect atau handling lainnya jika tipe tidak dikenali
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,53 +214,68 @@ public function process($id, $type, $process){
|
||||
'process' => $process,
|
||||
];
|
||||
|
||||
if($type === 'account'){
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
}elseif($type === 'login-activities'){
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)->orderByDesc('id')->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
}elseif($type === 'company'){
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
}elseif($type === 'media'){
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
}elseif($type === 'journalists'){
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
switch ($type) {
|
||||
case 'account':
|
||||
return view('dashboard.users.profiles.account', $data);
|
||||
|
||||
case 'login-activities':
|
||||
$data['loginActivities'] = LoginHistory::where('user_id', $user->id)
|
||||
->orderByDesc('id')
|
||||
->simplePaginate(20);
|
||||
return view('dashboard.users.profiles.login-activity', $data);
|
||||
|
||||
case 'company':
|
||||
return view('dashboard.users.profiles.company', $data);
|
||||
|
||||
case 'media':
|
||||
return view('dashboard.users.profiles.media', $data);
|
||||
|
||||
case 'journalists':
|
||||
return view('dashboard.users.profiles.journalists', $data);
|
||||
|
||||
default:
|
||||
abort(404); // untuk menangani tipe yang tidak dikenal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function statusAction(Request $request, $id, $action){
|
||||
$user = User::findOrFail(decrypt_id($id));
|
||||
|
||||
if($user->status === '0' && Auth::check() && is_role(['1'])){
|
||||
if($action == 'accept'){
|
||||
$user->update([
|
||||
'status' => '1'
|
||||
]);
|
||||
try{
|
||||
if($user->status === '0' && Auth::check() && is_role(['1'])){
|
||||
if($action == 'accept'){
|
||||
$user->update([
|
||||
'status' => '1'
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'accepted'));
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'accepted'));
|
||||
|
||||
return response()->json(['message' => 'Berhasil menyetujui pengguna.']);
|
||||
}else if($action == 'reject'){
|
||||
return response()->json(['message' => 'Berhasil menyetujui pengguna.']);
|
||||
}else if($action == 'reject'){
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
$validatedData = $request->validate([
|
||||
'rejection_reason' => ['required'],
|
||||
], [
|
||||
'rejection_reason.required' => 'Alasan penolakan wajib diisi.',
|
||||
]);
|
||||
|
||||
$user->update([
|
||||
'status' => '3'
|
||||
]);
|
||||
$user->update([
|
||||
'status' => '3'
|
||||
]);
|
||||
|
||||
$user->company->update([
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
$user->company->update([
|
||||
'rejection_reason' => $validatedData['rejection_reason']
|
||||
]);
|
||||
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'rejected', strip_tags($validatedData['rejection_reason'])));
|
||||
Mail::to($user->email)->send(new AccountVerification($user, 'rejected', strip_tags($validatedData['rejection_reason'])));
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak pengguna.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil menolak pengguna.');
|
||||
}
|
||||
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Proses gagal.');
|
||||
}
|
||||
|
||||
}
|
||||
@ -265,17 +292,17 @@ public function setting(){
|
||||
public function settingAction(AccountSettingRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$updatedUser = $user->update([
|
||||
'name' => $validatedData['name'],
|
||||
'email' => $validatedData['email'],
|
||||
]);
|
||||
|
||||
if($updatedUser){
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah data akun.');
|
||||
}else{
|
||||
try{
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$user->update([
|
||||
'name' => $validatedData['name'],
|
||||
'email' => $validatedData['email'],
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah data akun.');
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah data akun.');
|
||||
}
|
||||
|
||||
public function changePassword(){
|
||||
@ -291,15 +318,16 @@ public function changePassword(){
|
||||
public function changePasswordAction(ChangePasswordRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$updatedUser = User::findOrFail(Auth::id())->update([
|
||||
'password' => $validatedData['password']
|
||||
]);
|
||||
|
||||
if($updatedUser){
|
||||
return redirect()->route('dashboard.users.setting')->with('success-status', 'Berhasil mengubah password.');
|
||||
}else{
|
||||
try{
|
||||
$user = User::findOrFail(Auth::id());
|
||||
$user->update([
|
||||
'password' => $validatedData['password']
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah password.');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.users.setting')->with('success-status', 'Berhasil mengubah password.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ public function rules(): array
|
||||
'classification_id' => ['required', 'exists:content_recap_classifications,id', 'not_in:placeholder'],
|
||||
'social_media' => ['required', 'not_in:placeholder'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
@ -46,6 +47,7 @@ protected function prepareForValidation()
|
||||
$this->merge([
|
||||
'image' => filled($this->image) ? $this->image : null,
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ public function rules(): array
|
||||
'media_ids.*' => ['required', 'exists:media,id'],
|
||||
'banner' => ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'],
|
||||
'description' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
@ -41,6 +42,13 @@ public function rules(): array
|
||||
return $rules;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@ -27,6 +27,7 @@ public function rules(): array
|
||||
'short_name' => ['nullable', 'max:100'],
|
||||
'location' => ['nullable'],
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -36,6 +37,7 @@ protected function prepareForValidation()
|
||||
'short_name' => filled($this->short_name) ? $this->short_name : null,
|
||||
'location' => filled($this->location) ? $this->location : null,
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -32,8 +32,15 @@ public function rules(): array
|
||||
'description' =>['required'],
|
||||
'government_agencies' =>['required', 'array'],
|
||||
'government_agencies.*' =>['required', 'exists:government_agencies,id'],
|
||||
'enhancer_id' =>['required'],
|
||||
];
|
||||
}
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
|
||||
@ -25,7 +25,8 @@ public function rules(): array
|
||||
return [
|
||||
'name' => ['required', 'max:100'],
|
||||
'status' => ['required', 'in:0,1'],
|
||||
'description' => ['nullable']
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -33,6 +34,7 @@ protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ public function rules(): array
|
||||
'keyword' => ['required', 'max:100'],
|
||||
'quote' => ['nullable'],
|
||||
'release_date' => ['required', 'date'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
|
||||
if($this->isMethod('post')){
|
||||
@ -52,6 +53,7 @@ protected function prepareForValidation()
|
||||
'link' => filled($this->link) ? $this->link : null,
|
||||
'influencer' => filled($this->influencer) ? $this->influencer : null,
|
||||
'quote' => filled($this->quote) ? $this->quote : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,41 @@ public function rules(): array
|
||||
'image' => ['nullable', 'image', 'mimes:png,jpg,jpeg', 'max:2048'],
|
||||
'required_reports' => ['required', 'numeric', 'min:1', 'max:100'],
|
||||
'task_description' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function prepareForValidation(){
|
||||
$this->merge([
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'start_date.required' => 'Tanggal mulai harus diisi.',
|
||||
'start_date.date' => 'Format tanggal mulai tidak valid.',
|
||||
|
||||
'end_date.required' => 'Tanggal selesai harus diisi.',
|
||||
'end_date.date' => 'Format tanggal selesai tidak valid.',
|
||||
|
||||
'media_ids.required' => 'Media harus dipilih.',
|
||||
'media_ids.array' => 'Format media tidak valid.',
|
||||
'media_ids.*.required' => 'Media yang dipilih tidak boleh kosong.',
|
||||
'media_ids.*.exists' => 'Media yang dipilih tidak ditemukan dalam sistem.',
|
||||
|
||||
'image.image' => 'File yang diunggah harus berupa gambar.',
|
||||
'image.mimes' => 'Gambar harus berformat PNG, JPG, atau JPEG.',
|
||||
'image.max' => 'Ukuran gambar maksimal adalah 2MB.',
|
||||
|
||||
'required_reports.required' => 'Jumlah laporan yang dibutuhkan harus diisi.',
|
||||
'required_reports.numeric' => 'Jumlah laporan harus berupa angka.',
|
||||
'required_reports.min' => 'Jumlah laporan minimal adalah 1.',
|
||||
'required_reports.max' => 'Jumlah laporan maksimal adalah 100.',
|
||||
|
||||
'task_description.required' => 'Deskripsi tugas harus diisi.',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,7 +26,8 @@ public function rules(): array
|
||||
'name' => ['required', 'max:100'],
|
||||
'location_id' => ['required', 'exists:locations,id'],
|
||||
'status' => ['required', 'in:0,1'],
|
||||
'description' => ['nullable']
|
||||
'description' => ['nullable'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -34,6 +35,7 @@ protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'description' => filled($this->description) ? $this->description : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['required', 'max:100'],
|
||||
'email' => ['required', 'email', 'max:100'],
|
||||
'email' => ['required', 'email', 'max:100', 'unique:users,email'],
|
||||
'role_id' => ['required', 'in:1,2,3,4'],
|
||||
'status' => ['required', 'in:1,2'],
|
||||
];
|
||||
@ -36,11 +36,23 @@ public function rules(): array
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
}else if($this->isMethod('put')){
|
||||
$rules['password'] = ['nullable', 'confirmed', Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
||||
public function prepareForValidation(){
|
||||
if (!filled(trim($this->password))) {
|
||||
$this->request->remove('password');
|
||||
}
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
||||
@ -32,7 +32,7 @@ public function run(): void
|
||||
]);
|
||||
}
|
||||
|
||||
$createdUser = User::create([
|
||||
User::create([
|
||||
'name' => 'Administrator',
|
||||
'email' => 'admin@gmail.com',
|
||||
'password' => 'Rahasia123@',
|
||||
@ -40,6 +40,14 @@ public function run(): void
|
||||
'role_id' => '1'
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => 'Sample',
|
||||
'email' => 'sample@gmail.com',
|
||||
'password' => 'Rahasia123@',
|
||||
'status' => '1',
|
||||
'role_id' => '1'
|
||||
]);
|
||||
|
||||
User::find(117)->update([
|
||||
'password' => 'Rahasia123@'
|
||||
]);
|
||||
|
||||
@ -722,7 +722,6 @@ function ecommerceBarS1(selector, set_data) {
|
||||
data: ["{{ $facebookMediaMonitoring }}", "{{ $twitterMediaMonitoring }}", "{{ $websiteMediaMonitoring }}", "{{ $youtubeMediaMonitoring }}", "{{ $instagramMediaMonitoring }}", "{{ $tiktokMediaMonitoring }}", "{{ $cetakMediaMonitoring }}"]
|
||||
}]
|
||||
};
|
||||
@endif
|
||||
|
||||
var mediaOrderStatistics = {
|
||||
labels: ["Menunggu", "Diterima", "Ditolak"],
|
||||
@ -745,6 +744,7 @@ function ecommerceBarS1(selector, set_data) {
|
||||
data: ["{{ $facebookContentRecap }}", "{{ $twitterContentRecap }}", "{{ $websiteContentRecap }}", "{{ $youtubeContentRecap }}", "{{ $instagramContentRecap }}", "{{ $tiktokContentRecap }}", "{{ $cetakContentRecap }}"]
|
||||
}]
|
||||
};
|
||||
@endif
|
||||
|
||||
function ecommerceDoughnutS1(selector, set_data) {
|
||||
var $selector = selector ? $(selector) : $('.ecommerce-doughnut-s1');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user