Updating on the current id - laravel

I'm trying to update my pivot table using radio button. Where I don't need to go to another url. But it doesn't get the values of radio button when performing update. Here how it looks.
//SELECT
Route::get('/documents/pending/view/{id}',
[
'uses' => '\App\Http\Controllers\DocumentController#readDocumentsSentForApproval',
'as' => 'document.viewPending',
]);
//UPDATE
Route::post('/documents/pending/view/{id}',
[
'uses' => '\App\Http\Controllers\DocumentController#updateApprovalsDocument',
'as' => 'document.viewPending',
]);
Controller:
public function readDocumentsSentForApproval($id)
{
$viewPendingDocuments = DB::table('approvals_document')
->select('documents.title', 'documents.content', 'categories.category_type', 'documents.id')
->join('documents', 'documents.id', '=', 'approvals_document.document_id')
->join('categories', 'categories.id', '=', 'documents.category_id')
->where('documents.id', '=', $id)
->first();
$getApprovers = DB::table('approvals_document')
->select('users.first_name', 'users.middle_name', 'users.last_name', 'users.username', 'approvals_document.updated_at', 'approvals_document.isApprove', 'approvals_document.id', 'approvals_document.approver_id')
->join('documents', 'documents.id', '=', 'approvals_document.document_id')
->join('users', 'users.id', '=', 'approvals_document.approver_id')
->where('documents.id', '=', $id)
->get();
return view ('document.viewPending')
->with('viewPendingDocuments', $viewPendingDocuments)
->with('getApprovers', $getApprovers);
}
public function updateApprovalsDocument(Request $request)
{
//Getting the hidden input named = id.
$id = $request->get('id');
$document = DB::table('approvals_document')
->where('approvals_document.id', '=', $id)
->update(['isApprove' => $request->status, 'updated_at' => new DateTime]);
return redirect()->back();
}
View
#foreach($getApprovers as $list)
<tr>
<td>
#if(Auth::id() == $list->approver_id)
<form class="form-inline" id="submitMe" method="post" action="{{ url('documents/pending/view' . $list->id) }}">
<input type="hidden" name="id" value="{{ $list->id }}">
<div class="form-group">
<label>
<input type="radio" onclick="showApprove()" name="status" value="1">Approve</label>
<label>
<input type="radio" onclick="showReject()" name="status" value="2">Reject</label>
</div>
<input type="hidden" name="_token" value="{{ Session::token() }}">
</form>
#endif
</td>
</tr>
#endforeach
I passed the current url on the action so it will know what id is it. Is this the proper way updating? Thanks for your help!

There is nothing wrong with it, but I think the recommended way in Laravel would be to use the patch route, as this is the RESTful way of doing it.
post would be used for creating the entity, patch is used for updating it.
The only changes you would need to make, is the route binding (post to patch) and adding the form spoofing for the method
<input type="hidden" name="_method" value="PATCH">
https://laravel.com/docs/5.3/routing#form-method-spoofing
You could also use the route binding for the id, instead of passing it in as a form field. This would be more advantageous if you wanted to do validation on that route (e.g. a middleware, allowing only the owner of that record to update it).

I already find a solution for this using Form Method Spoofing
public function readDocumentsSentForApproval($id)
{
$viewPendingDocuments = DB::table('approvals_document')
->select('documents.title', 'documents.content', 'categories.category_type', 'documents.id')
->join('documents', 'documents.id', '=', 'approvals_document.document_id')
->join('categories', 'categories.id', '=', 'documents.category_id')
->where('documents.id', '=', $id)
->first();
$getApprovers = DB::table('approvals_document')
->select('users.first_name', 'users.middle_name', 'users.last_name', 'users.username', 'approvals_document.updated_at', 'approvals_document.isApprove', 'approvals_document.approver_id',
'approvals_document.id as approvalDocumentId', 'documents.id as documentId')
->join('documents', 'documents.id', '=', 'approvals_document.document_id')
->join('users', 'users.id', '=', 'approvals_document.approver_id')
->where('documents.id', '=', $id)
->get();
return view ('document.viewPending')
->with('viewPendingDocuments', $viewPendingDocuments)
->with('getApprovers', $getApprovers);
}
View:
<form class = "form-inline" role = "form" id = "submitMe" method = "POST" action = "/documents/pending/{{ $list->documentId}}/view">
{{ method_field('PATCH') }}
<input type = "hidden" name = "id" value = "{{ $list->approvalDocumentId }}">
<div class = "form-group">
<label><input type = "radio" onclick = "showApprove()" name = "status" value = "1"> Approve</label>
<label><input type = "radio" onclick = "showReject()" name = "status" value = "2"> Reject</label>
</div>
<input type = "hidden" name = "_token" value = "{{ Session::token() }}">
</form>

Related

Scope Search in Laravel returning all results from empty request()

I am working with Scope Search and cannot figure out why my ternary operator is working like it is.
I have the following in my view:
<form action='/search-results' method='GET'>
{{ csrf_field() }}
<div style="background-color:white">
<div class="container py-5">
<div class="input-group custom-search-form md-form mt-0">
<input type="text" class="form-control" name="city" placeholder="City...">
<input type="text" class="form-control" name="search" placeholder="Search...">
<span class="input-group-btn">
<button class="btn btn-default-sm" type="submit">
Submit
</button>
</div>
</div>
</div>
</form>
I have the following in my Controller:
public function index()
{
{
//The search() function is accessed using 'scopeSearch' within NPIData Model
$providers = NPIData::lookup()->orderBy('NPI')->paginate(20);
return view('inc.searchresults', compact('providers'));
}
I have the following in my NPIData model:
public function scopeLookup($query)
{
//this says if the request is NOT empty, return $query (which would be an empty query), otherwise return $query with all the conditions listed
return empty(request()) ? $query : $query->where('NPI', 'like', '%'.request()->search.'%')
->where('Entity Type Code', '=', '1')
->where('Provider Business Mailing Address City Name', '=', request()->zip)
->orWhere('Provider First Name', 'like', '%'.request()->search.'%')
->orWhere('Provider Last Name (Legal Name)', 'like', '%'.request()->search.'%');
}
}
When a search term is entered in both the 'city' and 'search' text inputs, the $query executes correctly. However, if one or both inputs are left blank, the $query returns everything from my NPIData table. If one or both inputs are left blank, I want my $query to return nothing so the search results are blank. I assume I have to change something in the second part of my ternary operator but cannot figure out what that should be.
You can use where 1 < 0 which is pretty standard way to get empty result
public function scopeLookup($query)
{
//this says if the request is NOT empty, return $query (which would be an empty query), otherwise return $query with all the conditions listed
return empty(request()) ? $query->whereRaw('1 < 0') : $query->where('NPI', 'like', '%'.request()->search.'%')
->where('Entity Type Code', '=', '1')
->where('Provider Business Mailing Address City Name', '=', request()->zip)
->orWhere('Provider First Name', 'like', '%'.request()->search.'%')
->orWhere('Provider Last Name (Legal Name)', 'like', '%'.request()->search.'%');
}

Update data in laravel 6

I try to create crud in laravel 6. Create, Read and Delete process is running well. But when Update process, the data in table not change. Could anyone help me to find the problem ? The following my code.
Route
Route::get('/blog', 'BlogController#index');
Route::get('/blog/add','BlogController#add');
Route::post('/blog/store','BlogController#store');
Route::get('/blog/edit/{id}','BlogController#edit');
Route::post('/blog/update','BlogController#update');
Controller
public function index()
{
$blog = DB::table('blog')->get();
return view('blog',['blog' => $blog]);
}
public function edit($id)
{
$blog = DB::table('blog')->where('blog_id', $id)->get();
return view('edit', ['blog'=>$blog]);
}
public function update(Request $request)
{
DB::table('blog')->where('blog_id',$request->blog_id)->update([
'blog_title' => $request->title,
'author' => $request->author]);
return redirect('/blog');
}
View
#foreach ($blog as $n)
<form method="post" action="/blog/update" />
{{ csrf_field() }}
Title <input type="text" name="title" value="{{ $n->title}}">
Author<input type="text" name="author" value="{{ $n->author}}">
<button type="submit" class="btn btn-secondary">Update</button>
</form>
#endforeach
You must provide id in your route
Route::post('/blog/update/{id}','BlogController#update');
In update method add parameter id and then find product against id
public function update(Request $request, $id)
{
DB::table('blog')->where('blog_id',$id)->update([
'blog_title' => $request->title,
'author' => $request->author]);
return redirect('/blog');
}
#foreach ($blog as $n)
<form method="post" action="{{ route('your route name'), ['id' => $$n->id] }}" />
{{ csrf_field() }}
Title <input type="text" name="title" value="{{ $n->title}}">
Author<input type="text" name="author" value="{{ $n->author}}">
<button type="submit" class="btn btn-secondary">Update</button>
</form>
#endforeach
try separating the update into two statements like so
$blog = DB::table('blog')->where('blog_id',$id)->first();
$blog->update([
'blog_title' => $request->title,
'author' => $request->author]);
Also you might want to use models in the future so you can do it like
$blog = Blog::where('blog_id',$id)->first();
Doesn't really shorten your code but it improves the readibility.
Do your update like this:
public function update(Request $request)
{
$post = DB::table('blog')->where('blog_id',$request->blog_id)->first();
$post->blog_title = $request->title;
$post->author = $request->author;
$post->update();
return redirect('/blog');
}

How to put 'id' value in ajax url?

I had dependant dropdown selection in edit page to edit staff profile. The view for the selection is this:
<div class="form-group">
<div class="row">
<div class="col-lg-3">
<label for="kategori">Kategori:</label>
</div>
<div class="col-lg-4">
<select name="kategori" class="form-control select2" style="width:250px">
<option value="">--- pilih ---</option>
#foreach ($categories as $key => $value)
<option value="{{ $key }}">{{ $value }}</option>
#endforeach
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-3">
<label for="pangkat">Pangkat:</label>
</div>
<div class="col-lg-4">
<select name="pangkat" class="form-control select2"style="width:250px">
<option>--pilih--</option>
</select>
</div>
</div>
</div>
The ajax script as follows:
<script type="text/javascript">
jQuery(document).ready(function ()
{
jQuery('select[name="kategori"]').on('change',function(){
var CatID = jQuery(this).val();
if(CatID)
{
jQuery.ajax({
url : '/edit_profil/{id}/getpangkat/' +CatID,
type : "GET",
dataType : "json",
success:function(data)
{
console.log(data);
jQuery('select[name="pangkat"]').empty();
jQuery.each(data, function(key,value){
$('select[name="pangkat"]').append('<option value="'+ key +'">'+ value +'</option>');
});
}
});
}
else
{
$('select[name="pangkat"]').empty();
}
});
});
</script>
This is the route code to the edit page and also to the selection value:
Route::get('/edit_profil/{id}', 'Modul\ProfilController#edit')->name('editProfil');
Route::get('edit_profil/{id}/getpangkat/','Modul\ProfilController#getpangkat');
The controller for edit page is:
$dataItemregistration = DB::table('itemregistrations')
->join('sections', 'itemregistrations.sectionid', '=', 'sections.sectionid')
->join('categories', 'itemregistrations.categoryid', '=', 'categories.categoryid')
->join('sandaran', 'itemregistrations.sandarid', '=', 'sandaran.sandarid')
->join('statusrumah', 'itemregistrations.statusrumahid', '=', 'statusrumah.statusrumahid')
->join('bangsa', 'itemregistrations.bangsaid', '=', 'bangsa.bangsaid')
->join('kahwin', 'itemregistrations.kahwinid', '=', 'kahwin.kahwinid')
->join('agama', 'itemregistrations.agamaid', '=', 'agama.agamaid')
->join('jantina', 'itemregistrations.jantinaid', '=', 'jantina.jantinaid')
->join('negeri', 'itemregistrations.negeriid', '=', 'negeri.negeriid')
->join('statuspro', 'itemregistrations.statusproid', '=', 'statuspro.statusproid')
->join('statuspengundi', 'itemregistrations.statuspengundiid', '=', 'statuspengundi.statuspengundiid')
->join('kategori_bank', 'itemregistrations.bankid', '=', 'kategori_bank.bankid')
->join('operasi', 'itemregistrations.operasiid', '=', 'operasi.operasiid')
->select('itemregistrations.*', 'sections.sectionname', 'categories.categoryname', 'sandaran.sandarname', 'statusrumah.status_rumah_semasa', 'bangsa.bangsaname','kahwin_status', 'agamaname', 'jantinaname', 'negeriname', 'statusproname', 'statusmengundi', 'bankname', 'operasiname')
->where('itemregistrations.itemregistrationid', $id)
->first();
$categories = DB::table('categories')->pluck("categoryname","CategoryID");
return view('profil.edit', compact('dataItemregistration', 'categories', 'id'));
Controller for getpangkat is:
public function getpangkat($id)
{
$operasi = DB::table("operasi")->where("CategoryID",$id)->pluck("operasiname","OperasiID");
return json_encode($operasi);
}
I had problem to get the value of dependant dropdown because of the url path. The edit page path contain the staff id like this "http://127.0.0.1:8000/edit_profil/194", but I don't know how to set the url in the ajax call contain the staff id value.
How can I modify the code to get dependant dropdown works?
Change your ajax url to this as you need to pass id between /edit_profil/ and /getpangkat/
url : 'edit_profil/{{ $id }}/getpangkat/' +CatID,
and in your route you need to specify the variable CatID also
Route::get('edit_profil/{id}/getpangkat/{CatID}','Modul\ProfilController#getpangkat');
And in your function
public function getpangkat($id, $CatID)
{
$operasi = DB::table("operasi")->where("CategoryID",$CatID)->pluck("operasiname","OperasiID");
return json_encode($operasi);
}
Hope it helps!

Laravel Pagination Appends Not Keeping Search Data

I've been able to implement the pagination and appends() on my form and it does show the proper values in the url on page 2, though it doesn't actually bring the values back into the form/query, it simply resets the actual data being searched for and displays all.
Here is my form code and the appends.
{{ Form::open(array('class' => 'stdform', 'method' => 'post', 'name' => 'all')) }}
<input type="text" name="srch_lname" class="input-large"
value="{{ Input::old('srch_lname', Session::get('srch_lname')) }}" />
<input type="text" name="srch_fname" class="input-large"
value="{{ Input::old('srch_fname', Session::get('srch_fname')) }}" />
.
.
.
<?php echo $employees->appends(array("srch_lname" => Session::get('srch_lname'),
"srch_fname" => Session::get('srch_fname') ))->links(); ?>
And my Controller
public function getIndex() {
$srch_lname = Session::get('srch_lname');
$srch_fname = Session::get('srch_fname');
$employees = vEmployees::co()->restrictions()
->where('lastname', 'LIKE', $srch_lname . '%')
->where('firstname', 'LIKE', $srch_fname . '%')
->paginate(10);
return View::make('employees.index')
->with('employees', $employees)
->with('title', 'Users');
}
public function postIndex() {
if (Input::has('btnSearch')) {
return Redirect::to('/employees')->with('search', 1)
->with('srch_lname', Input::get('srch_lname'))
->with('srch_fname', Input::get('srch_fname'));
else {
return Redirect::to('/employees');
}
}
Full Form
{{ Form::open(array('class' => 'stdform', 'method' => 'post', 'name' => 'all')) }}
<div class="stepContainer">
<div class="formwiz content">
<h4 class="widgettitle">Search for an Employee</h4>
<p>
<label>Lastname</label>
<span class="field">
<input type="text" name="srch_lname" class="input-large"
value="{{ Input::old('srch_lname', Session::get('srch_lname')) }}" />
</span>
</p>
<p>
<label>Firstname</label>
<span class="field">
<input type="text" name="srch_fname" class="input-large"
value="{{ Input::old('srch_fname', Session::get('srch_fname')) }}" />
</span>
</p>
</div>
</div>
<div class="actionBar" style="text-align: right;">
<button class="btn btn-primary" name="btnSearch" value="1">
Search for Employee(s)
</button>
</div>
{{ Form::close() }}
You need to pass your inputs to the view so that Input::old() has values to work with after the redirect from postIndex to getIndex.
in getIndex(), add to View::make()
->with('input', [ 'srch_lname'=> $srch_lname, 'srch_fname' => $srch_fname ]);
It looks like you do not have the pageSearch value in your pagination query string. Try this.
<?php echo $employees->appends(
array("btnSearch" => "1",
"srch_lname" => Session::get('srch_lname'),
"srch_fname" => Session::get('srch_fname') )
)->links(); ?>
I made a small sample but since I don't have your employees I just used the User model and commented out the filtering, just used as a test to pass and get input values.
Note the change to Input:: from Session, in getIndex() and in the form for $employees->appends(). Use Input instead of Session, I did not see anywhere in your code where you save the filter values in session variables.
I also changed the Redirect::to() to pass the parameters in the URL since it is a get method.
I tested and the filter values are passed to getIndex() and the form fields, also the inputs get properly passed by pagination links.
class EmployeeController extends BaseController
{
public
function getIndex()
{
$srch_lname = Input::get('srch_lname');
$srch_fname = Input::get('srch_fname');
$employees = User::query()
//->where('lastname', 'LIKE', $srch_lname . '%')
//->where('firstname', 'LIKE', $srch_fname . '%')
->paginate(10);
// make input available for page's form fields as old input
Session::flash('_old_input', Input::all());
return View::make('employees')
->with('employees', $employees)
->with('title', 'Users');
}
public
function postIndex()
{
if (Input::has('btnSearch'))
{
return Redirect::to('/employees?search=1&srch_lname=' . urlencode(Input::get('srch_lname')) . '&srch_fname=' . urlencode(Input::get('srch_fname')));
//return Redirect::to('/employees')->with('search', 1)
// ->with('srch_lname', Input::get('srch_lname'))
// ->with('srch_fname', Input::get('srch_fname'));
}
else
{
return Redirect::to('/employees');
}
}
}
Form and ->appends():
{{ Form::open(array('class' => 'stdform', 'method' => 'post', 'name' => 'all')) }}
<div class="stepContainer">
<div class="formwiz content">
<h4 class="widgettitle">Search for an Employee</h4>
<p>
<label>Lastname</label>
<span class="field">
<input type="text" name="srch_lname" class="input-large"
value="{{ Input::old('srch_lname', Session::get('srch_lname')) }}" />
</span>
</p>
<p>
<label>Firstname</label>
<span class="field">
<input type="text" name="srch_fname" class="input-large"
value="{{ Input::old('srch_fname', Session::get('srch_fname')) }}" />
</span>
</p>
</div>
</div>
<div class="actionBar" style="text-align: right;">
<button class="btn btn-primary" name="btnSearch" value="1">
Search for Employee(s)
</button>
</div>
{{ Form::close() }}
<?php echo $employees->appends(array("srch_lname" => Input::get('srch_lname'),
"srch_fname" => Input::get('srch_fname') ))->links(); ?>
I got it working! I continued to do some research and running the search through POST was really a major issue in adding that gap between the search itself and holding the data into the GET method of pagination.
I'll run through everything I did below for anyone in the future having the same issue.
I first created a Route that would direct to a new function in my EmployeesController
Route::get('emp_srch', 'EmployeesController#search');
And created the new function in the Controller
public function search() {
$srch_lname = Input::get('srch_lname');
$srch_fname = Input::get('srch_fname');
$employees = vEmployees::co()->restrictions()
->where('lastname', 'LIKE', $srch_lname . '%')
->where('firstname', 'LIKE', $srch_fname . '%')
->orderBy('lastname')
->orderBy('firstname')
->paginate(10);
Session::flash('_old_input', Input::all());
return View::make('employees.index')
->with('employees', $employees)
->with('title', 'Users')
->with('pagetitle', 'Employees')
}
It's essentially the function I had in the getIndex though rearranging the way the search was functioning I believe was the defining factor in actually getting this to work in my case.
I also changed the url on the form, which directed to my new Route. As well as changing the form so it uses the GET Method and no longer POST.
{{ Form::open(array('url' => 'emp_srch', 'class' => 'stdform', 'method' => 'get')) }}
I do want to thank vladsch and whoacowboy for helping push me in the right direction(s).

Laravel. Controller not getting the values from the Form

The controller is not getting the data from the FORM. I realise that the Form has by default a Post method, while the Route is using a Get, but if I change that, then the form will not display the form fields. Validation fails as the "required" does not get any values, so it returns to the same page. If I remove the validation filter, then it does go to the results page, but all it does is show ALL of the content of the table, since it is getting no parameters (where) from the Form. The weird thing is that in the past, it worked, but I must have messed up with some part of the code and now it doesn't. To save space here I have left out many fields which dont play a role in the problem.
The Form has three interdependent Fields Country, Region and Town, which are filled up alright.
FORM:
<form action = "{{URL::route('sacapropiedades')}} "class="form-horizontal" id="my_form" name="my_form">
<div class="form-group">
<div class="col-sm-3">
<label for="country">Pays</label>
<select name ="country" {{ (Input::old('country')) ?' value ="' . e(Input::old('country')). '"' : '' }} id = "country" class="form-control">
#foreach($countries as $country)
<option value="{{$country->country}}">{{$country->country}}</option>
#endforeach
</select>
</div>
<div class="col-sm-3">
<label for="town">Ville</label>
<select name ="town" {{ (Input::old('town')) ?' value ="' . e(Input::old('town')). '"' : '' }}id = "town" class="form-control">
</select>
</div>
</div><!-- END OF THIRD FORMGROUP -->
<div class="form-group">
<div class="col-sm-4">
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-success">Enviar</button>
<button type="reset" class="btn btn-danger">Borrar</button>
</div>
</div>
</form>
ROUTES
Route::get('realestate/listproperty', array(
'as' =>'sacapropiedades',
'uses' =>'countriesregionstownsController#findproperty'
));
CONTROLLER
public function findproperty(){
/*IT REPEATS THE COUNTRY QUERY ABOVE BECAUSE IT IS GOING TO USE IT
*ON THE RESULTS PAGE AND IT GIVES THE USER TO SELECT AGAIN OTHER COUNTRIES
*WITHOUT HAVING TO RETURN TO THE FIRST PAST PAGE*/
$countries = DB::table('properties')
->select('country')
->distinct()
->get();
/*FIRST VALIDATE INPUT DATA*/
$validator = Validator::make(Input::all(),
array(
'country' =>'required',
'regions' =>'required',
'transaction' =>'required',
'town' =>'required'
));
if($validator->fails()){
return Redirect::route('showrealestate')
->withErrors($validator)
->withInput();
}
else{
$country = Input::get('country');
$region = Input::get('regions');
$town = Input::get('town');
$transaction = Input::get('transaction');
$pricefrom = Input::get('pricefrom');
$priceto = Input::get('priceto');
$roomsfrom = Input::get('roomsfrom');
$roomsto = Input::get('roomsto');
$builtyear = Input::get('builtyear');
$swimming = Input::get('swimming');
$garden = Input::get('garden');
$garage = Input::get('garage');
$message = Input::get('message');
}
$country = DB::table('countries')->where('id_pais', $country)->pluck('nombre_pais');
$region = DB::table('regions')->where('id_region', $region)->pluck('nombre_region');
$town = DB::table('cities')->where('id_localidad', $town)->pluck('nombre_localidad');
$users = DB::table('users')
->join('properties', 'users.id', '=', 'properties.id_user_fk')
->select('users.email', 'properties.id_user_fk', 'properties.country', 'properties.region', 'properties.town',
'properties.price', 'properties.rooms','properties.m2','properties.swimming',
'properties.garden','properties.garage','properties.builtyear','properties.message',
'properties.pic1',
'properties.pic2', 'properties.pic3','properties.pic4','properties.pic5','properties.pic6');
if (!empty($country)) {
$users = $users->where('country', '=', $country);
}
if (!empty($region)) {
$users = $users->where('region', '=', $region);
}
if (!empty($town)) {
$users = $users->where('town', '=', $town);
}
if (!empty($transaction)) {
$users = $users->where('transaction', '=', $transaction);
}
if (!empty($pricefrom)) {
$users = $users->where('price', '>', $pricefrom);
}
if (!empty($priceto)) {
$users = $users->where('price', '<', $priceto);
}
if (!empty($roomsfrom)) {
$users = $users->where('rooms', '>', $roomsfrom);
}
if (!empty($roomsto)) {
$users = $users->where('rooms', '<', $roomsto);
}
if (!empty($builtyear)) {
$users = $users->where('builtyear', '>', $builtyear);
}
if (!empty($swimming)) {
$users = $users->where('swimming', '=', $swimming);
}
if (!empty($garage)) {
$users = $users->where('garage', '=', $garage);
}
if (!empty($garden)) {
$users = $users->where('garden', '=', $garden);
}
if (!empty($message)) {
$users = $users->where('message', '=', $message);
}
$users = $users->get();
return View::make('realestate.externa.listproperty', compact('users','countries'));
}
A post method is mandatory, otherwise Laravel will not redirect it to the correct method with the correct data. How was it working before? By luck, probably. :)
Route::get('realestate/listproperty', array(
'as' =>'sacapropiedades',
'uses' =>'countriesregionstownsController#findproperty'
));
Route::post('realestate/listproperty', array(
'as' =>'sacapropiedades',
'uses' =>'countriesregionstownsController#findproperty'
));
or
Route::match(array('GET', 'POST'), 'realestate/listproperty', array(
'as' =>'sacapropiedades',
'uses' =>'countriesregionstownsController#findproperty'
));
or
Route::any('realestate/listproperty', array(
'as' =>'sacapropiedades',
'uses' =>'countriesregionstownsController#findproperty'
));
Then you'll probably need to not validate on GET:
if (Request::getMethod() == 'POST')
{
$validator = Validator::...
}
EDIT:
Sorry I overlooked this problem:
Instead of writing your FORM tag manually, use Laravel's FormBuilder class:
<?php Form::open(array('route' => 'sacapropiedades', 'class' => 'form-horizontal', 'id' => 'my_form', 'name' => 'my_form')); ?>
The difference is that it will add the method for you and it will also add a csrf token to your form.

Resources