I have the following code in my update function in Company Model but it does not update data base?
public function update(Request $request, Company $company)
{
$companyupdate = Company::where('id', $company->id)->update([
'name'=>$request->input('name'),
'description'=>$request->input('description')
]);
if($companyupdate){
return redirect()->route('companies.show',['company'=>$company->id])
->with('success','Company Updated Successfully');
}
return back()->withInput();
}
And the below is my view code that contains form, which sends record to update function.But it is not updating the record in database. Anyone knows what the problem is..??where did i make a mistake in the code
@extends('layouts.app')
@section('content')
<div class="col-md-9 col-lg-9 col-sm-9 pull-left">
<!-- Jumbotron -->
<div class="row col-lg-12 col-md-12 col-sm-12" style="background-color:white; margin:10px;">
<form mehtod="post" action="{{ route('companies.update', [$company->id]) }}">
{{ csrf_field() }}
<input type="hidden" name="_method" value="put">
<div class="form-group">
<label for="company-name">Name<span class="required">*</span></label>
<input placeholder="Enter Name"
id="company-name"
required
name="name"
spellcheck="false"
class="form-control"
value="{{$company->name}}"
/>
</div>
<div class="form-group">
<label for="company-content">Description</label>
<textarea placeholder="Enter Description"
id="company-content"
required
name="description"
spellcheck="false"
class="form-control autosize-target text-left"
rows="5">
{{ $company->description }}</textarea>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit"/>
</div>
</form>
</div>
</div>
<div class="col-sm-3 col-md-3 col-lg-3 pull-right">
<!-- <div class="sidebar-module sidebar-module-inset">
<h4>About</h4>
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
</div>-->
<div class="sidebar-module">
<h4>Actions</h4>
<ol class="list-unstyled">
<li><a href="/companies/{{ $company->id }}">View Company</a></li>
<li><a href="/companies">All Companies</a></li>
</ol>
</div>
<!--<div class="sidebar-module">
<h4>Members</h4>
<ol class="list-unstyled">
<li><a href="#">March 2014</a></li>
</ol>
</div>-->
</div>
@endsection
````