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

Laravel Increase Upload file Size Heroku

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

taskcompleted file

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class TaskCompleted extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}


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

Laravel Nothing to Migrate

I created migration on my Laravel project using command php artisan make:migration migration_name and php artisan make:model ModelName -mcr.

When I run php artisan migrate the output is nothing to migrate.

I check my database, there is only migration table which has no row, even user table that comes from Laravel does not created.

This is the environment that I use to run Laravel using XAMPP

  • Laravel 7.24
  • Apache/2.4.39 (Win64)
  • PHP 7.3.7
  • MariaDB 10.3.16

This is the migration code

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('category', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('category');
    }
}

I already try these but found no luck :

  • Run composer dump-autoload
  • Run php artisan migrate:reset -> nothing to rollback
  • Run php artisan migrate:fresh-> dropped all table successfully, migration table created successfully ,nothing to migrate
  • Run php artisan migrate --path="/database/migrations/" -> nothing to migrate
  • Run php artisan migrate:status -> no migrations found


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

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

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 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.

arguments;"Call to a member function isdeferred() on null"

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

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


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

Laravel forcing https in localhost

I have a Laravel app and I don't know why suddenly started to force https on my localhost. This is something I had never faced before.

This app runs with docker but even without running it with docker-compose but php artisan serve keeps on forcing https on my localhost. I even tried by adding

#app/Providers/AppServiceProvider.php

public function boot() 
{
   \URL::forceScheme('http');
   #.... rest of the code
}

but nothing. Any idea?



via Chebli Mohamed

how can admin approve or disapprove a user's form-data request in laravel

I have an employee management system on laravel 5.5 and I want the admin to approve or disapprove a request whenever a logged-in user wants to edit any information on his form data, any idea on how to make it work



via Chebli Mohamed

graphql with laravel output not working without "php artisan serve"

GraphQL-Laravel is not working without PHP artisan serve it's working fine for 127.0.0.1:8000/graphiql but not in localhost/myproject/graphiql

Here I've attached screencast



via Chebli Mohamed

Laravel Polymorphic Relationships - Return child with parent

I have a model Team with has a polymorphic relationship with Marketcenters Model:


namespace App;

use Illuminate\Database\Eloquent\Model;

class Team extends Model
{
    public function teamable()
    {
        return $this->morphTo();
    }
    
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Marketcenter extends Model
{
    public function teams()
    {
        return $this->morphMany('App\Team', 'teamable');
    }
}

I need to retieve all Teams for one or any Marketcenter so I can list all Teams and to which Marketcenter they belong. So I execute the following code and I get a collection od Teams for the Market Center in query:

$marketcenters = Marketcenter::where('id', $request->user()->marketcenter->id)->with('teams')->get();
    foreach($marketcenters as $marketcenter) {
        dd($marketcenter->teams);
    }

But my problem appears when I want to retrieve each Team with their corresponing Market Center:

$marketcenters = Marketcenter::where('id', $request->user()->marketcenter->id)->with('teams')->get();
    foreach($marketcenters as $marketcenter) {
        dd($marketcenter->teams->marketcenter->mc_name);
    }
Property [marketcenter] does not exist on this collection instance.

How can I retrieve parent data to child record in a Polymoprphic relationship?

Regards



via Chebli Mohamed

Converting multiple same name into one single name and also values get sum in laravel

I am trying to fetch the multi same name to single name also sum associated QTY values also.Show PART-ID as it's

example

enter image description here

I want to show like this

enter image description here

my controller

    public function productserach()
{ 
    $searchitem = Item_list::get();
    return view('products.product-serach',compact('searchitem'));
}


via Chebli Mohamed

This site can’t be reached when running site on https on localhost on wamp server

I am implementing web push notification, so i have enabled ssl on localhost, because some functionalituy does not work without ssl, not when i'm accessing my site by prefixing https:// it gives following error as shown in screenshot.

enter image description here

Without https it is working, Please help to sort out my issue.

httpd.conf:

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
# will be interpreted as '/logs/access_log'.
#
# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default.  It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.
ServerSignature On
ServerTokens Full

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
# Apache variable names used by Apache conf files:
# The names and contents of variables:
# APACHE24, VERSION_APACHE, INSTALL_DIR, APACHE_DIR, SRVROOT
# should never be changed.
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.39
Define INSTALL_DIR c:/wamp64new
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
Define SRVROOT ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}

ServerRoot "${SRVROOT}"

#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
#
# Uncomment and change the directory if mutexes are file-based and the default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
#
# Mutex default:logs

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_core_module modules/mod_authn_core.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule authz_core_module modules/mod_authz_core.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule brotli_module modules/mod_brotli.so
#LoadModule buffer_module modules/mod_buffer.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule data_module modules/mod_data.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule dumpio_module modules/mod_dumpio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
#LoadModule http2_module modules/mod_http2.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule lua_module modules/mod_lua.so
#LoadModule macro_module modules/mod_macro.so
#LoadModule md_module modules/mod_md.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so
#LoadModule proxy_html_module modules/mod_proxy_html.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_http2_module modules/mod_proxy_http2.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule request_module modules/mod_request.so
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_crypto_module modules/mod_session_crypto.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule socache_redis_module modules/mod_socache_redis.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
#LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so

PHPIniDir "${APACHE_DIR}/bin"
LoadModule php7_module "${INSTALL_DIR}/bin/php/php7.2.18/php7apache2_4.dll"

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin wampserver@wampserver.invalid

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
HostnameLookups Off

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks +Multiviews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #
#   onlineoffline tag - don't remove
    Require local
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
#ErrorLog "logs/error.log"
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "${INSTALL_DIR}/logs/access.log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access.log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock cgisock
</IfModule>

#
# "${SRVROOT}/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "${SRVROOT}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule headers_module>
    #
    # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied
    # backend servers which have lingering "httpoxy" defects.
    # 'Proxy' request header is undefined by the IETF, not listed by IANA
    #
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile off

# AcceptFilter: On Windows, none uses accept() rather than AcceptEx() and
# will not recycle sockets between connections. This is useful for network
# adapters with broken driver support, as well as some virtual network
# providers such as vpn drivers, or spam, virus or spyware filters.
AcceptFilter http none
AcceptFilter https none
# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf

# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include "${INSTALL_DIR}/alias/*"

httpd-vhosts.conf

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>



<VirtualHost *:443>
  ServerName localhost
  ServerAlias localhost
  SSLEngine On
  SSLCertificateFile "C:/wamp64new/bin/apache/apache2.4.39/conf/key/certificate.crt"
  SSLCertificateKeyFile "C:/wamp64new/bin/apache/apache2.4.39/conf/key/private.key"
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
    # etc
</VirtualHost>


via Chebli Mohamed