Laravel Controller saying undefined Request, Any error here? - php

I am developing a laravel project but some part of my codes is returning an error of undefined request
Seems like i forgot something or ..
Here is a snip
Of my codes

the problem is with how you defined Request Parameter in your function, It should be like
public function insertrecord(Request $request) {}
Now you can proceed... Hope this helps..

Related

VSCode intelephense's fake errors - Livewire

That's not a breaking-mind thing but it's really annoying:
public function render(){
return view('home')->extends('layout.app')->section('content');
}
The error is
Undefined method 'extends'.
That's not even the only "fake error" i get but it's the only one in this project.
Does anyone know how to fix that?

Response in laravel component

I have a component SeenRecentlyProduct and return code:
return response()->view('components.products.seen-recently-product', compact('seenRecentlyProducts'))
->withCookie($cookie);
I get an error:
Illegal offset type in isset or empty
If I write this code in the controller, it works well. If I remove response() from the component, the same works well. Help please resolve the issue with the response and cookie in the component.

[swagger-codegen][php-symfony] No entrypoint in generated code?

I am attempting to generate a php-symfony server stub using swagger-codgen but I am not getting an index.php (or app.php or anything like that).
When I generate a server stub using the php-silex preset I get an index.php. If I google "silex .htaccess" I can easily find the mod_rewrite directives to get it working. However, when I generate code using the php-symfony preset I cannot find the entry point.
I attempted to combine the php-silex and php-symfony generated codebases (since silex is a symfony project) like so:
(index.php):
use Swagger\Server\Controller\GetTypesListController;
$app->GET('/image/list/types', function (Application $app, Request $request) {
$tlc = new GetTypesListController();
$response = $tlc->getTypeListAction($request);
return $response;
//new Response('How about implementing getTypeList as a GET method ?');
});
However, then I get errors like:
"Fatal error: Uncaught Error: Call to a member function getApiHandler() on null"
I modified the getApiHandler function of my generated GetTypesListController to instantiate the apiServer variable:
public function getApiHandler()
{
if (!isset($this->apiServer)){
$this->apiServer = new \Swagger\Server\Api\ApiServer();
}
return $this->apiServer->getApiHandler('getTypesList');
}
but this just gave me another error:
Undefined property: Swagger\Server\Controller\GetTypesListController::$container
(referencing SymfonyBundle-php/Controller/Controller.php on line 149)
I am obviously doing something wrong. I would really appreciate being pointed in the right direction.
Edit: I do realize that I'm not supposed to call controllers inside controllers.. I assume that I'm not supposed to combine these two generated codebases at all.

Call to undefined method Infusionsoft\Api\Rest\ContactService::addToGroup()

I'm using https://github.com/infusionsoft/infusionsoft-php but when I try to apply tags for a contact I'm getting this error.
Someone knows something about it?
As Mr. Void said there is no addToGroup() method in Rest Api. You should use this ContactService class instead of the one from Rest.

function to convert string to integer -- call to undefined function

I am creating a function that converts a users initials (STRING) to their userid (INT)
problem is when I call the function I get a call to undefined func error because the below declared function is no where to be found in the Source!
// connect to database -- this works, I checked it
function convertRadInitToRadID($radInits){
$sqlGetRadID="SELECT id FROM sched_roster WHERE radInitials == '".$radInits."'";
$resultGetRadID=mysql_query($sqlGetRadID);
$radID=mysql_result($resultGetRadID,0);
return $radID;
}
...I then create and array ($radNotOnVacay_and_NonMRNotonVacayWeekBeforeAndAfter) of user initials, it works with no errors I tested it independently
$randKey=rand(0,(count($radNotOnVacay_and_NonMRNotonVacayWeekBeforeAndAfter)-1));
$randRad=$radNotOnVacay_and_NonMRNotonVacayWeekBeforeAndAfter[$randKey];
$randAssignedRadID=convertRadInitToRadID($randRad); // call to undefined function error here
when I view source the function definition code (where I define the function) is nowhere to be seen in the source. Very strange. I tried placing it around different areas of the script, same error. The function definition is declared appropriately and is wrapped in .
Very strange. The function just doesn't appear. Quotations, syntax, semi-colons, etc are all spot on.
No syntax errors. Advice?
I Strongly agree with Answer #1.
In addition a usual problems occur in php if you are defining function after calling it. i.e. your calling code is before function defination then it will not run and will give an error of undefined function.
You can create a class then define this function in that class and on the time of calling you can call that function with help of $this->function(args)
I think this will resolve your problem in mean while i am trying to run your code on my machine, lets see what happen
May be your function is a method of some class. So, if it is, you should use it in another way:
MyClass::convertRadInitToRadID($radInits) // if static method
or like this
$class = new MyClass();
$class ->convertRadInitToRadID($radInits)
Trying to make sense of your question... Are you trying to call the function using JavaScript? If so, remember that JavaScript is run on the browser, and PHP is run on the server (and this is why when you "view source" you don't see the function anywhere). To send data back from JavaScript to PHP you should use AJAX.
I found the answer: I was using Jquery UI tabs.... there must be a conflict with tabs. When I run the code without tabs there is no issue.
Thanks for the '==' fix.. appreciate it. my bad
thanks for reminding me about the 80 char varname code limit

Categories