Files
freeu-project/app/Http/Controllers/Admin/ManageFreeUInvestments/PrivateCreditFundController.php
2024-04-08 16:12:02 +05:30

106 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\ManageFreeUInvestments;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Category;
use Maatwebsite\Excel\Facades\Excel;
use App\Imports\AlternativeInvestmentFundImport;
use Illuminate\Support\Str;
use App\Models\AlternativeInvestmentFund;
use App\Models\Product;
class PrivateCreditFundController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$category = Category::find(Category::PrivateCreditFundId);
$text = $category->category_name;
$category_id = $category->id;
$excelFileName = 'PrivateCreditTemplate.xlsx';
$route = route('manage.private-credit-fund.store');
return view('Admin.Pages.manage_freeu_investment.upload-product.alternative-investment-fund', compact('text', 'category_id','excelFileName', 'route'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// dd($request->all());
request()->validate([
'productFile' => 'required|mimes:xlx,xls,xlsx|max:2048'
]);
$category_type = $request->category_id;
$category = Category::find($request->category_id);
Excel::import(new AlternativeInvestmentFundImport($category_type), $request->file('productFile'));
// dd('he')
// return back()->with('success', "$category->category_name Imported Successfully.");
return back()->with('success', "$category->category_name Imported Successfully.");
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}