Files
freeu-project/app/Http/Controllers/Frontend/VentureDebtsController.php
Ritikesh yadav c661166e1d first commit
2024-03-28 14:52:40 +05:30

58 lines
2.2 KiB
PHP

<?php
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Product;
use App\Http\Resources\FractionalRealEstate as test;
use App\Http\Resources\VentureDebtResource;
use App\Models\VentureDebt;
use App\Http\Controllers\Admin\ManageFreeUInvestments\FractionalRealEstateController as FractionalRealEstateFrontendController;
class VentureDebtsController extends Controller
{
public function index(){
$ventureDebts = $this->ventureDebts()->getData();
$learnMore = (new FractionalRealEstateFrontendController)->ventureDebtQuestionAndAnswer()->getData();
$faqs = (new FractionalRealEstateFrontendController)->ventureDebtQuestionAndAnswerFaqs()->getData();
return view('Frontend.Pages.venture-debts.index',compact('ventureDebts','learnMore','faqs'));
}
public function product($slug){
$ventureDebts = $this->ventureDebtsData($slug)->getData()->data;
$otherVD = VentureDebt::query()
->join('products', 'venture_debts.products_id', 'products.id')
->where('status',true)
->where('slug', '!=', $slug)
->where('categories_id',12)
->get();
// $securitizedDebtInstrument = SecuritizedDebtInstrument::where('slug',$slug)->first();
$productData = VentureDebt::where('slug','=',$slug)->first();
$productData = Product::where('id','=',$productData->products_id)->first();
return view('Frontend.Pages.venture-debts.product',compact('ventureDebts','otherVD','productData'));
}
public function ventureDebts()
{
try {
return (new test(Product::has('ventureDebt')->with('ventureDebt.companies')->active()->get()))
->response()
->setStatusCode(200);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
}
public function ventureDebtsData($slug)
{
try {
return (new VentureDebtResource(VentureDebt::where('slug',$slug)->first()))
->response()
->setStatusCode(200);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
}
}