8 months ago

Exporting/Importing Files

Posted 8 months ago by mehmetanbaki

Hey Laravelers

I have this issues with exporting files'export')

this is the route with error 404 not found


namespace App\Http\Controllers;

use App\People;
use Illuminate\Http\Request;
use App\Exports\PeopleExport;
use App\Imports\PoepleImport;
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)
            'import_file' => 'required'
        Excel::import(new PeopleImport,request()->file('import_file'));

        return redirect()->back();

this is the controller

Route::get('/people', '[email protected]');
Route::post('/people/import', '[email protected]');
Route::get('export', '[email protected]');

this is the routes

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <h1>إستيراد وتصدير الملفات</h1>

    <form action="{{ url('people/import') }}" method="POST" name="importform">
        <input type="file" name="import_file"><br /><hr />
        <button>إستيراد ملفات</button>
        <a href="url('export')">تصدير الملف</a>

    <hr />
    <hr />
    <hr />

    <table border="1">
            <th>رقم مركز التموين</th>
            <th>إسم مركز التموين</th>
            <th>رقم الصحيفة</th>
            <th>رقم السجل</th>
            <th>إسم الأب</th>
            <th>تاريخ التولد</th>
    <hr />


this is the code view

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