ERROR : syntax error, unexpected '$app' (T_VARIABLE), expecting ')' - laravel

Found in [consoletvs\charts\src\ChartsServiceProvider.php]
Error
Found this error.. any ideas ?

The error is very clear, it tells you that you are missing one ) after your $app variable.
Try this :
public function register(): void {
$this->app->singleton(Registrar::class, fn(Application $app)) => new Registrar (
//...
);
}

Related

Error Handling / Throw error in Strapi 4.0

in Strapi 4.0, i want to validate the input before saving. So i created lifecycles.js file as per the documentation and added the code:
module.exports = {
beforeCreate(event) {
//validation login here;
if (!valid) {
throw strapi.errors.badRequest('Invalid Entry');
}
},
}
How ever throw strapi.errors.badRequest('Invalid Entry'); is giving an error :
Cannot read property 'badRequest' of undefined
My guess is the Strapi v4 changed it from version 3. I looked everywhere but couldn't find a solution.
Any idea on how to handle error in lifecycles.js?
I had a similar situation with a forbidden error. I got to do it importing a class from #strapi/utils/lib/errors.js
const { ForbiddenError } = require("#strapi/utils").errors;
...
if (!authorized) {
throw new ForbiddenError(errorMessage);
}
You can show the list of errors based on your requirement
const { ValidationError } = require("#strapi/utils").errors;
...
if (formValidationError) {
throw new ForbiddenError("Fill the form");
}
Strapi comes with a lot of error response functions here are they
HttpError,
ApplicationError,
ValidationError,
YupValidationError,
PaginationError,
NotFoundError,
ForbiddenError,
PayloadTooLargeError,
UnauthorizedError,
PolicyError,

Near Protocol: Error during Context.predecessor in view

I'm trying to get sender accountId in contract and getting error.
My contract:
#nearBindgen
export class Contract {
private message: string = 'Hello '
helloWorld(): string {
const predecessor = Context.predecessor
return this.message + predecessor
}
}
I'm trying to access contract from CLI with following command(with my account id):
near view $CONTRACT helloWorld --accountId <id>.testnet
Error:
Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(ProhibitedInView { method_name: "predecessor_account_id" })).
Oops. I should use
near call
instead of
near view

Putting put string text in javascript raise syntax error

In my Laravel 8 / blade/ jQuery 3.5.1 app I need to put string text in javascript like :
L.marker([{{$adLocation->lat}}, {{ $adLocation->lng }}]).addTo(locationMap)
.bindPopup("<b>Add Location!</b><br />"+'{!! crlf($adLocation->content) !!}'+".").openPopup();
I try to replace crlf characters with method like
function crlf(string $s) : string
{
return str_replace( array("\r\n", "\r", "\n"), "<br />", $s);
// 2 lines below does not work too
// return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $s);
// return nl2br($s);
}
But anyway I got error :
edit:539 Uncaught SyntaxError: Invalid or unexpected token
and I see in browser : https://prnt.sc/wtpnri and https://prnt.sc/wtq78t
Which way is valid ?
Thanks!

Message: Undefined property: CI_Loader::$uri

Here is my config/upload.php code:
if($this->uri->segment(2)=='addPlace'){
$config[upload_path] = './uploads/place_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}
elseif($this->uri->segment(2)=='addPack'){
$config[upload_path] = './uploads/package_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}
after run my project it shows:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$uri
Filename: config/upload.php
Line Number: 2
Backtrace:
File: D:\xampp\htdocs\project_tour_city\application\config\upload.php
Line: 2
Function: _error_handler
Use as its not getting instance of class
$this->CI->uri->segment('2')
I would sugest you autoload the URI resource
You can Change Like This
You have to get ci master class
$ci =& get_instance();
// after you use $ci instead of $this
if($ci->uri->segment(2)=='addPlace'){
$config[upload_path] = './uploads/place_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}
else if($ci->uri->segment(2)=='addPack'){
$config[upload_path] = './uploads/package_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}

Uncaught Error: Syntax error, unrecognized expression: option[]

When I try to add a selector and then pick an option, the script errors.
<form:select propertyContainer="${searchCriteria}" id="macroconditions" liveSearch="true" name="macroconditions" propertyPath="macroconditions" convertsToAccordion="true"/>
The log shows:
Uncaught Error: Syntax error, unrecognized expression: option[value=text of the selector]
SearchCriteria Script:
private EclMacroconditionCollection macroconditions;
public EclMacroconditionCollection getMacroconditions() {
if (macroconditions == null){
macroconditions = new EclMacroconditionCollection(EclMacrocondition.class);
Object period = getValueFromCookie(getPeriod());
macroconditions.getMacroconditions(period == null ? null : period.toString());
}
return macroconditions;
}
public void setMacroconditions(EclMacroconditionCollection macroconditions) {
this.macroconditions = macroconditions;
}
thanks

Resources