irankhosravi
1 year ago
149
12
Laravel

How to store row id in laravvel

Posted 1 year ago by irankhosravi

create.blade.php

            <form action="{{ route('requisitions.store')}}" method="post">
                {{ csrf_field() }}
                <div class="radio">
                    <label for="school">School</label>
                    <input type="radio" value="1" id="school" name="application">
                    <br>
                    <label for="equipment">Equipment</label>
                    <input type="radio" value="2" id="equipment" name="application">
                    <br>
                    <label for="level">Level</label>
                    <input type="radio" value="3" id="level" name="application">
                    <br>
                    <label for="place">Place</label>
                    <input type="radio" value="4" id="place" name="application">
                    <br>
                    <label for="tax">Tax</label>
                    <input type="radio" value="5" id="tax" name="application">
                    <br>
                    <label for="reactivation">Reactivation</label>
                    <input type="radio" value="6" id="reactivation" name="application">
                    <br>
                    <button type="submit" class="btn-warning btn">Send</button>
                </div>
            </form>

RequisitionController.php

public function store(Request $request, School $school)
{
    dd($school->id);
    $requisition = new Requisition();
    $requisition->user_id = auth()->user()->id;
    $requisition->school_id = $school->id;
    $requisition->type = $request->application;
    $requisition->status = 0;
    $requisition->approved = 0;
    $requisition->save();
    return redirect(route('requisitions.show'));
}

When I run dd($school->id); it display null.

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