samedi 30 décembre 2017

Laravel Can't Access Model Within Event Listener

Not sure why I am having this issue, it should be a simple utilization of the use statement as is frequently done in Laravel controllers and repositories.

Is there something different for event listeners?

My error is:

Class 'App\Listeners\Asset' not found

It fires from my event listener:

<?php

namespace App\Listeners;

use App\Events\FFMPEGcreateAVideo;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Models\Asset;
use Auth;
use Illuminate\Support\Facades\Log;
class FFMPEGcreateAVideoListener implements ShouldQueue
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  FFMPEGcreateAVideo  $event
     * @return void
     */
    public function handle(FFMPEGcreateAVideo $event)
    {
        $assetID =  $event->assetID;
        $assetURL = $event->assetURL;
        $newAssetURL = preg_replace('/(.*\.(?!.*\.))(.*)/','${1}mp4',$assetURL);
        $coverPhotoPath = $event->coverphoto;
        $asset = Asset::where("id",$assetID)->first(); //error here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire