Actualizacuion de Rama Kquiroz

This commit is contained in:
ellecio2
2023-09-04 19:53:37 -04:00
parent d2e9ba53ab
commit 2e99d7b290
2206 changed files with 100145 additions and 467275 deletions

View File

@@ -16,20 +16,19 @@ class DigitalProductController extends Controller
{
$product = Product::findOrFail($request->id);
$orders = Order::select("id")->where('user_id', auth()->user()->id)->pluck('id');
$orderDetails = OrderDetail::where("product_id",$request->id)->whereIn("order_id",$orders)->get();
$orderDetails = OrderDetail::where("product_id", $request->id)->whereIn("order_id", $orders)->get();
if (auth()->user()->user_type == 'admin' || auth()->user()->id == $product->user_id || $orderDetails) {
$upload = Upload::findOrFail($product->file_name);
if (env('FILESYSTEM_DRIVER') == "s3") {
return \Storage::disk('s3')->download($upload->file_name, $upload->file_original_name . "." . $upload->extension);
} else {
if (file_exists(base_path('public/' . $upload->file_name))) {
$file = public_path()."/$upload->file_name";
return response()->download($file,config('app.name')."_".$upload->file_original_name);
$file = public_path() . "/$upload->file_name";
return response()->download($file, config('app.name') . "_" . $upload->file_original_name . "." . $upload->extension);
}
}
} else {
return response()->download(File("dd.pdf"),"failed.jpg");
return response()->download(File("dd.pdf"), "failed.jpg");
}
}
}