Undefined variable: data laravel 8

Route :

Route::post('/store', [App\Http\Controllers\ArticleController::class, 'store']);

View :

<form action="/store" method="post">
@csrf
nom article <input type="text" name="titre" class="form-control mb-3"><br><br><br>
nom auteur <input type="text" name="nomAut" class="form-control mb-3"/><br><br><br>
contenu <input type="text" name="body" class="form-control mb-3"/><br><br><br>
<button class="btn btn-primary float-end px-5" type="submit">Submit</button>
</form>

Controller :

public function store(Request $request)
{
    $request->validate([
        'titre'=>'required',
        'nomAut'=>'required',
        'body'=>'required',
    ]);

    Article::create($data);
    return redirect()->route('articles.index');
}


Read more here: https://stackoverflow.com/questions/68475426/undefined-variable-data-laravel-8

Content Attribution

This content was originally published by Nesrine Missaoui at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: