Error of class not found when i am passing parameter to function
error :
Class App\Http\Requests\CsvImportRequest does not exist
What should I for this error for my controller, I am pasting here what i done :
<?php
namespace App\Http\Controllers\trades;
use App\Contact;
use App\CsvData;
use App\Http\Requests\CsvImportRequest;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;
class ImportSingleTradesController extends Controller
{
public function tradesImport(CsvImportRequest $request)
{
$path = $request->file('csv_file')->getRealPath();
if ($request->has('header')) {
$data = Excel::load($path, function($reader) {})->get()->toArray();
} else {
$data = array_map('str_getcsv', file($path));
}
if (count($data) > 0) {
if ($request->has('header')) {
$csv_header_fields = [];
foreach ($data[0] as $key => $value) {
$csv_header_fields[] = $key;
}
}
$csv_data = array_slice($data, 0, 2);
$csv_data_file = CsvData::create([
'csv_filename' => $request->file('csv_file')->getClientOriginalName(),
'csv_header' => $request->has('header'),
'csv_data' => json_encode($data)
]);
} else {
return redirect()->back();
}
return view('member.add-single-trade.import-excel.import_fields', compact( 'csv_header_fields', 'csv_data', 'csv_data_file'));
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire