I'm trying to insert the route according to the positus whatsapp api documentation in laravel 9, however, an error occurs in the route, could someone help me?
enter image description here
You cannot use positional argument after named arguments.
So you should use named arguments for every argument, or none at all.
Route::post('uri', 'action');
// OR
Route::post(uri: 'uri', action: 'action');
Should not be:
Route::post(uri: 'webhook',....
Should instead be:
Route::post('webhook', function(...
Related
I want to get a dynamic route function into Laravel 6.x
Route::get('/', 'HomeController#index')->name('home');
Route::get('/{code}', 'DetailController#detail1')->name('detail1');
Route::get('/impress', 'ImpressController#index')->name('impress');
If the URL contains a code with 4 digits, DetailController#detail1 should be called.
If the URL contains a code with 8 or 9 digits, DetailController#detail2 should be called.
However, it should still be possible, for example, to call the imprint controller.
How can this be realized?
Thanks for help.
You should use regex to define the constraint on your parameter:
Route::get('/{code89}', 'DetailController#detail1')->where('code89', '[0-9]{8,9}')->name('detail2');
Route::get('/{code4}', 'DetailController#detail1')->where('code4', '[0-9]{4}')->name('detail1');
See : https://laravel.com/docs/6.x/routing#parameters-regular-expression-constraints
Define them in this order or detail1 will always be matched and never detail2.
I just got an issue , i have 2 problems :
I want create a custom route for fast using without copy past code many time. Example Laravel 5 have default Route:resource (...) to make Restful! But i want to make my custom route function , Route:api(...) , Route:xxx(...) ... and I can custom it what I want !
How can I use multi route file ? Example : I can define route in App\User\route.user.php , App\Book\route.book.php .... because now, I can only use route file in route folder default !
I do not understand properly question 1. But for question 2, try this:
Go to app/Providers/RouteServiceProvider.php. Look for the function mapWebRoutes(). The line
require base_path('routes/web.php');
Duplicate it and change so you now have :
require base_path('routes/web.php');
require base_path('app/User/route.user.php');
require base_path('app/Whatever/route.whatever.php');
And laravel will load all routes within those files. Now, I've tested this, it works (Laravel 5.3) but I can't guarantee anything or if there are going to be conflicts with routes (duplicates). But yeah, it works.
I want to test that warning messages are displayed correctly when form fields are returned as invalid. The best way to do this would be to access the array in validation.php to get the name of the language line that I want to use.
How can I do this?
The documentation for Laravel is very great. You can access language files in resources/lang/{locale}/ easily with the provided trans() function (Laravel 5):
$expected = 'The :attribute may only contain letters.';
$actual = trans('validation.alpha');
$this->assertEquals($expected,$actual);
Please provide your attempts in the question next time. Also have a look at the SO tour (you will be rewarded with a bronze badge afterwards!)
I am trying to follow http://excellencemagentoblog.com/magento-create-custom-payment-method-api-based to build a payment gateway.
Everything is ok. But I need to pass a digital signature to payment gateway.
I think I should add it in the class Excellence_Pay_Model_Pay assignData($data)
info = $this->getInfoInstance();
$info->setCcType($data->getCcType())
->setCcOwner($data->getCcOwner())
->setCcLast4(substr($data->getCcNumber(), -4))
->setCcNumber($data->getCcNumber())
->setCcCid($data->getCcCid())
->setCcExpMonth($data->getCcExpMonth())
->setCcExpYear($data->getCcExpYear())
->setCcSsIssue($data->getCcSsIssue())
->setCcSsStartMonth($data->getCcSsStartMonth())
->setCcSsStartYear($data->getCcSsStartYear())
->setCcsignature($data->getCcsignature());
I have added one more field : ->setCcsignature($data->getCcsignature());
But I am not able to retrieve it on capture() or callApi() function. It is empty all the time. I thought ->setSsignature will use php magic set function, isn't it?
Any hint and advise will be appreciated.
Thanks guys!
Looks like you have to check if the value is being set or not by using $info->getCcsignature(). After the value has been set, if it is being passed on to capture() or callApi() function. You just need to follow the basic steps of debugging. echo-die, echo-die and so on. Good Luck.
Hello I am having a problem with my joomla code
when I try xxxxxxxxxindex.php?option=com_blast&task=ccis this is going to the controller function ccis and when I tr xxxxxxxxxxxxxxindex.php?option=com_blast&task=ccim?data=123 this is going to the function display, I want this to come to the function ccis, how can I do this ??
whats wrong in my joomla
Thanks
Use &data=123 instead of ?data=123. In your URL you get the following arguments:
option=com_blast
task=ccim?data=123
As you see, data is not a separate argument since you are not using & to separate it from the previous argument.