Deepak Keynes
Deepak Keynes

Reputation: 2329

Laravel showing null value after form submit

My View:

<form action="/AddJuiceForm" method="POST">
    @csrf;
    <div class="form-group">
        <label for="FruitName">Fruit Name : </label>
        <input type="text"
            class="form-control"
            placeholder="Enter the Fruit Name"
            name="fruitname">
    </div>
    <div class="form-group">
        <label for="JuiceName">Juice Name : </label>
        <input type="text"
            class="form-control"
            placeholder="Enter the Juice Name"
            name="juicename">
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
</form>

My Routes/web.php:

Route::post('AddJuiceForm','JuiceController@insertjuice ');

My Controller:

<?php

namespace App\Http\Controllers;

use App\JuiceModel;
use Illuminate\Http\Request;

class JuiceController extends Controller
{
    public function insertjuice()
    {
        dd(request()->all);
    }
}

Result: I am getting 'null' as output

Help me where I am going wrong?

Upvotes: 0

Views: 1752

Answers (1)

Watercayman
Watercayman

Reputation: 8168

Inject the Illuminate\Http\Request object into the insertjuice method and then call the all() method on the variable within your JuiceController class:

public function insertjuice(Request $request)
{
    dd($request->all());
}

Upvotes: 1

Related Questions