1 year ago

How to store id in show function in laravel 5-4

Posted 1 year ago by irankhosravi

In my controller in my show function in laravel I want the get the id that shows in browser show when I browse it it shows like this.


Now how to save id of schools table to school_id of requisitions.

public function store(Request $request, School $school)
    $school_id = $request->get($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;
    return redirect(route('school.index'));


class Requisition extends Model
    public function schools()
        return $this->belongsTo(School::class, 'school_id');


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

I did send already in create function.

public function create()
    $school = School::all();
    return view('Admin.requisitions.create', compact('school'));

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