migration from monolith to microservice architecture
This commit is contained in:
parent
73c33fc6b2
commit
c622a9b069
@ -7,6 +7,7 @@
|
||||
use Hashids\Hashids;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -17,46 +18,109 @@
|
||||
// }
|
||||
|
||||
if (! function_exists('store_file')) {
|
||||
function store_file($file = null, $path, $disk = 'public')
|
||||
function store_file($file = null, $path, $disk = null)
|
||||
{
|
||||
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();
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
$file->storeAs($path, $randomFilename, $disk);
|
||||
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();
|
||||
|
||||
return [
|
||||
'randomFileName' => $randomFilename,
|
||||
'originalFileName' => $originalFileName,
|
||||
'isSuccess' => true,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'randomFileName' => null,
|
||||
'originalFileName' => null,
|
||||
'isSuccess' => false,
|
||||
];
|
||||
$stored = $file->storeAs($path, $randomFilename, $disk);
|
||||
|
||||
if ($stored) {
|
||||
$url = Storage::disk($disk)->url($stored);
|
||||
|
||||
return [
|
||||
'randomFileName' => $randomFilename,
|
||||
'originalFileName' => $originalFileName,
|
||||
'url' => $url,
|
||||
'isSuccess' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'randomFileName' => null,
|
||||
'originalFileName' => null,
|
||||
'url' => null,
|
||||
'isSuccess' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('display_file')) {
|
||||
function display_file($dir, $filename, $disk = null, $expirationMinutes = 60): string
|
||||
{
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
if (!filled($filename)) {
|
||||
return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
}
|
||||
|
||||
$path = "uploads/{$dir}/{$filename}";
|
||||
|
||||
try {
|
||||
$fileExists = is_file_exists($path, $disk);
|
||||
|
||||
if (!$fileExists) {
|
||||
return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
}
|
||||
|
||||
if ($disk === 's3') {
|
||||
$fileUrl = Storage::disk($disk)->temporaryUrl($path, now()->addMinutes($expirationMinutes));
|
||||
} else {
|
||||
$fileUrl = Storage::disk($disk)->url($path);
|
||||
}
|
||||
|
||||
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$mimeType = match ($ext) {
|
||||
'jpg', 'jpeg', 'png', 'gif', 'webp' => 'image/' . $ext,
|
||||
'pdf' => 'application/pdf',
|
||||
default => 'unknown',
|
||||
};
|
||||
|
||||
if (str_contains($mimeType, 'image')) {
|
||||
return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
} elseif ($mimeType === 'application/pdf') {
|
||||
return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
}
|
||||
|
||||
return '<p class="text-center">Format file tidak didukung</p>';
|
||||
} catch (\Exception $e) {
|
||||
return '<p class="text-center text-danger">Terjadi kesalahan saat menampilkan file.</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('delete_file')) {
|
||||
function delete_file($path)
|
||||
function delete_file($path, $disk = null): bool
|
||||
{
|
||||
if (File::exists(storage_path($path))) {
|
||||
File::delete(storage_path($path));
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
if(is_file_exists($path)){
|
||||
return Storage::disk($disk)->delete($path);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('is_file_exists')) {
|
||||
function is_file_exists($path)
|
||||
if (!function_exists('is_file_exists')) {
|
||||
function is_file_exists($path, $disk = null): bool
|
||||
{
|
||||
return File::exists(public_path('storage/' . $path));
|
||||
$disk = $disk ?? env('FILESYSTEM_DISK', 'public');
|
||||
|
||||
try {
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
return !empty($file);
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,32 +333,6 @@ function get_user_agent($userAgentParam): array
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('display_file')) {
|
||||
function display_file($dir, $filename)
|
||||
{
|
||||
$path = storage_path("app/public/uploads/{$dir}/{$filename}");
|
||||
|
||||
if(!filled($filename)){
|
||||
return '<p class="text-center">Belum ditambahkan.</p>';
|
||||
}
|
||||
|
||||
if (!file_exists($path)) {
|
||||
return '<p class="text-center">File tidak ditemukan.</p>';
|
||||
}
|
||||
|
||||
$mimeType = mime_content_type($path);
|
||||
$fileUrl = asset("storage/uploads/{$dir}/{$filename}");
|
||||
|
||||
if (str_contains($mimeType, 'image')) {
|
||||
return "<img src='{$fileUrl}' alt='File Image' class='img-fluid'>";
|
||||
} elseif ($mimeType === 'application/pdf') {
|
||||
return "<iframe src='{$fileUrl}' width='100%' height='600px'></iframe>";
|
||||
}
|
||||
|
||||
return '<p class="text-center">Format file tidak didukung</p>';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('change_status')) {
|
||||
function change_status($status, $category) {
|
||||
if(in_array($category, ['company_edit', 'media_edit'])){
|
||||
|
||||
@ -67,7 +67,7 @@ public function registerAction(RegisterRequest $request){
|
||||
$companyFileNames = [];
|
||||
foreach($companyFiles as $file){
|
||||
if($request->hasFile($file)){
|
||||
$companyFileNames[$file] = store_file($validatedData[$file], '/uploads/companies', 'public')['randomFileName'];
|
||||
$companyFileNames[$file] = store_file($validatedData[$file], '/uploads/companies')['randomFileName'];
|
||||
}else{
|
||||
$companyFileNames[$file] = null;
|
||||
}
|
||||
@ -105,7 +105,7 @@ public function registerAction(RegisterRequest $request){
|
||||
$mediaFileNames = [];
|
||||
foreach($mediaFiles as $file){
|
||||
if($request->hasFile($file)){
|
||||
$mediaFileNames[$file] = store_file($validatedData[$file], '/uploads/media', 'public')['randomFileName'];
|
||||
$mediaFileNames[$file] = store_file($validatedData[$file], '/uploads/media')['randomFileName'];
|
||||
}else{
|
||||
$mediaFileNames[$file] = null;
|
||||
}
|
||||
@ -132,7 +132,7 @@ public function registerAction(RegisterRequest $request){
|
||||
$journalistFileNames = [];
|
||||
foreach($journalistFiles as $file){
|
||||
if($request->hasFile($file)){
|
||||
$journalistFileNames[$file] = store_file($validatedData[$file], '/uploads/journalists', 'public')['randomFileName'];
|
||||
$journalistFileNames[$file] = store_file($validatedData[$file], '/uploads/journalists')['randomFileName'];
|
||||
}else{
|
||||
$journalistFileNames[$file] = null;
|
||||
}
|
||||
|
||||
@ -11,6 +11,17 @@
|
||||
|
||||
class AiringProofThemeController extends Controller
|
||||
{
|
||||
private function checkExistedData($slug, $isSoftDeleted = false)
|
||||
{
|
||||
$query = AiringProofTheme::withTrashed()->where('slug', $slug);
|
||||
|
||||
if($isSoftDeleted){
|
||||
$query->whereNotNull('deleted_at');
|
||||
}
|
||||
|
||||
return $query->first();
|
||||
}
|
||||
|
||||
public function index(){
|
||||
return view('dashboard.airing-proof-themes.index', [
|
||||
'title' => "Tema Bukti Tayang"
|
||||
@ -25,22 +36,17 @@ public function create(){
|
||||
|
||||
public function store(AiringProofThemeRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['slug'] = Str::slug($validatedData['name']. ' '. $validatedData['year']);
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$existedData = AiringProofTheme::withTrashed()->where('slug', $validatedData['slug'])->first();
|
||||
|
||||
if($existedData && filled($existedData->deleted_at)){
|
||||
if($this->checkExistedData($validatedData['slug'], true)){
|
||||
return redirect()->back()->with('data-exists', $validatedData['slug']);
|
||||
}elseif($existedData){
|
||||
}elseif($this->checkExistedData($validatedData['slug'])){
|
||||
return redirect()->back()->with('failed-status', 'Tema dengan nama dan tahun tersebut sudah ada.');
|
||||
}
|
||||
|
||||
$createdTheme = AiringProofTheme::create($validatedData);
|
||||
|
||||
if($createdTheme){
|
||||
try{
|
||||
AiringProofTheme::create($validatedData);
|
||||
return redirect()->back()->with('success-status', 'Berhasil menambahkan tema bukti tayang.');
|
||||
}else{
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal menambahkan tema bukti tayang.');
|
||||
}
|
||||
}
|
||||
@ -56,15 +62,12 @@ public function edit($id){
|
||||
|
||||
public function update(AiringProofThemeRequest $request, $id){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['slug'] = Str::slug($validatedData['name']. ' '. $validatedData['year']);
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$updatedAiringProofTheme = $airingProofTheme->update($validatedData);
|
||||
|
||||
if($updatedAiringProofTheme){
|
||||
try{
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
$airingProofTheme->update($validatedData);
|
||||
return redirect()->back()->with('success-status', 'Berhasil mengubah tema bukti tayang.');
|
||||
}else{
|
||||
}catch(\Exception $e){
|
||||
return redirect()->back()->with('failed-status', 'Gagal mengubah tema bukti tayang.');
|
||||
}
|
||||
}
|
||||
@ -81,7 +84,6 @@ public function show($id){
|
||||
public function destroy($id){
|
||||
try {
|
||||
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
|
||||
|
||||
$airingProofTheme->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus tema bukti tayang.']);
|
||||
|
||||
@ -38,7 +38,7 @@ public function store(AnnouncementRequest $request){
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements', 'public')['randomFileName'];
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements')['randomFileName'];
|
||||
}
|
||||
|
||||
$announcement = Announcement::create($validatedData);
|
||||
@ -69,8 +69,8 @@ public function update(AnnouncementRequest $request, $id){
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements', 'public')['randomFileName'];
|
||||
delete_file('app/public/uploads/announcements/'.$announcement->attachment);
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/announcements')['randomFileName'];
|
||||
delete_file('uploads/announcements/'.$announcement->attachment);
|
||||
}else{
|
||||
$validatedData['attachment'] = $announcement->attachment;
|
||||
}
|
||||
@ -126,7 +126,6 @@ public function destroy($id){
|
||||
$announcement = Announcement::with(['users'])->findOrFail(decrypt_id($id));
|
||||
|
||||
$announcement->users()->detach();
|
||||
|
||||
$announcement->delete();
|
||||
|
||||
return response()->json(['message' => 'Berhasil menghapus pengumuman.']);
|
||||
|
||||
@ -117,7 +117,7 @@ public function update(CompanyRequest $request){
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$companyFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/companies', 'public')['randomFileName'];
|
||||
$companyFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/companies')['randomFileName'];
|
||||
} else {
|
||||
$companyFileNames[$requestKey] = $company->{$dbField};
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public function store(ContentRecapRequest $request){
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
if($request->has('image') && filled($validatedData['image'])){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = null;
|
||||
}
|
||||
@ -73,7 +73,7 @@ public function update(ContentRecapRequest $request, $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', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/content-recaps')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $contentRecap->image;
|
||||
}
|
||||
|
||||
@ -15,11 +15,11 @@ 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', 'public')['randomFileName'];
|
||||
$validatedData['payment_request_letter'] = store_file($validatedData['payment_request_letter'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['invoice'] = store_file($validatedData['invoice'], 'uploads/cooperation-completions', 'public')['randomFileName'];
|
||||
$validatedData['invoice'] = store_file($validatedData['invoice'], 'uploads/cooperation-completions')['randomFileName'];
|
||||
|
||||
$validatedData['other_document'] = store_file($validatedData['other_document'], 'uploads/cooperation-completions', 'public')['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;
|
||||
|
||||
@ -117,7 +117,7 @@ public function storeProposal(JournalistCooperationProposalRequest $request, $id
|
||||
$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', 'public')['randomFileName'];
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
|
||||
$createdCooperationProposal = CooperationProposal::create($validatedData);
|
||||
$createdCooperationProposal->journalists()->attach($validatedData['journalist_ids']);
|
||||
@ -233,7 +233,7 @@ public function updateProposal(JournalistCooperationProposalRequest $request, $i
|
||||
$validatedData['cooperation_id'] = $proposal->cooperation_id;
|
||||
|
||||
if($request->hasFile('attachment')){
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals', 'public')['randomFileName'];
|
||||
$validatedData['attachment'] = store_file($validatedData['attachment'], '/uploads/cooperation-proposals')['randomFileName'];
|
||||
delete_file('app/public/uploads/cooperation-proposals/'.$proposal->image);
|
||||
}else{
|
||||
$validatedData['attachment'] = $proposal->attachment;
|
||||
|
||||
@ -107,7 +107,7 @@ public function store(JournalistRequest $request){
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists', 'public')['randomFileName'];
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists')['randomFileName'];
|
||||
}else{
|
||||
$journalistFileNames[$requestKey] = null;
|
||||
}
|
||||
@ -248,7 +248,7 @@ public function update(JournalistRequest $request, $id){
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists', 'public')['randomFileName'];
|
||||
$journalistFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/journalists')['randomFileName'];
|
||||
}else{
|
||||
$journalistFileNames[$requestKey] = $journalist->{$dbField};
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public function update(MediaRequest $request){
|
||||
|
||||
foreach ($fileFieldMap as $requestKey => $dbField) {
|
||||
if ($request->hasFile($requestKey) && filled($validatedData[$requestKey])) {
|
||||
$mediaFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/media', 'public')['randomFileName'];
|
||||
$mediaFileNames[$requestKey] = store_file($validatedData[$requestKey], '/uploads/media')['randomFileName'];
|
||||
} else {
|
||||
$mediaFileNames[$requestKey] = $media->{$dbField};
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ public function store(CooperationRequest $request){
|
||||
$validatedData = $request->validated();
|
||||
$validatedData['enhancer_id'] = Auth::id();
|
||||
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations', 'public')['randomFileName'];
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations', 'public')['randomFileName'];
|
||||
$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']);
|
||||
@ -83,14 +83,14 @@ public function update(CooperationRequest $request, $id){
|
||||
|
||||
if($request->hasFile('banner')){
|
||||
delete_file('app/public/uploads/cooperations/'.$cooperation->banner);
|
||||
$validatedData['banner'] = store_file($validatedData['banner'], '/uploads/cooperations', 'public')['randomFileName'];
|
||||
$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', 'public')['randomFileName'];
|
||||
$validatedData['offer_file_template'] = store_file($validatedData['offer_file_template'], '/uploads/cooperations')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['offer_file_template'] = $cooperation->offer_file_template;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public function store(MediaMonitoringRequest $request){
|
||||
$code = 'ADN'.$newNumber;
|
||||
|
||||
$validatedData['code'] = $code;
|
||||
$validatedData['image'] = store_file($validatedData['image'], 'uploads/media-monitorings', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], 'uploads/media-monitorings')['randomFileName'];
|
||||
|
||||
$createMediaMonitoring = MediaMonitoring::create($validatedData);
|
||||
|
||||
@ -76,7 +76,7 @@ public function update(MediaMonitoringRequest $request, $id){
|
||||
|
||||
if($request->has('image')){
|
||||
delete_file('app/public/uploads/media-monitorings/'.$mediaMonitoring->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-monitorings', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-monitorings')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $mediaMonitoring->image;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ 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', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
$cooperation = Cooperation::findOrFail(decrypt_id($id));
|
||||
$validatedData['cooperation_id'] = $cooperation->id;
|
||||
@ -86,7 +86,7 @@ public function update(OrderRequest $request, $id){
|
||||
$validatedData['cooperation_id'] = $mediaOrder->cooperation_id;
|
||||
|
||||
if($request->hasFile('image')){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/media-orders')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/media-orders/'.$mediaOrder->image);
|
||||
}else{
|
||||
|
||||
@ -43,7 +43,7 @@ public function store(NewsRequest $request){
|
||||
}
|
||||
|
||||
if($request->has('image')){
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news', 'public')['randomFileName'];
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
}
|
||||
|
||||
|
||||
@ -71,8 +71,8 @@ public function update(NewsRequest $request, $id){
|
||||
$news = News::findOrFail(decrypt_id($id));
|
||||
|
||||
if($request->has('image')){
|
||||
delete_file('app/public/uploads/news/'.$news->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news', 'public')['randomFileName'];
|
||||
delete_file('uploads/news/'.$news->image);
|
||||
$validatedData['image'] = store_file($validatedData['image'], '/uploads/news')['randomFileName'];
|
||||
}else{
|
||||
$validatedData['image'] = $news->image;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ public function store(ReportRequest $request, $id){
|
||||
$validatedData['media_id'] = Auth::user()->company->media->id;
|
||||
$validatedData['order_id'] = decrypt_id($id);
|
||||
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports', 'public')['randomFileName'];
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
$createdReport = Report::create($validatedData);
|
||||
|
||||
@ -53,7 +53,7 @@ public function update(ReportRequest $request, $mediaOrderId, $id){
|
||||
$report = Report::findOrFail(decrypt_id($id));
|
||||
|
||||
if($request->hasFile('image')){
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports', 'public')['randomFileName'];
|
||||
$validatedData['proof'] = store_file($validatedData['proof'], '/uploads/reports')['randomFileName'];
|
||||
|
||||
delete_file('app/public/uploads/reports/'.$report->proof);
|
||||
}else{
|
||||
|
||||
@ -25,7 +25,7 @@ public function update(SettingRequest $request)
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($request->hasFile($file)) {
|
||||
$savedFile = store_file($request->file($file), 'uploads/settings', 'public');
|
||||
$savedFile = store_file($request->file($file), 'uploads/settings');
|
||||
$validFile[$file] = $savedFile['randomFileName'];
|
||||
} else {
|
||||
$validFile[$file] = $settings->$file;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Dotenv\Util\Str;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@ -26,6 +27,8 @@ public function rules(): array
|
||||
'name' => ['required', 'max:100'],
|
||||
'year' => ['required', 'max:5'],
|
||||
'description' => ['nullable'],
|
||||
'slug' => ['required'],
|
||||
'enhancer_id' => ['required'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -39,4 +42,12 @@ public function messages(): array
|
||||
'description.nullable' => 'Deskripsi bersifat opsional.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'slug' => filled($this->name) && filled($this->year) ? \Illuminate\Support\Str::slug($this->name. ' '. $this->year) : null,
|
||||
'enhancer_id' => Auth::check() ? Auth::id() : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"biscolab/laravel-recaptcha": "^6.1",
|
||||
"laravel/framework": "^11.31",
|
||||
"laravel/tinker": "^2.9",
|
||||
"league/flysystem-aws-s3-v3": "^3.0",
|
||||
"maatwebsite/excel": "^3.1",
|
||||
"spatie/laravel-settings": "^3.4",
|
||||
"sqids/sqids": "^0.5.0",
|
||||
|
||||
310
composer.lock
generated
310
composer.lock
generated
@ -4,8 +4,159 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f8b7e7e41db868dc95f7797e7b226123",
|
||||
"content-hash": "b7c265f1ef13691fce1a70859340846c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-crt-php",
|
||||
"version": "v1.2.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/awslabs/aws-crt-php.git",
|
||||
"reference": "d71d9906c7bb63a28295447ba12e74723bd3730e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/d71d9906c7bb63a28295447ba12e74723bd3730e",
|
||||
"reference": "d71d9906c7bb63a28295447ba12e74723bd3730e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35||^5.6.3||^9.5",
|
||||
"yoast/phpunit-polyfills": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "AWS SDK Common Runtime Team",
|
||||
"email": "aws-sdk-common-runtime@amazon.com"
|
||||
}
|
||||
],
|
||||
"description": "AWS Common Runtime for PHP",
|
||||
"homepage": "https://github.com/awslabs/aws-crt-php",
|
||||
"keywords": [
|
||||
"amazon",
|
||||
"aws",
|
||||
"crt",
|
||||
"sdk"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/awslabs/aws-crt-php/issues",
|
||||
"source": "https://github.com/awslabs/aws-crt-php/tree/v1.2.7"
|
||||
},
|
||||
"time": "2024-10-18T22:15:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.342.32",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "638ded9f33b28aac014db6bf2817e9341f5e6361"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/638ded9f33b28aac014db6bf2817e9341f5e6361",
|
||||
"reference": "638ded9f33b28aac014db6bf2817e9341f5e6361",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"aws/aws-crt-php": "^1.2.3",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-simplexml": "*",
|
||||
"guzzlehttp/guzzle": "^7.4.5",
|
||||
"guzzlehttp/promises": "^2.0",
|
||||
"guzzlehttp/psr7": "^2.4.5",
|
||||
"mtdowling/jmespath.php": "^2.8.0",
|
||||
"php": ">=8.1",
|
||||
"psr/http-message": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"andrewsville/php-token-reflection": "^1.4",
|
||||
"aws/aws-php-sns-message-validator": "~1.0",
|
||||
"behat/behat": "~3.0",
|
||||
"composer/composer": "^2.7.8",
|
||||
"dms/phpunit-arraysubset-asserts": "^0.4.0",
|
||||
"doctrine/cache": "~1.4",
|
||||
"ext-dom": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-pcntl": "*",
|
||||
"ext-sockets": "*",
|
||||
"phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5",
|
||||
"psr/cache": "^2.0 || ^3.0",
|
||||
"psr/simple-cache": "^2.0 || ^3.0",
|
||||
"sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0",
|
||||
"symfony/filesystem": "^v6.4.0 || ^v7.1.0",
|
||||
"yoast/phpunit-polyfills": "^2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"aws/aws-php-sns-message-validator": "To validate incoming SNS notifications",
|
||||
"doctrine/cache": "To use the DoctrineCacheAdapter",
|
||||
"ext-curl": "To send requests using cURL",
|
||||
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
|
||||
"ext-sockets": "To use client-side monitoring"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Aws\\": "src/"
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"src/data/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Amazon Web Services",
|
||||
"homepage": "http://aws.amazon.com"
|
||||
}
|
||||
],
|
||||
"description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project",
|
||||
"homepage": "http://aws.amazon.com/sdkforphp",
|
||||
"keywords": [
|
||||
"amazon",
|
||||
"aws",
|
||||
"cloud",
|
||||
"dynamodb",
|
||||
"ec2",
|
||||
"glacier",
|
||||
"s3",
|
||||
"sdk"
|
||||
],
|
||||
"support": {
|
||||
"forum": "https://github.com/aws/aws-sdk-php/discussions",
|
||||
"issues": "https://github.com/aws/aws-sdk-php/issues",
|
||||
"source": "https://github.com/aws/aws-sdk-php/tree/3.342.32"
|
||||
},
|
||||
"time": "2025-04-22T18:26:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "barryvdh/laravel-dompdf",
|
||||
"version": "v3.1.1",
|
||||
@ -1285,16 +1436,16 @@
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.9.2",
|
||||
"version": "7.9.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "d281ed313b989f213357e3be1a179f02196ac99b"
|
||||
"reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b",
|
||||
"reference": "d281ed313b989f213357e3be1a179f02196ac99b",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77",
|
||||
"reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1391,7 +1542,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.9.2"
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.9.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1407,20 +1558,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-07-24T11:22:20+00:00"
|
||||
"time": "2025-03-27T13:37:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
"version": "2.0.4",
|
||||
"version": "2.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/promises.git",
|
||||
"reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455"
|
||||
"reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455",
|
||||
"reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c",
|
||||
"reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1474,7 +1625,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/promises/issues",
|
||||
"source": "https://github.com/guzzle/promises/tree/2.0.4"
|
||||
"source": "https://github.com/guzzle/promises/tree/2.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1490,20 +1641,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-10-17T10:06:22+00:00"
|
||||
"time": "2025-03-27T13:27:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "2.7.0",
|
||||
"version": "2.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201"
|
||||
"reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201",
|
||||
"reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16",
|
||||
"reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1590,7 +1741,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/psr7/issues",
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.7.0"
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.7.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1606,7 +1757,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-07-18T11:15:46+00:00"
|
||||
"time": "2025-03-27T12:30:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/uri-template",
|
||||
@ -2436,6 +2587,61 @@
|
||||
},
|
||||
"time": "2024-10-08T08:58:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem-aws-s3-v3",
|
||||
"version": "3.29.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git",
|
||||
"reference": "c6ff6d4606e48249b63f269eba7fabdb584e76a9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/c6ff6d4606e48249b63f269eba7fabdb584e76a9",
|
||||
"reference": "c6ff6d4606e48249b63f269eba7fabdb584e76a9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"aws/aws-sdk-php": "^3.295.10",
|
||||
"league/flysystem": "^3.10.0",
|
||||
"league/mime-type-detection": "^1.0.0",
|
||||
"php": "^8.0.2"
|
||||
},
|
||||
"conflict": {
|
||||
"guzzlehttp/guzzle": "<7.0",
|
||||
"guzzlehttp/ringphp": "<1.1.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\Flysystem\\AwsS3V3\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Frank de Jonge",
|
||||
"email": "info@frankdejonge.nl"
|
||||
}
|
||||
],
|
||||
"description": "AWS S3 filesystem adapter for Flysystem.",
|
||||
"keywords": [
|
||||
"Flysystem",
|
||||
"aws",
|
||||
"file",
|
||||
"files",
|
||||
"filesystem",
|
||||
"s3",
|
||||
"storage"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.29.0"
|
||||
},
|
||||
"time": "2024-08-17T13:10:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem-local",
|
||||
"version": "3.29.0",
|
||||
@ -3151,6 +3357,72 @@
|
||||
],
|
||||
"time": "2025-03-24T10:02:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mtdowling/jmespath.php",
|
||||
"version": "2.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jmespath/jmespath.php.git",
|
||||
"reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
|
||||
"reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"symfony/polyfill-mbstring": "^1.17"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/xdebug-handler": "^3.0.3",
|
||||
"phpunit/phpunit": "^8.5.33"
|
||||
},
|
||||
"bin": [
|
||||
"bin/jp.php"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/JmesPath.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"JmesPath\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "hello@gjcampbell.co.uk",
|
||||
"homepage": "https://github.com/GrahamCampbell"
|
||||
},
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Declaratively specify how to extract elements from a JSON document",
|
||||
"keywords": [
|
||||
"json",
|
||||
"jsonpath"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/jmespath/jmespath.php/issues",
|
||||
"source": "https://github.com/jmespath/jmespath.php/tree/2.8.0"
|
||||
},
|
||||
"time": "2024-09-04T18:46:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "3.8.6",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user