dimanche 7 juillet 2019

Why Laravel controller store function inserts null values in database

I want to insert data into a table mysql database through controller store function but always null values inserted, I don not know where is the problem Office Model

class Office extends Model
{
Protected $fillable = array('office_name_local', 'office_english_name');
}

Controller

public function store(Request $request)
{
    $validatedData = $request->validate([
        'office_name_local' => 'required', 'office__name_english' => 'required'
    ]);

    $office = Office::create($validatedData);

    return redirect('/createOffice')->with('success', 'Office is successfully saved');
}

My .blade.php

<form method="POST" class="form-horizontal well col-xs-8 col-xs-offset-2" 
action="">
<div class="form-group row">
<div class="col-md-6">
<label for="office_name_local"> local name</label>
<input type="text" class="form-control" name="office_name_local" required>   
</div>
</div>  
<div class="form-group row">
<div class="col-md-6">
<label for="office_name_english"> English name</label>
<input  type="text" class="form-control" name="office_name_english"  required>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
 
 </button>
 </div>
 </div>
 </form>
 </form> 



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire