mercredi 26 août 2020

Laravel error when using composer to setup

I am a php beginner. I got some problem when using composer to initially extend the project. Your kindness would be highly appreciate.

Hereby is the trace infomation and composer.jason.

Stack trace: #0 C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(809): ReflectionClass->__construct() #1 C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(691): Illuminate\Container\Container->build() #2 C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(796): Illuminate\Container\Container->resolve() #3 C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(269): Illuminate\Foundation\Application->resolve() #4 C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(805): Illuminate\Container\Container->Illuminate\Container{closure}() #5 C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(691): Illuminate\Container\Container- in C:\Users\jim\git\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 811 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255


{ "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.2.5", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^6.3", "laravel/framework": "^7.24", "laravel/tinker": "^2.0" }, "require-dev": { "facade/ignition": "^2.0", "fzaninotto/faker": "^1.9.1", "mockery/mockery": "^1.3.1", "nunomaduro/collision": "^4.1", "phpunit/phpunit": "^8.5" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "extra": { "laravel": { "dont-discover": [] } }, "autoload": { "psr-4": { "App\\": "app/" }, "classmap": [ "database/seeds", "database/factories" ] }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] } }


I try to track the exception and found error indicator in app.php



via Chebli Mohamed

issue laravel version 6.0 not able to call compact function

writing this code for routing

Route::get('/welcome', 'WelcomeController@welcome');

after that i have called to a new controller

<?php
    namespace  App\Http\Controllers;
    
    class WelcomeController extends Controller{
        
        public function welcome () {
            $data = ['name'=>'Test'];
            return view('welcome', compact(data));
        }
    }

after that i am calling this $data variable in welcome.blade.php

using this method $data['name'];

server not sending any responce



via Chebli Mohamed

Query fails when trying to get candidates from API with two words value separated by space

Both queries are not returning candidates with status:Returned Candidate. First query never fails but not returning candidates with status: Returned Candidate. Second query fails with error "Trying to get property of non-object". Please can you advise how this query should be built and how correctly request a status with two words value separated by space.

    $query = '&query=isDeleted:0 AND (status:Registered OR status:Returned Candidate OR status:Offer OR status:Placed OR status:Unavailable)';
    $query = '&query=isDeleted:0 AND (status:"Returned Candidate" OR status:"Offer" OR status:"Placed" OR status:"Unavailable")';



    $query = str_replace(" ", "%20", $query);
    $fields = 'id';
    $method='search/Candidate?BhRestToken='.Session::get('BH.restToken').$query.'&fields='.$fields.'&count='.$count.'&start='.$start.'&sort=-customDate1';

    $response = $bh->makeHttpRequest(Session::get('BH.restURL'), $method);


    if(isset($response->errorMessage)){

        if(BH_DEV === true) echo "<pre>".print_r($response,2)."</pre>";

        $response = array();
    }

    return $response;


via Chebli Mohamed

Heroku, Laravel - Increase Upload Size

It looks like I cannot upload more than 2mb file with heroku.

I can upload 3mb file on my local but I can't upload the same file after pushing to heroku. (Using storage S3)

I updated the htaccess file and I have added

ini_set('upload_max_filesize', '64M');

to my controller but it doesn't work.

Is there a way we can change the php.ini setting on heroku?



via Chebli Mohamed

Laravel Socialite + Ionic / Angular ( Sign up with Facebook or Google)

My website already has login with Fb or Google function and it's working fine, now I want to connect it to my ionic app. I wrote the code, and in Ionic it's connecting to Fb API successfully but not posting a request to my server (Laravel), there's no change in the DB. Can anyone figure out what is the issue? Here's my code:

Laravel - Api Social Controller:

     public function mobileProviderLogin($provider)
    {
        try{
            $userinfo = Socialite::driver($provider)->user();
        }catch (\Exception $e){
           return response()->json(array("status" => false,  "message" => "Login failed!"));        }

        Log::debug($userinfo->getId());
        $socialProvider = SocialProvider::where('provider_id',$userinfo->getId())->first();
        if(!$socialProvider){

           
                Log::debug('CONTINUE 1.1');
                $user = User::firstOrCreate(
                    ['name'=>$userinfo->getName(), 'display_name' => $userinfo->getName()] //Create With including email
                );
                
                Log::debug('CONTINUE 1.2');
                $user->socialProvider()->create([
                    'provider_id' =>$userinfo->getId(),
                    'provider' => $provider
                ]);
           
        }
        else
        {
            Log::debug('CONTINUE 2.1');
            $user=$socialProvider->user;
            Log::debug('CONTINUE 2.2');
        }
        
        if ($user != null)
        {
            Log::debug('CONTINUE 3.1');
            auth()->login($user);
        }
   
return response()->json(array("status" => true,  "message" => "Login success!"));  } 

Ionic - service.ts:

  mobileProviderLogin(res: any) {

    return this.http.post(this.env.API_URL + 'auth/mobileProviderLogin', {res:res}
    )
  }

Ionic - Login.ts:

fbLogin() 
 {
  this.fb.login(['public_profile', 'email'])
    .then(res => {
      if (res.status === 'connected') {
        this.isLoggedIn = true;
        this.getUserDetail(res.authResponse.userID);
        this.authService.mobileProviderLogin(res);
        this.route.navigate(['/home']); 
      } else {
        this.isLoggedIn = false;
      }
    }),  (error: any) => {
      console.log(error);
         }
}


via Chebli Mohamed

Is there a way to take the number between two dates and subtract with it in Laravel

So I've been trying to find a way to get/take the number in between two dates in fields "from" and "to"(leave table) then take that number(ex. it's 7) and subtract it with another number from the user table a from a field called leaveBalance it has a default number of 20 so I want that ( 20 -7) and the result to be saved in that specific user who requested the leave, in that leaveBalance field after that is changed, also would it be possible to add an if statement to check if the number between dates is bigger than the number allowed that we have on the leaveBalance to just return an error message

This is the leave table

  1. id
  2. user_id
  3. from
  4. to
  5. type
  6. description
  7. status
  8. message

The user table has the leaveBalance field and the two tables don't have a foreign key relation the user_id on the leave only stores the id of that authenticated user when a leave is created and then it only displays the leaves of that id created on the user's view

This is the Leave Controller

public function create()
     {
        $leaves = Leave::latest()->where('user_id',auth()->user()->id)->paginate(5);
        return view('leave.create',compact('leaves'));
    }
public function store(Request $request)
    {
        $this->validate($request,[
            'from'=>'required',
            'to'=>'required',
            'description'=>'required', 
            'type'=>'required'
            ]);
            $data=$request->all();
            $data['user_id']=auth()->user()->id;
            $data['message']='';
            $data['status']=0;
            $leave =Leave::create($data);
            
            $admins = Admin::all();
            $users = User::where('role_id', 2)->get();

            foreach ($admins as $admins) {
                foreach($users as $users){
                $admins->notify(new LeaveSent($leave));
                $users->notify((new LeaveSent($leave)));
            }
        }
        return redirect()->back()->with('message','Leave Created');

    }

This is the Leave Model:

{
    use Notifiable;

    protected $guarded=[];
    
    public function user(){
        return $this->belongsTo(User::class,'user_id','id');   
     }
}

This is the view of the Leave

<div class="card-body">
                    <form method="POST" action="">
                        @csrf

                        <div class="form-group">
                            <label>From Date</label>
                            <div class="col-md-6">
                                <input class="datepicker" type="text" class="form-control @error('from') is-invalid @enderror" name="from" required="">

                                @error('from')
                                    <span class="invalid-feedback" role="alert">
                                        <strong></strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group">
                            <label>To Date</label>
                            <div class="col-md-6">
                                <input class="datepicker1" type="text" class="form-control @error('to') is-invalid @enderror" name="to" required="">

I'm open to using carbon in this I don't really know much on carbon but I am aware that it's used for dates and such but since I use date picker is that possible?



via Chebli Mohamed

Unable to encrypt uploaded file on S3 using FileVault in Laravel 5.8?

I am using Laravel 5.8.

I am uploading a file on s3 which is successfully uploaded. But I am unable to encrypt using FileVault api.

enter image description here

Below are my configurations:

'kyc-documents' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'root' => 'app/kyc',
        ],

My controller code

$file_url = Storage::disk('kyc-documents')->putFileAs('/'.Auth::user()->id,$file,$filename);

            Log::info($file_url); // here it logs as 4/hitbtc_api_key.png


            FileVault::disk('kyc-documents')->encrypt($file_url); // Here it gives error as mentioned below

The error I am getting is as follows

fopen(app/kyc/4/hitbtc_api_key.png.enc): failed to open stream: No such file or directory {"userId":4,"exception":"[object] (ErrorException(code: 0): fopen(app/kyc/4/hitbtc_api_key.png.enc): failed to open stream: No such file or directory at /var/www/html/buy_sell/vendor/soarecostin/file-vault/src/FileEncrypter.php:170)

PS: While I am using local disk it is uploaded with .enc file extension which is correct way it should be. Only issue using s3 configurations in my fileSystem disk.

Please do help



via Chebli Mohamed

SSL Certificate has expired error in Laravel API with Guzzle and can't generate new license using lets encrypt

I have an laravel project configure with docker setup. I notice that my SSL is expired, but I cannot renew my SSL so that I want to have a free SSL license using letsencrypt but I have some issues regarding on my domain name.

enter image description here

When I tried using Lets encrypt I encountered this error: enter image description here

Guide followed: linode.

I don't know why letsencrypt is not accepting my domain name?

Thanks!



via Chebli Mohamed

mardi 25 août 2020

Upload Bulk Images Alphabetically

I am trying to upload bulk images alphabetically but finding it difficult. please help with same and i have tried many times didn;t got any success. Given below is the code to upload images as well as code to upload bulk images is included itself in between after //bulk upload section. Please help. Whenever i upload images it uploads like :

1.A 2.C 3.B

I like to upload the images alphabetically.

1.A 2.B 3.C

<?php

namespace App\Http\Controllers\Traits;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Models\AdminSettings;
use App\Models\User;
use App\Models\Stock;
use App\Models\Images;
use App\Helper;
use League\ColorExtractor\Color;
use League\ColorExtractor\ColorExtractor;
use League\ColorExtractor\Palette;
use Illuminate\Support\Facades\Validator;
use Image;

trait Upload {

  public function __construct(AdminSettings $settings, Request $request) {
   $this->settings = $settings::first();
   $this->request = $request;
 }

 protected function validator(array $data, $type)
 {
    Validator::extend('ascii_only', function($attribute, $value, $parameters){
      return !preg_match('/[^x00-x7F\-]/i', $value);
  });

  $sizeAllowed = $this->settings->file_size_allowed * 1024;

  $dimensions = explode('x',$this->settings->min_width_height_image);

  if ($this->settings->currency_position == 'right') {
    $currencyPosition =  2;
  } else {
    $currencyPosition =  null;
  }

  if ($type == 'bulk') {
    $max_lenght_title = 255;
  } else {
    $max_lenght_title = $this->settings->title_length;
  }

  $messages = array (
  'photo.required' => trans('misc.please_select_image'),
  "photo.max"   => trans('misc.max_size').' '.Helper::formatBytes( $sizeAllowed, 1 ),
  "price.required_if" => trans('misc.price_required'),
  'price.min' => trans('misc.price_minimum_sale'.$currencyPosition, ['symbol' => $this->settings->currency_symbol, 'code' => $this->settings->currency_code]),
  'price.max' => trans('misc.price_maximum_sale'.$currencyPosition, ['symbol' => $this->settings->currency_symbol, 'code' => $this->settings->currency_code]),

);

  // Create Rules
  return Validator::make($data, [
   'photo'       => 'required|mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width='.$dimensions[0].',min_height='.$dimensions[1].'|max:'.$this->settings->file_size_allowed.'',
      'title'       => 'required|min:3|max:'.$max_lenght_title.'',
      'description' => 'min:2|max:'.$this->settings->description_length.'',
      'tags'        => 'required',
      'price' => 'required_if:item_for_sale,==,sale|integer|min:'.$this->settings->min_sale_amount.'|max:'.$this->settings->max_sale_amount.'',
      'file' => 'max:'.$this->settings->file_size_allowed_vector.'',
    ], $messages);
  }

// Store Image
 public function upload($type)
 {

   if ($this->settings->who_can_upload == 'admin' && Auth::user()->role != 'admin') {
     return response()->json([
         'success' => false,
         'errors' => ['error' => trans('misc.error_upload')],
     ]);
   }

   //======= EXIF DATA
   $exif_data  = @exif_read_data($this->request->file('photo'), 0, true);
   if (isset($exif_data['COMPUTED']['ApertureFNumber'])) : $ApertureFNumber = $exif_data['COMPUTED']['ApertureFNumber']; else: $ApertureFNumber = ''; endif;

   if (isset($exif_data['EXIF']['ISOSpeedRatings'][0]))
     : $ISO = 'ISO '.$exif_data['EXIF']['ISOSpeedRatings'][0];
     elseif(!isset($exif_data['EXIF']['ISOSpeedRatings'][0]) && isset($exif_data['EXIF']['ISOSpeedRatings']))
     : $ISO = 'ISO '.$exif_data['EXIF']['ISOSpeedRatings'];
   else: $ISO = '';
 endif;

   if (isset($exif_data['EXIF']['ExposureTime'])) : $ExposureTime = $exif_data['EXIF']['ExposureTime']; else: $ExposureTime = ''; endif;
   if (isset($exif_data['EXIF']['FocalLength'])) : $FocalLength = $exif_data['EXIF']['FocalLength']; else: $FocalLength = ''; endif;
   if (isset($exif_data['IFD0']['Model'])) : $camera = $exif_data['IFD0']['Model']; else: $camera = ''; endif;
   $exif = $FocalLength.' '.$ApertureFNumber.' '.$ExposureTime. ' '.$ISO;
   //dd($exif_data);

   $pathFiles      = config('path.files');
   $pathLarge      = config('path.large');
   $pathPreview    = config('path.preview');
   $pathMedium     = config('path.medium');
   $pathSmall      = config('path.small');
   $pathThumbnail  = config('path.thumbnail');
   $watermarkSource = url('public/img', $this->settings->watermark);

   $input = $this->request->all();

   if (! $this->request->price) {
     $price = 0;
   } else {
     $price = $input['price'];
   }

   // Bulk Upload
   if ($type == 'bulk') {

     $_type = true;
     $replace = ['+','-','_','.','*'];
     $input['title']  = str_replace($replace, ' ', Helper::fileNameOriginal($this->request->file('photo')->getClientOriginalName()));

     $tags = explode(' ', $input['title']);

     if ($this->request->tags == '') {
               $input['tags'] = $tags[0];
         }

     // Set price min
     if ($this->request->item_for_sale == 'sale'
          && $this->request->price == ''
          || $this->request->item_for_sale == 'sale'
          && $this->request->price < $this->settings->min_sale_amount
        ) {
               $price = $this->settings->min_sale_amount;
         $input['price'] = $this->settings->min_sale_amount;
         } else if($this->request->item_for_sale == 'sale'
      && $this->request->price == ''
      || $this->request->item_for_sale == 'sale'
      && $this->request->price > $this->settings->max_sale_amount) {
       $price = $this->settings->max_sale_amount;
       $input['price'] = $this->settings->max_sale_amount;
     }

     // Description
     if (! empty($this->request->description)) {
        $description = Helper::checkTextDb($this->request->description);
      } else {
        $description = '';
      }
                         
   }

   $input['tags'] = Helper::cleanStr($input['tags']);
   $tags = $input['tags'];

   if (strlen($tags) == 1) {
     return response()->json([
         'success' => false,
         'errors' => ['error' => trans('validation.required', ['attribute' => trans('misc.tags')])],
     ]);
   }

   $validator = $this->validator($input, $type);

   if ($validator->fails()) {
     return response()->json([
         'success' => false,
         'errors' => $validator->getMessageBag()->toArray(),
     ]);
 } //<-- Validator

    $vectorFile = '';

    // File Vector
    if ($this->request->hasFile('file')) {

      $file           = $this->request->file('file');
      $extensionVector = strtolower($file->getClientOriginalExtension());
      $fileVector      = strtolower(Auth::user()->id.time().str_random(40).'.'.$extensionVector);
      $sizeFileVector  = Helper::formatBytes($file->getSize(), 1);

    $valid_formats = ['ai', 'psd', 'eps', 'svg'];

    if (! in_array($extensionVector, $valid_formats)) {
        return response()->json([
            'success' => false,
            'errors' => ['error_file' => trans('misc.file_validation', ['values' => 'AI, EPS, PSD, SVG'])],
        ]);
    }

    if ($extensionVector == 'ai') {
      $mime = ['application/illustrator', 'application/postscript', 'application/vnd.adobe.illustrator', 'application/pdf'];

    } elseif ($extensionVector == 'eps') {
      $mime = ['application/postscript', 'image/x-eps', 'application/pdf', 'application/octet-stream'];

    } elseif ($extensionVector == 'psd') {
      $mime = ['application/photoshop', 'application/x-photoshop', 'image/photoshop', 'image/psd', 'image/vnd.adobe.photoshop', 'image/x-photoshop', 'image/x-psd'];

    } elseif ($extensionVector == 'svg') {
      $mime = ['image/svg+xml'];
    }

    if (! in_array($file->getMimeType(), $mime)) {
        return response()->json([
            'success' => false,
            'errors' => ['error_file' => trans('misc.file_validation', ['values' => 'AI, EPS, PSD, SVG'])],
        ]);
    }

    $vectorFile = 'yes';

  }

   $photo          = $this->request->file('photo');
   $fileSizeLarge  = Helper::formatBytes($photo->getSize(), 1);
   $extension      = $photo->getClientOriginalExtension();
   $originalName   = Helper::fileNameOriginal($photo->getClientOriginalName());
   $widthHeight    = getimagesize($photo);
   $large          = strtolower(Auth::user()->id.time().str_random(100).'.'.$extension );
   $medium         = strtolower(Auth::user()->id.time().str_random(100).'.'.$extension );
   $small          = strtolower(Auth::user()->id.time().str_random(100).'.'.$extension );
   $preview        = strtolower(str_slug($input['title'], '-').'-'.Auth::user()->id.time().str_random(10).'.'.$extension );
   $thumbnail      = strtolower(str_slug($input['title'], '-').'-'.Auth::user()->id.time().str_random(10).'.'.$extension );

   $watermark   = Image::make($watermarkSource);
   $x = 0;
   ini_set('memory_limit', '512M');

        $width    = $widthHeight[0];
        $height   = $widthHeight[1];

       if ($width > $height) {

         if ($width > 1280) : $_scale = 1280; else: $_scale = 900; endif;
             $previewWidth = 850 / $width;
             $mediumWidth = $_scale / $width;
             $smallWidth = 640 / $width;
             $thumbnailWidth = 280 / $width;
       } else {

         if ($width > 1280) : $_scale = 960; else: $_scale = 800; endif;
             $previewWidth = 480 / $width;
             $mediumWidth = $_scale / $width;
             $smallWidth = 480 / $width;
             $thumbnailWidth = 190 / $width;
       }

         //======== PREVIEW
         $scale    = $previewWidth;
         $widthPreview = ceil($width * $scale);

         $imgPreview  = Image::make($photo)->resize($widthPreview, null, function ($constraint) {
           $constraint->aspectRatio();
           $constraint->upsize();
         })->encode($extension);

         //======== Medium
         $scaleM  = $mediumWidth;
         $widthMedium = ceil($width * $scaleM);

         $imgMedium  = Image::make($photo)->resize($widthMedium, null, function ($constraint) {
           $constraint->aspectRatio();
           $constraint->upsize();
         })->encode($extension);

         //======== Small
         $scaleSmall  = $smallWidth;
         $widthSmall = ceil($width * $scaleSmall);

         $imgSmall  = Image::make($photo)->resize($widthSmall, null, function ($constraint) {
           $constraint->aspectRatio();
           $constraint->upsize();
         })->encode($extension);

         //======== Thumbnail
         $scaleThumbnail  = $thumbnailWidth;
         $widthThumbnail = ceil($width * $scaleThumbnail);

         $imgThumbnail  = Image::make($photo)->resize($widthThumbnail, null, function ($constraint) {
           $constraint->aspectRatio();
           $constraint->upsize();
         })->encode($extension);


   //======== Large Image
   $photo->storePubliclyAs($pathLarge, $large);

   //========  Preview Image
   Storage::put($pathPreview.$preview, $imgPreview, 'public');
   $url = Storage::url($pathPreview.$preview);

   //======== Medium Image
   Storage::put($pathMedium.$medium, $imgMedium, 'public');
   $urlMedium = Storage::url($pathMedium.$medium);

   //======== Small Image
   Storage::put($pathSmall.$small, $imgSmall, 'public');
   $urlSmall = Storage::url($pathSmall.$small);

   //======== Thumbnail Image
   Storage::put($pathThumbnail.$thumbnail, $imgThumbnail, 'public');

   //=========== Colors
   $palette   = Palette::fromFilename($urlSmall);
   $extractor = new ColorExtractor($palette);

   // it defines an extract method which return the most “representative” colors
   $colors = $extractor->extract(5);

   // $palette is an iterator on colors sorted by pixel count
   foreach ($colors as $color) {

     $_color[] = trim(Color::fromIntToHex($color), '#') ;
   }

   $colors_image = implode( ',', $_color);

   if (! empty($this->request->description)) {
        $description = Helper::checkTextDb($this->request->description);
      } else {
        $description = '';
      }

   if ($this->settings->auto_approve_images == 'on') {
     $status = 'active';
   } else {
     $status = 'pending';
   }

   $token_id = str_random(200);

   $sql = new Images;
   $sql->thumbnail            = $thumbnail;
   $sql->preview              = $preview;
   $sql->title                = trim($input['title']);
   $sql->description          = trim($description);
   $sql->categories_id        = $this->request->categories_id;
   $sql->user_id              = Auth::user()->id;
   $sql->status               = $status;
   $sql->token_id             = $token_id;
   $sql->tags                 = mb_strtolower($tags);
   $sql->extension            = strtolower($extension);
   $sql->colors               = $colors_image;
   $sql->exif                 = trim($exif);
   $sql->camera               = $camera;
   $sql->how_use_image        = $this->request->how_use_image;
   $sql->attribution_required = $this->request->attribution_required;
   $sql->original_name        = $originalName;
   $sql->price                = $price;
   $sql->item_for_sale        = $this->request->item_for_sale ? $this->request->item_for_sale : 'free';
   $sql->vector               = $vectorFile;
   $sql->save();

   // ID INSERT
   $imageID = $sql->id;

   // Save Vector DB
   if($this->request->hasFile('file')) {

       $file->storePubliclyAs($pathFiles, $fileVector);

       $stockVector             = new Stock;
       $stockVector->images_id  = $imageID;
       $stockVector->name       = $fileVector;
       $stockVector->type       = 'vector';
       $stockVector->extension  = $extensionVector;
       $stockVector->resolution = '';
       $stockVector->size       = $sizeFileVector;
       $stockVector->token      = $token_id;
       $stockVector->save();
   }

   // INSERT STOCK IMAGES
   $lResolution = list($w, $h) = $widthHeight;
   $lSize       = $fileSizeLarge;

   $mResolution = list($_w, $_h) = getimagesize($urlMedium);
   $mSize      = Helper::getFileSize($urlMedium);

   $smallResolution = list($__w, $__h) = getimagesize($urlSmall);
   $smallSize       = Helper::getFileSize($urlSmall);

 $stockImages = [
     ['name' => $large, 'type' => 'large', 'resolution' => $w.'x'.$h, 'size' => $lSize ],
     ['name' => $medium, 'type' => 'medium', 'resolution' => $_w.'x'.$_h, 'size' => $mSize ],
     ['name' => $small, 'type' => 'small', 'resolution' => $__w.'x'.$__h, 'size' => $smallSize ],
   ];

   foreach ($stockImages as $key) {
     $stock             = new Stock;
     $stock->images_id  = $imageID;
     $stock->name       = $key['name'];
     $stock->type       = $key['type'];
     $stock->extension  = $extension;
     $stock->resolution = $key['resolution'];
     $stock->size       = $key['size'];
     $stock->token      = $token_id;
     $stock->save();

   }

   if ($type == 'normal') {
     return response()->json([
                    'success' => true,
                    'target' => url('photo', $imageID),
                ]);
   } else {
     return 'success';
   }
  }
}


via Chebli Mohamed

Laravel nova File Field | How can i get resource id before storing file

I want to store a file with resource id + extension i.e 1.csv,2.csv,3.txt,4.jpeg.

I am using laravel nova File Field to upload file in s3 is there any way I can get the id of that row before storing in db?

below is the code I am using to uploading files.

File::make('path')
    ->disk(config('filesystems.default'))
    ->rules('required','mimes:csv,txt')
    ->storeAs(function (Request $request) {
        return $request->path->getClientExtension();
    })
   ->path('csv'),


via Chebli Mohamed

email notification in laravel 5.5 i get this error ```Trying to access array offset on value of type null```

i want to get email notification each time a new user is registered but after creating php artisan make:notification Taskcompleted and added Notification::route('mail','admin@gmail.com')->notify(new TaskCompleted()); like this in my contoller

public function store(Request $request){
        $employee = request()->validate([
            'employee_id' => 'required|max:250',
            'name' => 'required|max:100',
            'place_of_birth' => 'nullable|max:100',]);
Notification::route('mail','admin@gmail.com')->notify(new TaskCompleted());

i keep getting this error Trying to access array offset on value of type null i have imported the necessary class and configured my .env file with mailtrap,still yet same error



via Chebli Mohamed

Laravel Clousure

I keep getting this Opis\Closure\ClosureStream::stream_set_option is not implemented! when I'm running a closure using the dispatch helper.

        dispatch(function () use ($done) {
            foreach ($done as $order) {
              try{
                Log::info("Some code");
              }catch(\Exception $e){
                continue;
              }
            }
        });

It's been years since I've worked with PHP and I'm really stuck on this part.

I'm using vagrant with laravel 5.8 and my PHP 7.4.

Thanks in advance guys.



via Chebli Mohamed

Laravel - Many To Many return child records filtered

I have a User model which has a M:M relationship with Role model (I use roles_user intermediate table for M:M relationship)

The intermediate table has a column "Active" which defines which of the multiple roles assigned to a User is the active one.

So, I'm trying to retrieve a User with all the relationships it has an also only the active role.

For that, Im executing the follwing code https://laravel.com/docs/6.x/eloquent-relationships#querying-relationship-existence :

public function index()
    {    
        $users = User::whereHas('roles', function (Builder $query) {
            $query->where('active', true); 
        })->get();            
        foreach ($users as $user) {
            dd($user->roles);
        }
        
        return view('pages.admin.users.index', compact('users'));
    }

When I dd the collection, I have the 5 records in intermnediate table and not just the active one wich I'm filtering:

enter image description here

enter image description here

What I am doing wrong?

Regards



via Chebli Mohamed

Issue implementing google autocomplete in vue.js

I'm trying to use google auto complete in vue.js with laravel but it is giving me error :

[Vue warn]: Error in mounted hook: "ReferenceError: google is not defined" 
found in
---> <VueGoogleAutocomplete> at /src/components/VueGoogleAutocomplete.vue
       <App> at /src/App.vue

         <Root>

here is the link to the code which i'm trying to implement:

https://codesandbox.io/s/nifty-bardeen-5eock



via Chebli Mohamed

laravel 5.8 bootstrap not working inside Jquery

i am using https://developer.snapappointments.com/bootstrap-select/examples/

its working fine in view but when i using this in Jquery below code its not working. help me to fix this.

view code php

      <table id="tableAppointment" style="background-color:powderblue;">
     
        <tr>
        <th style="text-align:center;" colspan="1">NAME</th>
        <th style="text-align:center;" colspan="1">HSN/SAC</th>
       
       
      <th><a href="#" class="addRow btn btn-warning vertical-center"><i class="glyphicon glyphicon- 
  plus">ADD</i></a></th>
      </tr>
       
       <tr>
        <td >
    
            <select class="selectpicker" data-live-search="true"  name="product_name[]">
           <option value=""></option>
          @foreach ($addnewitem as $key=>$addnewitems)
            <option  ></option> 
          @endforeach </select>
    
        </td>
    
     
        <td >
              <select class="selectpicker" data-live-search="true"  name="part_no[]">
           <option value=""></option>
          @foreach ($addnewitem as $key=>$addnewitems)
            <option  ></option> 
          @endforeach </select>
    
        </td>
    
         <td><a href="#" class="btn btn-danger "><i class="glyphicon glyphicon-remove">REMOVE</i></a> 
  </td>
      </tr>
    
    </table>
    
    <script type="text/javascript">
    
        $('.addRow').on('click',function(){
            addRow();
        });
        function addRow()
        {
        
            var tr='<tr>'+
    
    
            '<td ><select class="selectpicker" data-live-search="true"  name="product_name[]"><option 
 value=""></option> @foreach($addnewitem as $key=>$addnewitems)<option  ></option>@endforeach </select></td>'+
    
    
    
             
'<td ><select class="selectpicker" data-live-search="true"  name="part_no[]"><option value=""></option> 
  @foreach($addnewitem as $key=>$addnewitems)<option  ></option>@endforeach 
 </select></td>'+
    
    
           
            
 '<td><a href="#" class="btn btn-danger remove"><i class="glyphicon glyphicon-remove">REMOVE</i></a> 
 </td>'+
         
            '</tr>';
            $('tbody').append(tr);
        };
        $('.remove').live('click',function(){
            var last=$('tbody tr').length;
            if(last==1){
                alert("you can not remove last row");
            }
            else{
                 $(this).parent().parent().remove();
            }
        
        });
    
    </script>

enter image description here



via Chebli Mohamed

ReflectionException Error in Laravel 5.5 after deployment to live server

Due to unable to access Terminal in hosting server, I ran composer update in my local machine and uploaded everything including vendor folder, composer.json and composer.lock. My hosting server run PHP 7.1 and so does my local machine with Laravel 5.5.

Now I am facing PHP Fatal error: Uncaught ReflectionException: Class view does not exist in /public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php:752 Stack trace:

#0 /public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php(752): ReflectionClass->__construct('view')

#1 /public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('view')

#2 /public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php(586): Illuminate\Container\Container->resolve('view', Array)

#3 /public_html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(732): Illuminate\Container\Container->make('view', Array)

#4 /public_html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(110): Illuminate\Foundation\Application->make('view', Array)

#5 /public_html/vendor/laravel/framework/src/Illuminate/Found in /public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 752

I ran the following command.

composer require maatwebsite/excel --no-update
composer update maatwebsite/excel

And I uploaded the following files and folder from local to live server.

  1. Vendor / maatwebsite folder and all other newly created by folders.
  2. vendor / composer folder
  3. composer.json
  4. composer.lock

I cleared config cache, route cache, view cache from PHP file using artisan command.

Can anyone please help me to debug the error? Thank you.



via Chebli Mohamed

Image Upload: Error Creating default object from empty value

I'm having trouble with image upload/processing, I only follow a youtube tutorial code by code so I'm not quite sure whats the problem. The image itself doesn't change the name of the supposed file name yet it is moved into the specified image directory with the image original name.

Here is my Controller

public function add(Request $request) {
    $post = new Blog();

    $post->name = $request->input('title');
    $post->content = $request->input('content');
    $post->image = $request->input('image');

    if($request->hasfile('image')) {
        $file = $request->file('image');
        $extension = $file->getClientOriginalExtension();
        $filename = time().'.'. $extension;
        $file->move('uploads/blog/', $filename);
        $blog->image = $filename;
    }else{
        return $request;
        $blog->image = '';
    }

    $post->save();

    return view('admin.postnews')->with('post', $data);
}

}

and here is my Form

                    <form action="" method="POST" enctype="multipart/form-data">
                
                 ... 
                  <div class="form-group">
                    <label for="exampleFormControlFile1">Thumbnail</label>
                    <input type="file" name="image" class="form-control-file" id="exampleFormControlFile1">
                  </div>
                <button type="submit" class="btn btn-primary">Submit</button>
              </form>

I had google similar questions to no avail since everyone seems to have a different way of image processing or their problem is not with image.

For a record im currently using Laravel 5.8



via Chebli Mohamed

Application sometime stop working when using from company's wifi network

I am maintaining web application built using Angular and Laravel. Its sometimes stop working without any reason when using company's wifi, it works when using from somewhere else. Its deployed to AWS. Can somebody tell how to investigate the issue. I have checked the server, its fine, no extra load or any unusual.



via Chebli Mohamed

lundi 24 août 2020

Laravel middleware doesn't work on production server: Target class [App\Http\Middleware\IsRole] does not exist

I am working with a custom Laravel middleware to restrict routes based on authorized user roles. The middleware works seamlessly on my local machine, where I am using XAMPP.

But when I pushed this to a production server (the server is similar to AWS), I got the following error:

Target class [App\Http\Middleware\IsRole] does not exist.

I generated this middleware file using:

php artisan make:middleware isRole

This is the file itself:

<?php

namespace App\Http\Middleware;

use Closure;
use Auth;
use App\User;

class isRole
{
    public function handle($request, Closure $next, $role1, $role2 = '', $role3 = '', $role4 = '')
    {
        $rolesArray = [$role1, $role2, $role3, $role4];
        $user = Auth::user();

        l($user);

        if (in_array($user->role, $rolesArray)) {
            return $next($request);
        }
        return response(['message' => 'Unauthenticated', 'translation' => 'errors.unauthenticated'], 401);
    }
}

I have registered this route with an alias is in app\Http\Kernel.php

protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        'is' => \App\Http\Middleware\IsRole::class,
];

And this how I am using the middleware in my API routes:

Route::middleware('is:admin')->group(function () {
        // Super admin routes
        
    });
Route::middleware('is:admin,company_admin,driver')->group(function () {
        // Super admin, company admin and driver routes
        
    });

This is the full error with stacktrace:

[2020-08-25 06:50:34] local.ERROR: Target class [App\Http\Middleware\IsRole] does not exist. {"userId":1,"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [App\\Http\\Middleware\\IsRole] does not exist. at /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:811)
[stacktrace]
#0 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#1 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array, true)
#2 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve('App\\\\Http\\\\Middle...', Array)
#3 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#4 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(156): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#5 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#6 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#7 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#8 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1')
#9 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#10 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure), 'api')
#11 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#12 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#13 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#14 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#15 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#16 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#17 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#18 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#19 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /var/webprod/lpgsys.app/api/vendor/fruitcake/laravel-cors/src/HandleCors.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#28 /var/webprod/lpgsys.app/api/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#29 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#30 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#31 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#32 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#33 /var/webprod/lpgsys.app/api/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))      
#34 {main}

[previous exception] [object] (ReflectionException(code: -1): Class App\\Http\\Middleware\\IsRole does not exist at /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:809)
[stacktrace]
#0 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct('App\\\\Http\\\\Middle...')
#1 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#2 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array, true)
#3 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve('App\\\\Http\\\\Middle...', Array)
#4 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#5 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(156): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#6 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#7 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#8 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#9 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1')
#10 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#11 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure), 'api')
#12 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#13 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#14 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#15 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#16 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#17 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#18 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#19 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /var/webprod/lpgsys.app/api/vendor/fruitcake/laravel-cors/src/HandleCors.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /var/webprod/lpgsys.app/api/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#33 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#34 /var/webprod/lpgsys.app/api/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))      
#35 {main}
"}
[2020-08-25 06:50:34] local.ERROR: Target class [App\Http\Middleware\IsRole] does not exist. {"userId":1,"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [App\\Http\\Middleware\\IsRole] does not exist. at /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:811)
[stacktrace]
#0 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#1 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array, true)
#2 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve('App\\\\Http\\\\Middle...', Array)
#3 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#4 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(204): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#5 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(178): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\JsonResponse))
#6 /var/webprod/lpgsys.app/api/public/index.php(60): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\JsonResponse))
#7 {main}

[previous exception] [object] (ReflectionException(code: -1): Class App\\Http\\Middleware\\IsRole does not exist at /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:809)
[stacktrace]
#0 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct('App\\\\Http\\\\Middle...')
#1 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#2 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array, true)
#3 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve('App\\\\Http\\\\Middle...', Array)
#4 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#5 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(204): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#6 /var/webprod/lpgsys.app/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(178): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\JsonResponse))
#7 /var/webprod/lpgsys.app/api/public/index.php(60): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\JsonResponse))
#8 {main}
"}

The middleware works as intended on my local machine, but not on the server. Any help would be much appreciated, Thanks!



via Chebli Mohamed

Cannot include script for google autocomplete in vue.js using laravel

I'm using vue.js and implementing google autocomplete in the head section i'm trying to include this script app.blade.php :

<head>
 <script src="https://maps.googleapis.com/maps/api/js?key=&libraries=places" defer></script>
</head> 

but when i load my component this script is not found and i'm getting error

VM2823 app.js:62045 [Vue warn]: Error in mounted hook:
"ReferenceError: google is not defined"
     
    found in
     
    ---> <VueGoogleAutocomplete> at node_modules/vue-google-autocomplete/src/VueGoogleAutocomplete.vue
           <user> at resources/js/components/addUser.vue
             <Root>


via Chebli Mohamed

updating my sources code file on the serve it give me an error which need help to interpret laravel error 500 [closed]

after the update of the script it gives me the following error found in storage /log pls i need help to solve this

[2020-08-24 00:17:10] local.ERROR: Translation file [/home/multcqzm/topsuccess.ng/resources/lang/en.json] contains an invalid JSON structure. (View: /home/multcqzm/topsuccess.ng/resources/views/errors/500.blade.php) {"exception":"[object] (ErrorException(code: 0): Translation file [/home/multcqzm/topsuccess.ng/resources/lang/en.json] contains an invalid JSON structure. (View: /home/multcqzm/topsuccess.ng/resources/views/errors/500.blade.php) at /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php:145, RuntimeException(code: 0): Translation file [/home/multcqzm/topsuccess.ng/resources/lang/en.json] contains an invalid JSON structure. at /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php:145)
[stacktrace]
#0 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(45): Illuminate\\View\\Engines\\CompilerEngine->handleViewException(Object(RuntimeException), 1)
#1 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('/home/multcqzm/...', Array)
#2 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\\View\\Engines\\CompilerEngine->get('/home/multcqzm/...', Array)
#3 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/View/View.php(125): Illuminate\\View\\View->getContents()
#4 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/View/View.php(90): Illuminate\\View\\View->renderContents()
#5 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Http/Response.php(42): Illuminate\\View\\View->render()
#6 /home/multcqzm/topsuccess.ng/vendor/symfony/http-foundation/Response.php(205): Illuminate\\Http\\Response->setContent(Object(Illuminate\\View\\View))
#7 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/ResponseFactory.php(55): Symfony\\Component\\HttpFoundation\\Response->__construct(Object(Illuminate\\View\\View), 500, Array)
#8 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/ResponseFactory.php(81): Illuminate\\Routing\\ResponseFactory->make(Object(Illuminate\\View\\View), 500, Array)
#9 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(390): Illuminate\\Routing\\ResponseFactory->view('errors::500', Array, 500, Array)
#10 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(295): Illuminate\\Foundation\\Exceptions\\Handler->renderHttpException(Object(Symfony\\Component\\HttpKernel\\Exception\\HttpException))
#11 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(192): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse(Object(Illuminate\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\HttpException))
#12 /home/multcqzm/topsuccess.ng/app/Exceptions/Handler.php(49): Illuminate\\Foundation\\Exceptions\\Handler->render(Object(Illuminate\\Http\\Request), Object(ErrorException))
#13 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(83): App\\Exceptions\\Handler->render(Object(Illuminate\\Http\\Request), Object(ErrorException))
#14 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(55): Illuminate\\Routing\\Pipeline->handleException(Object(Illuminate\\Http\\Request), Object(ErrorException))
#15 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#16 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#19 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#22 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#29 /home/multcqzm/topsuccess.ng/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#30 /home/multcqzm/topsuccess.ng/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#31 {main}

that is the error log above



via Chebli Mohamed

Llaravel and blade , api and frontal in the same project

I have a project with Laravel and I have Passport installed , because i'm using it to manage authorization and authentication with the project's API.

I have a login method that returns token and then from the responsive wep app I send this token on each request. The example would be, I make the call to / login, I receive the token I store it and in the other calls for example / api / companies I send the token and if it is valid the api returns the correct answer. This works OK

What I can't get to work is within the same project to authenticate through a form that calls another method

I have the problem in that within the same project I want to authenticate through a form that calls another method and save the data in the laravel session.

Method I use from the progressive web apps

public function login()
{
    if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
        $user = Auth::user();
        $success['token'] =  $user->createToken('MyApp')-> accessToken;

        return response()->json(['success' => $success,'email' => request('email')], $this-> successStatus);
    }
    else{
        return response()->json(['error'=>'Unauthorised'], 401);
    }
}

This is the other method that I want to use from the same laravel application, using sessions. The idea is, when a user is correctly logged in, they will save their email session.

 /**
 * @param Request $request
 * @return \Illuminate\Http\JsonResponse
 */
public function loginweb(Request $request)
{

    $request->session()->put('login_email', $request->get('email'));

    $user = User::where('email',$request->get('email'))
        ->where('password',$request->get('password'))
        ->first();


    if (null !== $user) {

        $request->session()->put('login_email', $request->get('email'));
        $request->session()->put('user_id', $user->id);

        return response()->json($user,201);
    }

    return response()->json('Error',401);
}

The problem is that I use the loginweb function, and then I access another form and I have lost the session data.

For example, I access this route (in web.php)

Route::get('/forms/list', 'Front\FormController@list')->name('front.user.forms.list');

Content from this method

    public function list(Request $request)
{
    if ($request->get('email') !== null) {
        $request->session()->put('login_email', $request->get('email'));
        $request->session()->put('logged', true);
    }

     dd($request->session());

     return view ('front.user.forms.list');
}

This last "dd" dont show me session variables.



via Chebli Mohamed

Number format in French

I'm tring to change the number format of my result in my view but i have a problem.

It's shows me A non well formed numeric value encountered

My code below

<td style="font-size:60%">
<?php
$val = $indemnite->indemnite;

 // Notation française
$resultat = number_format($val, 2, ',', ' ');
// Résultat : 1 234,56
echo $resultat ;
?>
</td>


via Chebli Mohamed

[Vue warn]: Error in mounted hook: "ReferenceError: google is not defined"

I'm trying to implement google autocomplete and using this link:

https://www.npmjs.com/package/vue-google-autocomplete but i'm getting this error:

VM2823 app.js:62045 [Vue warn]: Error in mounted hook: "ReferenceError: google is not defined"

found in

---> <VueGoogleAutocomplete> at node_modules/vue-google-autocomplete/src/VueGoogleAutocomplete.vue
       <user> at resources/js/components/addUser.vue
         <Root>
 <template>
    <div>
        <h2>Your Address</h2>
 
        <vue-google-autocomplete
            ref="address"
            id="map"
            classname="form-control"
            placeholder="Please type your address"
            v-on:placechanged="getAddressData"
            country="sg"
        >
        </vue-google-autocomplete>
    </div>
</template>
 
<script>
    import VueGoogleAutocomplete from 'vue-google-autocomplete'
 
    export default {
        components: { VueGoogleAutocomplete },
 
        data: function () {
            return {
              address: ''
            }
        },
 
        mounted() {
       
            this.$refs.address.focus();
        },
 
        methods: {
         
            getAddressData: function (addressData, placeResultData, id) {
                this.address = addressData;
            }
        }
    }
</script> 

Please help to sort out my issue.



via Chebli Mohamed

CORS error: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request [duplicate]

please someone to help me,i'm facing this error

Access to fetch at 'http://url/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

while trying to access laravel api in reactjs app on shared hosting but local is working

reactjs code

fetch("http://schoolcbapi.schoolcountbook.rw/api/authuser/",{

        method:"POST",
        mode:"cors",
        headers:{
          "Content-Type":"Application/json",
          "Accept":"Application/json",
        },
        body:JSON.stringify({
          "email":this.state.email,
          "password":this.state.password
        })
      })

laravel middleware

public function handle($request, Closure $next)
{
    $response = $next($request);

    $response->header("Access-Control-Allow-Origin","*");
    $response->header("Access-Control-Allow-Credentials","true");
    $response->header("Access-Control-Max-Age","600");    // cache for 10 minutes

    $response->header("Access-Control-Allow-Methods","POST, GET, OPTIONS, DELETE, PUT"); //Make sure you remove those you do not want to support

    $response->header("Access-Control-Allow-Headers", "Content-Type, Accept, Authorization, X-Requested-With, Application");

    return $response;
}


via Chebli Mohamed

upply plugin to delete file from database in laravel

i try but only delete in preview section in database not remove so how can i remove from database also here is my code

$(document).on('click', id + ' .kt-uppy__list .kt-uppy__list-remove', function () {
                var itemId = $(this).attr('data-id');
                var path = $(this).attr('data-path');

                var index = filelist.indexOf(path);
                if (index > -1) {
                    filelist.splice(index, 1);
                }
                $('#filenamelist').val(filelist);
                console.log(filelist);
                //uppyMin.removeFile(itemId);
                $(id + ' .kt-uppy__list-item[data-id="' + itemId + '"').remove();

});


via Chebli Mohamed

How to speed up server while using pusher events laravel and redis

Here I have digital ocean server + Laravel 5.8 Project set up with + Mysql + Redis + Pusher Echo Events.

Backend : Laravel

Frontend : React

The server is facing big traffic everyday.

So Found the issue like pusher's socket is taking much memory and cpu usage which causes server low in performance and which impacts on website traffic as well.

So how can I speed or improve it ?

I have used frontend event.listeners() to auto refresh the changes. So sometimes it might call another API to get updated state.



via Chebli Mohamed

Variable undefined in Laravel [duplicate]

I am getting undefined variable error in Laravel for the code section: (this is index.blade.php file)

 @foreach($faqs as $faq) 

  <tr>
  <td></td>
  <td></td>
  <td></td>
  </tr>

though I send the variable in this file via Controller:

public function index(Request $request)
{

    $faqs = Faq::all();
    return view('admin.faq.index')->with('faqs', $faqs);
}

The Faq Model is :

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Faq extends Model
{
    //
}

the error message I am getting is enter image description here

How can I solve this? TIA.



via Chebli Mohamed

dimanche 23 août 2020

Validation Request Class not Found In Laravel

I am receiving error Class App\Http\Requests\PostStore Not Found

My Contoller Code

namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Http\Requests\PostStore;
class PostController extends Controller
{

 public function store(PostStore $request)
{
    //
    return redirect()->back();
}
}

and request code looks like

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class PostStore extends FormRequest
{
/**
 * Determine if the user is authorized to make this request.
 *
 * @return bool
 */
public function authorize()
{
    return true;
}

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        //
        'title' => 'min:20|max:200|required|string',
        'content' => 'min:20|max:400|required'
    ]
}
public function messages()
{
    return [
    'title.required' => ' :attribute is required',
    'content.required' => ' :attribute is required'
    ]
}
}

I have used

composer dump-autoload

PHP artisan cache:clear,

composer clear-cache,

But it dose not work for me Thank You For Your Help



via Chebli Mohamed

Cannot display image from storage directory using vue.js in laravel

I'm saving image in Storage folder path is like:

storage\app\public\img\images_01.png

now in my vue component i'm getting image like this:

this is returning following path :

 /storage/img/images_01.png

but the issue is image does not gets displayed.



via Chebli Mohamed

samedi 22 août 2020

JSON DECODE RETURNING EMPTY OBJECT FOR API CALL

I am building a project with angular 8 and laravel as the backend. I am sending a formData with a stringified object to my backend but when I decode the object and console to log, I get an empty object {}. What is wrong?

HERE IS MY FRONTEND FORMDATA

const imgKey: any = Object.values(this.images);
for (let i = 0; i <= this.bulkCount.number; i++) {
    for (let j = 0; j < imgKey[i].length; j++) {
        formData.append(`image[]`, imgKey[i][j], JSON.stringify([{product_position: i, name: imgKey[i][j].name}]))
    }
}

BACKEND

return response()->json(json_decode($fileNameToStoreWithExt, true));

$fileNameToStoreWithExt is the stringified object which when I get when I console.log.

What is wrongenter image description here



via Chebli Mohamed

Call to a member function isdeferred() on null

it gives me this problem on this "deferred" part. Can you help me? I'm new.

I wrote the whole code again. Can you help this time? Thank you.

       class ProviderRepository


protected function compileManifest($providers)
{

    $manifest = $this->freshManifest($providers);

    foreach ($providers as $provider) {
        $instance = $this->createProvider($provider);

   //The problem starts right on this line! (deferred)

 if ($instance->isdeferred()) {
            foreach ($instance->provides() as $service) {
                $manifest['deferred'][$service] = $provider;
            }

            $manifest['when'][$provider] = $instance->when();
        }

        
        else {
            $manifest['eager'][] = $provider;
        }
    }

    return $this->writeManifest($manifest);
}


via Chebli Mohamed

Too few arguments to function App\Http\Controllers\CartController::destroy(), 0 passed and exactly 1 expected

Am using darryldecode ShoppingCart library but I keep getting the above error when am trying to remove an item from my cart, I don't know what am missing. Here is my code below.

public function destroy($id)
{
    Cart::remove($id);
    return redirect()->back();
}

This is my route.

Route::delete('/cart', 'CartController@destroy')->name('cart.destroy');

And here is my view

<form action="" method="POST">
    @csrf
    
    <button type="submit" class="btn btn-link mr-2" style="color: gray">Remove</button>
</form>

What am I missing? Thanks for your concern!



via Chebli Mohamed

failed to push some refs to 'https://ift.tt/2YqvtjV'

C:\xampp\htdocs\starter> git push heroku master

To https://git.heroku.com/damp-lowlands-91408.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://ift.tt/2YqvtjV'



via Chebli Mohamed

vendredi 21 août 2020

Error while trying to run composer install

I am running into an issue while trying to install dependencies w/ composer. I have tried updating the orchestra version\ laravel version to try and meet each others needs. Can't seem to find a solution. Anyone else run into this problem?

After running composer install I get the error

Problem 1
    - orchestra/testbench v3.9.4 requires laravel/framework ^6.18.0 -> satisfiable by laravel/framework[6.x-dev, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9] but these conflict with your requirements or minimum-stability.
    - orchestra/testbench v3.9.3 requires laravel/framework ^6.18.0 -> satisfiable by laravel/framework[6.x-dev, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9] but these conflict with your requirements or minimum-stability.
    - orchestra/testbench v3.9.2 requires laravel/framework ^6.2 -> satisfiable by laravel/framework[6.x-dev, v6.10.0, v6.10.1, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.2.0, v6.3.0, v6.4.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0, v6.9.0] but these conflict with your requirements or minimum-stability.
    - orchestra/testbench v3.9.1 requires laravel/framework ^6.0 -> satisfiable by laravel/framework[6.x-dev, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.10.1, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.2.0, v6.3.0, v6.4.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0, v6.9.0] but these conflict with your requirements or minimum-stability.
    - orchestra/testbench v3.9.0 requires laravel/framework ^6.0 -> satisfiable by laravel/framework[6.x-dev, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.10.1, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.2.0, v6.3.0, v6.4.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0, v6.9.0] but these conflict with your requirements or minimum-stability.
    - Conclusion: don't install laravel/framework v5.8.38
    - Conclusion: don't install laravel/framework v5.8.37
    - Conclusion: don't install laravel/framework v5.8.36
    - orchestra/testbench v3.8.5 requires laravel/framework ~5.8.35 -> satisfiable by laravel/framework[v5.8.35, v5.8.36, v5.8.37, v5.8.38].
    - orchestra/testbench v3.8.6 requires laravel/framework ~5.8.35 -> satisfiable by laravel/framework[v5.8.35, v5.8.36, v5.8.37, v5.8.38].
    - Conclusion: don't install laravel/framework v5.8.35
    - Conclusion: don't install laravel/framework v5.8.34
    - Conclusion: don't install laravel/framework v5.8.33
    - Conclusion: don't install laravel/framework v5.8.32
    - Conclusion: don't install laravel/framework v5.8.31
    - Conclusion: don't install laravel/framework v5.8.30
    - Conclusion: don't install laravel/framework v5.8.29
    - Conclusion: don't install laravel/framework v5.8.28
    - Conclusion: don't install laravel/framework v5.8.27
    - Conclusion: don't install laravel/framework v5.8.26
    - Conclusion: don't install laravel/framework v5.8.25
    - Conclusion: don't install laravel/framework v5.8.24
    - Conclusion: don't install laravel/framework v5.8.23
    - Conclusion: don't install laravel/framework v5.8.22
    - Conclusion: don't install laravel/framework v5.8.21
    - Conclusion: don't install laravel/framework v5.8.20
    - orchestra/testbench v3.8.3 requires laravel/framework ~5.8.19 -> satisfiable by laravel/framework[v5.8.19, v5.8.20, v5.8.21, v5.8.22, v5.8.23, v5.8.24, v5.8.25, v5.8.26, v5.8.27, v5.8.28, v5.8.29, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.37, v5.8.38].
    - orchestra/testbench v3.8.4 requires laravel/framework ~5.8.19 -> satisfiable by laravel/framework[v5.8.19, v5.8.20, v5.8.21, v5.8.22, v5.8.23, v5.8.24, v5.8.25, v5.8.26, v5.8.27, v5.8.28, v5.8.29, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.37, v5.8.38].
    - Conclusion: don't install laravel/framework v5.8.19
    - Conclusion: don't install laravel/framework v5.8.18
    - Conclusion: don't install laravel/framework v5.8.17
    - Conclusion: don't install laravel/framework v5.8.16
    - Conclusion: don't install laravel/framework v5.8.15
    - Conclusion: don't install laravel/framework v5.8.14
    - Conclusion: don't install laravel/framework v5.8.13
    - Conclusion: don't install laravel/framework v5.8.12
    - Conclusion: don't install laravel/framework v5.8.11
    - Conclusion: don't install laravel/framework v5.8.10
    - Conclusion: don't install laravel/framework v5.8.9
    - Conclusion: don't install laravel/framework v5.8.8
    - Conclusion: don't install laravel/framework v5.8.7
    - Conclusion: don't install laravel/framework v5.8.6
    - Conclusion: don't install laravel/framework v5.8.5
    - Conclusion: don't install laravel/framework v5.8.4
    - orchestra/testbench v3.8.2 requires laravel/framework ~5.8.3 -> satisfiable by laravel/framework[v5.8.10, v5.8.11, v5.8.12, v5.8.13, v5.8.14, v5.8.15, v5.8.16, v5.8.17, v5.8.18, v5.8.19, v5.8.20, v5.8.21, v5.8.22, v5.8.23, v5.8.24, v5.8.25, v5.8.26, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.37, v5.8.38, v5.8.4, v5.8.5, v5.8.6, v5.8.7, v5.8.8, v5.8.9].
    - Conclusion: don't install laravel/framework v5.8.3
    - orchestra/testbench v3.8.1 requires laravel/framework ~5.8.2 -> satisfiable by laravel/framework[v5.8.10, v5.8.11, v5.8.12, v5.8.13, v5.8.14, v5.8.15, v5.8.16, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.21, v5.8.22, v5.8.23, v5.8.24, v5.8.25, v5.8.26, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.37, v5.8.38, v5.8.4, v5.8.5, v5.8.6, v5.8.7, v5.8.8, v5.8.9].
    - Conclusion: don't install laravel/framework v5.8.2
    - Installation request for barryvdh/laravel-debugbar dev-master -> satisfiable by barryvdh/laravel-debugbar[dev-master].
    - Installation request for orchestra/testbench ~3.8 -> satisfiable by orchestra/testbench[v3.8.0, v3.8.1, v3.8.2, v3.8.3, v3.8.4, v3.8.5, v3.8.6, v3.9.0, v3.9.1, v3.9.2, v3.9.3, v3.9.4].
    - barryvdh/laravel-debugbar dev-master requires illuminate/support ^6|^7 -> satisfiable by illuminate/support[v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, 
v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.4, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.2.0, v6.3.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, 
v6.6.2, v6.7.0, v6.8.0, v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.21.0, v7.22.0, v7.22.1, v7.22.2, v7.22.3, v7.22.4, v7.23.0, v7.23.1, v7.23.2, v7.24.0, v7.25.0, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
    - don't install illuminate/support v6.0.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.0.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.0.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.0.3|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.0.4|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.1.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.10.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.11.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.12.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.13.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.13.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.14.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.15.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.15.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.16.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.17.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.17.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.10|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.11|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.12|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.13|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.14|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.15|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.16|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.17|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.18|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.19|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.20|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.21|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.22|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.23|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.24|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.25|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.26|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.27|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.28|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.29|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.3|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.30|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.31|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.32|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.33|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.34|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.35|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.4|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.5|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.6|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.7|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.8|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.18.9|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.2.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.3.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.4.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.5.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.5.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.5.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.6.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.6.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.6.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.7.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v6.8.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.3|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.4|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.5|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.6|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.7|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.0.8|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.1.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.1.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.1.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.1.3|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.10.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.10.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.10.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.10.3|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.11.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.12.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.13.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.14.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.14.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.15.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.16.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.16.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.17.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.17.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.17.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.18.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.19.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.19.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.2.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.2.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.2.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.20.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.21.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.22.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.22.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.22.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.22.3|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.22.4|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.23.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.23.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.23.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.24.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.25.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.3.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.4.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.5.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.5.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.5.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.6.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.6.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.6.2|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.7.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.7.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.8.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.8.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.9.0|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.9.1|don't install laravel/framework v5.8.0
    - don't install illuminate/support v7.9.2|don't install laravel/framework v5.8.0
    - orchestra/testbench v3.8.0 requires laravel/framework ~5.8.0 -> satisfiable by laravel/framework[v5.8.0, v5.8.1, v5.8.10, v5.8.11, v5.8.12, v5.8.13, v5.8.14, v5.8.15, v5.8.16, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.21, v5.8.22, v5.8.23, v5.8.24, v5.8.25, v5.8.26, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.37, v5.8.38, v5.8.4, v5.8.5, v5.8.6, v5.8.7, v5.8.8, v5.8.9].      
    - Conclusion: don't install laravel/framework v5.8.1

My composer dependencies look like this:

    "require": {
        "php": ">=7.1.3",
        "barryvdh/laravel-debugbar": "dev-master",
        "cartalyst/sentinel": "2.0.*",
        "elasticsearch/elasticsearch": "^6.7",
        "laravel/framework": "~5.8",
        "laravel/nexmo-notification-channel": "^2.3",
        "laravel/socialite": "^4.1",
        "laravel/tinker": "^1.0",
        "laravelcollective/html": "5.8.*",
        "laravelcollective/remote": "^5.8",
        "laravelium/sitemap": "^3.1"
    },
    "require-dev": {
        "orchestra/testbench": "~3.8",
        "fzaninotto/faker": "~1.8",
        "mockery/mockery": "1.2.*",
        "phpunit/phpunit": "8.1.*"
    }



via Chebli Mohamed