Hello,
I am going through flyer series. Step by step.
I have my route setup like this.
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
Route::get('/', function () {
return view('pages.home');
});
Route::resource('flyers','FlyersController');
Route::get('{zip}/{street}','FlyersController@show');
Route::post('{zip}/{street}/photos',['as' => 'store_photo_path', 'uses' => 'FlyersController@addPhoto']);
I have created a form like this
@extends('layout')
@section('content')
<h1>Selling your home?</h1>
<form action="/flyers" method="POST">
@include('flyers.form')
@include('errors')
</form>
@stop
My form.blade.php includes the following code.
@inject('countries','App\Http\Utilities\Country')
<div class="row">
<div class="col-md-6">
{{ csrf_field() }}
<div class="form-group">
<label for="street">Street:</label>
<input type="text" name="street" id="street" class="form-control" value="{{old('street')}}" />
</div>
<div class="form-group">
<label for="city">City:</label>
<input type="text" name="city" id="city" class="form-control" value="{{old('city')}}" />
</div>
<div class="form-group">
<label for="zip">Zip / Postal Code:</label>
<input type="text" name="zip" id="zip" class="form-control" value="{{old('zip')}}" />
</div>
<div class="form-group">
<label for="country">Country:</label>
<select id="country" name="country" class="form-control">
@foreach($countries::all() as $country => $code)
<option value="{{$code}}">{{$country}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="country">State:</label>
<input type="text" name="state" id="state" class="form-control" value="{{old('state')}}" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="price">Sale Price:</label>
<input type="text" name="price" id="price" class="form-control" value="{{old('price')}}" />
</div>
<div class="form-group">
<label for="description">Home Description:</label>
<textarea type="text" name="description" rows="10" id="description" class="form-control">
{{old('description')}}
</textarea>
</div>
</div>
<div class="col-md-12">
<hr>
<div class="form-group">
<button class="btn btn-primary" type="submit">Create Flyer</button>
</div>
</div>
</div>@inject('countries','App\Http\Utilities\Country')
<div class="row">
<div class="col-md-6">
{{ csrf_field() }}
<div class="form-group">
<label for="street">Street:</label>
<input type="text" name="street" id="street" class="form-control" value="{{old('street')}}" />
</div>
<div class="form-group">
<label for="city">City:</label>
<input type="text" name="city" id="city" class="form-control" value="{{old('city')}}" />
</div>
<div class="form-group">
<label for="zip">Zip / Postal Code:</label>
<input type="text" name="zip" id="zip" class="form-control" value="{{old('zip')}}" />
</div>
<div class="form-group">
<label for="country">Country:</label>
<select id="country" name="country" class="form-control">
@foreach($countries::all() as $country => $code)
<option value="{{$code}}">{{$country}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="country">State:</label>
<input type="text" name="state" id="state" class="form-control" value="{{old('state')}}" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="price">Sale Price:</label>
<input type="text" name="price" id="price" class="form-control" value="{{old('price')}}" />
</div>
<div class="form-group">
<label for="description">Home Description:</label>
<textarea type="text" name="description" rows="10" id="description" class="form-control">
{{old('description')}}
</textarea>
</div>
</div>
<div class="col-md-12">
<hr>
<div class="form-group">
<button class="btn btn-primary" type="submit">Create Flyer</button>
</div>
</div>
</div>
Now the problem i am facing is that when click on submit button, the form does not get submitted. It send a GET request to /flyers. It should send a POST request but it sends a GET request. I tried with some other URL
like "/testUrl" and it worked fine and sent an POST request.
I cannot figure out why this send an GET request and not a POST request.
I also tried php artisan route:list.
It gave the following output.
C:\xampp\htdocs\flyer>php artisan route:list
+--------+----------+-----------------------+------------------+-------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-----------------------+------------------+-------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | |
| | GET|HEAD | auth/login | | App\Http\Controllers\Auth\AuthController@getLogin | guest |
| | POST | auth/login | | App\Http\Controllers\Auth\AuthController@postLogin | guest |
| | GET|HEAD | auth/logout | | App\Http\Controllers\Auth\AuthController@getLogout | |
| | GET|HEAD | auth/register | | App\Http\Controllers\Auth\AuthController@getRegister | guest |
| | POST | auth/register | | App\Http\Controllers\Auth\AuthController@postRegister | guest |
| | POST | flyers | flyers.store | App\Http\Controllers\FlyersController@store | auth |
| | GET|HEAD | flyers | flyers.index | App\Http\Controllers\FlyersController@index | auth |
| | GET|HEAD | flyers/create | flyers.create | App\Http\Controllers\FlyersController@create | auth |
| | PATCH | flyers/{flyers} | | App\Http\Controllers\FlyersController@update | auth |
| | DELETE | flyers/{flyers} | flyers.destroy | App\Http\Controllers\FlyersController@destroy | auth |
| | PUT | flyers/{flyers} | flyers.update | App\Http\Controllers\FlyersController@update | auth |
| | GET|HEAD | flyers/{flyers} | flyers.show | App\Http\Controllers\FlyersController@show | |
| | GET|HEAD | flyers/{flyers}/edit | flyers.edit | App\Http\Controllers\FlyersController@edit | auth |
| | GET|HEAD | test | | App\Http\Controllers\FlyersController@ftp | auth |
| | GET|HEAD | {zip}/{street} | | App\Http\Controllers\FlyersController@show | |
| | POST | {zip}/{street}/photos | store_photo_path | App\Http\Controllers\FlyersController@addPhoto | auth |
+--------+----------+-----------------------+------------------+-------------------------------------------------------+------------+