How to route GET and POST for same pattern in Laravel?
You could try the following:
Route::controller('login','AuthController');
Then in your AuthController class
implement these methods:public function getIndex();
public function postIndex();
It should work ;) GET and POST controller for one route in Laravel
This is an example of how you would implement the rule:
Route::match(['get', 'post'], 'order/{invoice}/confirm', ['uses' => 'OrderController@paymentConfirmation', 'as' => 'order.payment.confirmation']);
How to configure a route of extracting data from the same table in laravel
What you need to do is just, pass the object $farm
and I'll automatically generate an URL to this route so it becomes like that
http://example.com/clinic/{farm}
to
http://example.com/clinic/1 <!-- if the Id was 1
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('vaccine1', $farm->id)}}">
0 - 2 (months)
</a>
</div>
or like that<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('vaccine1', ['farm' => $farm->id ])">
0 - 2 (months)
</a>
</div>
More info check out the docs for URLs For Named Routes Two route variables with the same start URL in Laravel 8
No it's not possible because after Laravel is confused, doesnt know what do zou want.
Can a Laravel POST route return a view instead of redirecting to another route?
The pattern is called post-redirect-get, or PRG. It is convention because POST should be used for requests that change data, whereas GET should be used to simply display data.
If you return a view after a POST, the user can hit reload, and (probably unintentionally) change data again, eg buy something a second time. By using PRG, the user hitting reload simply reloads the last GET, which just re-displays something.
NOTE: There is some advice in the comments on your question to ignore this convention. I think that is unwise and dangerous, these conventions exist for good reasons.
Redirect routes to separate controllers for same url pattern?
In Routes you can only use one where condition. So you have to make one regular expression to include all conditions.
Or you can just have dashboard
and login
routes before universal {slug}
.
For example:
Route::get('/login', [...]);
Route::get('/dashboard', [...]);
Route::get('/{slug}', [PageController::class, 'getPage'])->name('link_view');
Laravel Duplicate Route names
No, you can not use the same name for 2 different routes as is stated in the documentation if you really need to name the routes you should look for different names, but if there's no need to have named routes you can have each url with its method like:
Route::get('/your-url', 'App\Http\Controllers\UserController@addView');
Route::post('/your-url', 'App\Http\Controllers\UserController@store');
If you are making a CRUD you can have:Route::resource('user', UserController::class);
This will create all the urls needed for a CRUD:
Related Topics
PHP MySQL Query Where X = $Variable
Get Folders with PHP Glob - Unlimited Levels Deep
How to Add 5 Minutes to Current Datetime on PHP < 5.3
Laravel 4 - Including a "Partial" View Within a View (Without Using Blade Template)
How to Use Etags in a PHP File
Use of Undefined Constant Mcrypt_Rijndael_128 - Assumed 'Mcrypt_Rijndael_128'
Force Cache Refresh After Deployment
Finding First Day of Week via PHP
Where to Store Database Login Credentials for a PHP Application
PHP Flush() Not Working in Chrome
How to Split a String into an Array of Unicode Characters in PHP
Php: Fastest Way to Check for Invalid Characters (All But A-Z, A-Z, 0-9, #, -, ., $)
PHP Splitting an Array into Two Arrays - Keys Array and Values Array
Flip (Transpose) the Rows and Columns of a 2D Array Without Changing the Number of Columns
In a PHP5 Class, When Does a Private Constructor Get Called
PHP - Swiftmailer Using Starttls and Self Signed Certificates