resting
1 year ago

Does alias work only work in view templates?

Posted 1 year ago by resting

I have a Facade class:

namespace App\Facades;

use Illuminate\Support\Facades\Facade;

class VuforiaApiFacade extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'VuforiaApi';
    }
}

I register the alias VuforiaApi with:

'VuforiaApi' => App\Facades\VuforiaApiFacade::class,

Tried to call a method from controller:

VuforiaApi::delete_from_vuforia_and_s3($m);

throws Class 'App\Http\Controllers\VuforiaApi' not found

I had to call the full path to the Facade:

use App\Facades\VuforiaApiFacade;
...
VuforiaApiFacade::delete_from_vuforia_and_s3($m);

However calling a method in view template works fine

@php
dd(VuforiaApi::d());
@endphp

So alias only works in view templates?

Please sign in or create an account to participate in this conversation.