lundi 24 juin 2019

How to fix this Uncaught UnexpectedValueException: Invalid route action

I'm trying to convert a closure-based routes to use a single action controller

So on my fuzzy.php inside routes folder i did this write the codes

Route::get('theme/{file?}', 'FuzzyController')->name('fuzzy-theme.get');


and on my FuzzyController.php inside Core\Controllers\Assets

<?php

//namespace App\Http\Controllers;
namespace Core\Controllers\Assets;

// use App\User;
use App\Http\Controllers\Controller;

class FuzzyController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return View
     */
    public function __invoke(Request $request, $file = null)
    {
        $path = base_path(config('path.themes', 'themes').'/'.settings('active_theme', 'default'))."/$file";
        $fileArray = explode('/', $file);
        $lastFile = end($fileArray);
        $extension = explode(".", $lastFile);
        $fileExtension = end($extension);
        $isCss = 'css' === $fileExtension ? true : false;

        if (! in_array($fileExtension, config('downloadables', []))) {
            return abort(403);
        }

        if (\File::exists($path)) {
            $headers = [
                'Cache-Control' => 'public',
                'Content-Type' => 'text/css'
            ];
            return response()->file($path, $isCss ? $headers : []);
        }

        return abort(404);
        // return view('user.profile', ['user' => User::findOrFail($id)]);
    }

}


can some explain why do i get an invalid route action thanks :D



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire