Laravel - Raw query using Rest API JSON
<p>I'm pretty new to Laravel and i'd like to know if I'm doing the follow API in the proper way.</p>

<p>I have a mobile app that will make a request to have the restaurants around a position, sending this URL with parameters (lng, lat, rad) :</p>

<pre><code>localhost/restaurant/@59.931412,59.931342,15
</code></pre>

<p>I came up with this route for the moment:</p>

<pre><code>Route::get('restaurants/@{latitude},{longitude},{radius}', 'RestaurantsController@show'})
-&gt;where(['latitude' =&gt; '[0-9]+', 'longitude' =&gt; '[0-9]+', 'radius' =&gt; '[0-9]+']);
</code></pre>

<p>But I saw that if I want to make it REST I should use:</p>

<pre><code>Route::resource('restaurants', 'RestaurantsController');
</code></pre>

<p>What I don't understant is: </p>

<ul>
<li>how do i pass the parameters ? </li>
<li>The mobile app is supposed to send an GET verb and i have to make a
'show' method in my controller ?</li>
<li>instead of doing verification of parameters in the route, i have to use a
middleware at the begining of the methode, right ?</li>
</ul>

<p>Bonus : Is my query well written, is it secure ?</p>

<pre><code>public function show($latitude, $longitude, $radius)
{
    //Middleware to control parameters later

    $results = DB::select(
                'SELECT * ( 3959 * acos( cos( radians(:latitude) ) *
                cos( radians( lat ) ) * cos( radians( lng ) - radians(:longitude) ) +
                sin( radians(:latitude) ) * sin( radians( lat ) ) ) ) AS distance FROM events HAVING 
                distance &lt; :radius ORDER BY distance LIMIT 0 , 20',
                ["latitude" =&gt; $latitude, "longitude" =&gt; $longitude, "radius" =&gt; $radius]);

    return Response::json($results);
}
</code></pre>

<p>Edit : It's such a mess in my head, i have so many question that i came up with a post title a bit different to my questions, sorry.</p>

<p><strong>Update 1:</strong>
Here is my route</p>

<pre><code>Route::get('restaurants/@{latitude},{longitude},{radius}', 'EventsController@show');
</code></pre>

<p>and my request rule (who's injected in the controller)</p>

<pre><code>public function rules()
    {
        return [
            'latitude' =&gt; 'required|digits_between:-90,90',
            'longitude' =&gt; 'required|digits_between:-180,180',
            'radius' =&gt; 'required|numeric',
        ];
    }
</code></pre>

<p>i'm having the page "The page isn't redirecting properly"
and in the log i have "Invalid request (Unexpected EOF)"</p>

<p>i use artisan and my url is : <a href="http://localhost:8000/restaurants/@59.93141200,30.31992300,15" rel="nofollow">http://localhost:8000/restaurants/@59.93141200,30.31992300,15</a></p>

<p>without the request in the controller, the route works...
I tried puting simple rule like 'required' only for latitude alone, it still does not want to access the request process. </p>

<p><strong>The probleme comes from required</strong> (required: The field under validation must be present in the input data.), i don't understant values are here.</p>