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

66 lines
2.6 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\HighYieldFinanceResource;
use App\Models\HighYieldFinance;
use App\Http\Controllers\Admin\ManageFreeUInvestments\HighYieldFinanceController as HighYieldFinanceFrontendController;
use App\Http\Controllers\Admin\ManageFreeUInvestments\FractionalRealEstateController as FractionalRealEstateFrontendController;
class HighYieldFinanceController extends Controller
{
public function index()
{
$highYieldFinance = $this->highYieldFinance()->getData();
$learnMore = (new FractionalRealEstateFrontendController)->highYieldFinanceQuestionAndAnswer()->getData();
$faqs = (new FractionalRealEstateFrontendController)->highYieldFinanceQuestionAndAnswerFaqs()->getData();
return view('Frontend.Pages.high-yield-finance.index', compact('highYieldFinance','learnMore','faqs'));
}
public function product($slug)
{
$highYieldFinance = $this->highYieldFinanceData($slug)->getData()->data;
$otherHYF = HighYieldFinance::query()
->join('products', 'high_yield_finances.products_id', 'products.id')
->where('status',true)
->where('slug', '!=', $slug)
->where('categories_id',1)
->get();
// dd($otherHYF);
$productData = HighYieldFinance::where('slug','=',$slug)->first();
$productData = Product::where('id','=',$productData->products_id)->first();
return view('Frontend.Pages.high-yield-finance.product', compact('highYieldFinance','otherHYF','productData'));
}
// public function highYieldFinance(){
// $highYieldFinance = Product::with('highYieldFinances', 'category')->highYieldFinances()->active()->get();
// return $highYieldFinance;
// }
public function highYieldFinance()
{
try {
return (new test(Product::has('highYieldFinances')->with('highYieldFinances')->active()->get()))
->response()
->setStatusCode(200);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
}
public function highYieldFinanceData($slug)
{
try {
return (new HighYieldFinanceResource(HighYieldFinance::where('slug', $slug)->first()))
->response()
->setStatusCode(200);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
}
}