99 lines
4.1 KiB
PHP
99 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\PeerToPeerLending;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Product;
|
|
use App\Http\Resources\FractionalRealEstate as test;
|
|
use App\Http\Resources\PeerToPeerLendingResource;
|
|
use App\Http\Controllers\Admin\ManageFreeUInvestments\PeerToPeerLendingController as PeerToPeerLendingFontendController;
|
|
use App\Http\Controllers\Admin\ManageFreeUInvestments\FractionalRealEstateController as FractionalRealEstateFrontendController;
|
|
|
|
class PeerToPeerLendingController extends Controller
|
|
{
|
|
public function index(){
|
|
$peerToPeerLendings = $this->peerToPeerLending()->getData();
|
|
$learnMore = (new FractionalRealEstateFrontendController)->peerToPeerLendingQuestionAndAnswer()->getData();
|
|
$faqs = (new FractionalRealEstateFrontendController)->peerToPeerLendingQuestionAndAnswerFaqs()->getData();
|
|
return view('Frontend.Pages.peer-to-peer-lending.index',compact('peerToPeerLendings','learnMore','faqs'));
|
|
}
|
|
|
|
public function product($slug){
|
|
// $peerToPeerLending = PeerToPeerLending::where('slug',$slug)->first();
|
|
$peerToPeerLending = $this->peerToPeerLendingData($slug)->getData()->data;
|
|
$otherP2P = PeerToPeerLending::query()
|
|
->join('products', 'peer_to_peer_lendings.products_id', 'products.id')
|
|
->where(['status' => true, 'categories_id' => 3])
|
|
// ->where('status',false)
|
|
->where('slug', '!=', $slug)
|
|
// ->where('categories_id',26)
|
|
->get();
|
|
|
|
$productData = PeerToPeerLending::where('slug','=',$slug)->first();
|
|
$productData = Product::where('id','=',$productData->products_id)->first();
|
|
// $productData['presentation_file'] = $productData->getRawOriginal('presentation');
|
|
// $productData['fact_sheet_file'] = $productData->getRawOriginal('fact_sheet');
|
|
return view('Frontend.Pages.peer-to-peer-lending.product',compact('peerToPeerLending','otherP2P','productData'));
|
|
}
|
|
|
|
public function downloadFilePersantation($filename){
|
|
// dd($filename);
|
|
if(\File::exists('public/uploads/product/presentation/'.$filename))
|
|
{
|
|
return response()->download(public_path('/uploads/product/presentation/'.$filename));
|
|
}
|
|
else if(\File::exists('public/uploads/product/fact_sheet/'.$filename))
|
|
{
|
|
return response()->download(public_path('/uploads/product/fact_sheet/'.$filename));
|
|
}else{
|
|
return "file not found";
|
|
}
|
|
}
|
|
// public function downloadpeertopeer($filename){
|
|
// // dd($filename);
|
|
// if(\File::exists('public/uploads/product/presentation/'.$filename))
|
|
// {
|
|
// return response()->download(public_path('/uploads/product/presentation/'.$filename));
|
|
// }
|
|
// else if(\File::exists('public/uploads/product/fact_sheet/'.$filename))
|
|
// {
|
|
// return response()->download(public_path('/uploads/product/fact_sheet/'.$filename));
|
|
// }else{
|
|
// return "file not found";
|
|
// }
|
|
// }
|
|
|
|
// public function peerToPeerLending(){
|
|
// $peerToPeerLendings = Product::with('peerToPeers', 'category')->peerToPeers()->active()->get();
|
|
// return (object)[
|
|
// 'status' => 200,
|
|
// 'data' => $peerToPeerLendings
|
|
// ];
|
|
// // return $peerToPeerLendings;
|
|
// }
|
|
|
|
public function peerToPeerLending()
|
|
{
|
|
try {
|
|
return (new test(Product::has('peerToPeers')->with('peerToPeers')->active()->get()))
|
|
->response()
|
|
->setStatusCode(200);
|
|
} catch (\Exception $e) {
|
|
return response()->json(['message' => $e->getMessage()], 400);
|
|
}
|
|
}
|
|
|
|
public function peerToPeerLendingData($slug)
|
|
{
|
|
try {
|
|
return (new PeerToPeerLendingResource(PeerToPeerLending::where('slug',$slug)->first()))
|
|
->response()
|
|
->setStatusCode(200);
|
|
} catch (\Exception $e) {
|
|
return response()->json(['message' => $e->getMessage()], 400);
|
|
}
|
|
}
|
|
}
|