mehmetanbaki
1 month ago
863
3
Laravel

Import Issue

Posted 1 month ago by mehmetanbaki
Maatwebsite\Excel\Exceptions\NoTypeDetectedException
No ReaderType or WriterType could be detected. Make sure you either pass a valid extension to the filename or pass an explicit type. 

this is the code for controller


<?php

namespace App\Http\Controllers;

use App\People;
use Illuminate\Http\Request;
use App\Exports\PeopleExport;
use App\Imports\PeopleImport;
use Maatwebsite\Excel\Facades\Excel;

class PeopleController extends Controller
{
    public function importExportView()
    {
       $people = People::get();
       return view('people', compact('people'));
    }

    public function export()
    {
        return Excel::download(new PeopleExport, 'people.xlsx');
    }

    public function import(Request $request)
    {
        $request->validate([
            'import_file' => 'required'
        ]);
        Excel::import(new PeopleImport,request()->file('import_file'));

        return redirect()->back();
    }
}


Please sign in or create an account to participate in this conversation.