mercredi 30 novembre 2022

getting error on server(aws) SyntaxError: Unexpected token '<', "

I have deployed my laravel application on AWS server(ubuntu). Application works fine. But when I upload images using custom modal popup, then i got the syntax error from vendors.js.

Here is the error getting from modal popup while uploading images: Here is the error getting from modal popup while uploading images

Can anyone tell about that, how i can resolve that? I am just stuck from last two days.

I have tried run on server npm i body-parser And also re-add the file of vendors.js But same result.



via Chebli Mohamed

mardi 29 novembre 2022

Fatal error: Uncaught ReflectionException: Class IlluminateContractsHttpKernel does not exist

Fatal error: Uncaught ReflectionException: Class IlluminateContractsHttpKernel does not exist in C:\xampp\htdocs\erc_new\vendor\laravel\framework\src\Illuminate\Container\Container.php:788 Stack trace: #0 C:\xampp\htdocs\erc_new\vendor\laravel\framework\src\Illuminate\Container\Container.php(788): ReflectionClass->__construct('IlluminateContr...') #1 C:\xampp\htdocs\erc_new\vendor\laravel\framework\src\Illuminate\Container\Container.php(667): Illuminate\Container\Container->build('IlluminateContr...') #2 C:\xampp\htdocs\erc_new\vendor\laravel\framework\src\Illuminate\Container\Container.php(615): Illuminate\Container\Container->resolve('IlluminateContr...', Array) #3 C:\xampp\htdocs\erc_new\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(767): Illuminate\Container\Container->make('IlluminateContr...', Array) #4 C:\xampp\htdocs\erc_new\public\index.php(52): Illuminate\Foundation\Application->make('IlluminateContr...') #5 C:\xampp\htdocs\erc_new\server.php(21): require_once('C:\xampp\htdocs...') #6 {mai in C:\xampp\htdocs\erc_new\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 788

auto it is showin the Kernel error. thought i have not made any changes. i have already tried checking the Kernel.php files. more over i have already deleated the vendor and composer.lock file and install the composer . But also getting the the above error.

Moreover I also have deleted the every things that recedes on bootstrap/cache/



via Chebli Mohamed

lundi 28 novembre 2022

Laravel 8 - search paginate ( withQueryString ) not working on table when searching NUMBERS on row integer

i can't search when it comes to searching NUMBERS on row int (price), but when searching like String number on row string (name) it's working fine

like this in my table row here is my Product table

category_id
"56"
user_id
"1"
name
"555"
description
"fruit"
price
555

when i am searching the name row "555" it's working fine beacuse its a string. but when it comes to price i can't search it because it's int

here is my code for controller searching

public function index(Request $request){
    $user = Auth::user()->id;
    if($request->search){
        $search = $request->search;
        $products = Products::with('category')
        ->where('name','like',"%$search%")
        ->orWhere('price','like',"%$search%")
        ->where('user_id',$user)->paginate(10);
    }else{
        $products = Products::with('category')->where('user_id',$user)->paginate(10);
    }
      return view('client.product.index',['products'=>$products]);
}

here is my blade

    <form class="w-full" action="">
        <i class="fa fa-search"></i>
        <input placeholder="Search"  type="search" name="search">     
        <button type="submit">Search</button>
    </form>

@foreach ($products as $product)
    <p></p>
    <p></p>
@endforeach



via Chebli Mohamed

How to sort parent data based on child column detial in laravel 5.4?

I have 3 way relationship firstl i have get code like this in a controller

Trial::with('subjects')->where('source_id', $sourceId)->get()->toArray()

Now I want to sort subject.reactions on desc order of subject.reactions.accounts.nb_followers column. I tried to use orderby on relationship but it does not work because it sorting account indsted on reactions. I want to sort reaction based on value of "nb_followes" column present inside account table.

Trail Model

class Trial extends Model
{
    use HasFactory;
    public $table = 'trials';

    public function subjects()
    {
        return $this->hasMany(Subject::class, 'trial_id')->with(['reactions', 'news'])->withCount('reactions');
    }
  } 

Subject Model

class Subject extends Model
{
    use HasFactory;
    public $table = 'subjects';

    public function reactions()
    {
        return $this->hasMany(Reaction::class, 'subject_id', 'id')->with(['accounts' => function ($q) {$q->orderBy('nb_followers', 'DESC');}])->where('twitter_error', 0)->where('active', 1)->orderby('key_reaction', 'DESC');
    }

    public function news()
    {
        return $this->hasone(News::class, 'id', 'news_item_id');
    }

Reaction Model

class Reaction extends Model
{
    use HasFactory;

    public $table = 'reactions';

    public function accounts()
    {
        return $this->belongsTo(Account::class, 'account_id', 'id')->where('name', '!=', '');
    }

Thank you in Advance.



I want to sort reactions based on account table's column yes i cant use simple eloquent query because it will not create a structure that i want so that's why i created these relationships.


via Chebli Mohamed

samedi 26 novembre 2022

laravel Target class [App\Http\Controllers\EmployeeController] does not exist

enter image description here enter image description here

enter image description here

Target class [App\Http\Controllers\EmployeeController] does not exist.

 protected $namespace ='App\\Http\\Controllers';
public function boot()
{
    $this->configureRateLimiting();

    $this->routes(function () {
        Route::middleware('api')
            ->prefix('api')
            ->namespace($this->namespace)
            ->namespace('App\Http\Controllers') 
            ->group(base_path('routes/api.php'));

        Route::middleware('web')
        ->namespace($this->namespace)
        ->namespace('App\Http\Controllers')
        ->group(base_path('routes/web.php'));
    });

}

using but not solving the problem



via Chebli Mohamed

vendredi 25 novembre 2022

Access numeric key in array php [duplicate]

I have a array with a key like "11_check". How to acess this using php/laravel?

            $check=$list[$i]->{11_check};

I'm trying to acess with {} but I'm getting the error

Parse error: syntax error, unexpected '_check' (T_STRING)

Solution:

            $check=$list[$i]->{'11_check'};


via Chebli Mohamed

jeudi 24 novembre 2022

How can I pass params at access point of GraphQL such as {url}/graphql?development=true by using lighthouse in laravel

How can I pass params at access point of GraphQL such as {url}/graphql?development=true by using lighthouse in laravel. if development is true i want to use different database in laravel.

http://127.0.0.1:8000/graphql?development=true

its working but graphql does not getting development params



via Chebli Mohamed