Laravel 5.2 - ReflectionException Class laravel-fullcalendar does not exist - laravel

I am using the Fullcalendar package for Laravel 5.
I am experiencing this error:
ReflectionException in Container.php line 734:
Class laravel-fullcalendar does not exist
I have the Service Provider and the Facade in app.php.
This is my controller:
namespace App\Http\Controllers\Admin;
use App\Lesson;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use MaddHatter\LaravelFullcalendar\Facades\Calendar;
class CalendarController extends Controller
{
public function index()
{
$calendar_events = Lesson::all();
return view('admin.calendar', ['calendar' => Calendar::addEvent($calendar_events)]);
}
}
I don't understand the reason of this error.
I tried to use \Calendar without the "use" line, MaddHatter\LaravelFullcalendar\Facades\Calendar::addEvent() directly and I tried several times composer dump-autoload.

I noticed that I started having the same problem with all the new installed packages.
I resolved in this way:
composer dump-autoload
php artisan cache:clear
php artisan config:clear

Related

Nova route overwriting

Nova 3 and Laravel 8
In RouteServiceProvider I added
Route::prefix('nova-api')
->middleware(['nova'])
->domain(config('nova.domain'))
->namespace('App\Http\Controllers\Nova')
->group(base_path('routes/nova-api.php'));
And the file content is
Route::delete('/{resource}/{resourceId}/field/{field}', 'FieldDestroyController#handle');
Route::delete('/testing', 'FieldDestroyController#handle');
After restarting project I see testing route, but not nova overwritten.
Is it possible to overwrite routes and how ?
Solution that works!
Create new ServiceProvider
php artisan make:provider NovaServiceProvider (or php artisan make:provider NovaRouteServiceProvider)
And place overwrite code .
In my case it is
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Laravel\Nova\NovaServiceProvider as ServiceProvider;
class NovaServiceProvider extends ServiceProvider
{
protected function registerRoutes()
{
parent::registerRoutes();
Route::prefix('nova-api')
->middleware(['nova'])
->domain(config('nova.domain'))
->namespace('App\Http\Controllers\Nova')
->group(base_path('routes/nova-api.php'));
}
}

Location of Controller in Laravel

I created a new Laravel controller named "StoriesController" using the CLI:
php artisan make:controller StoriesController
When I open app/Http/Controllers/StoriesController.php, I see:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class StoriesController extends Controller
{
//
}
My question is about the line:
class StoriesController extends Controller
Where is the "Controller" script located? Which directory?
{your-project]/app/http/controllers/{StoriesController}

Export process work but no file downloaded [ Maatwebsite / Laravel-Excel ]

PHP version: 7.3.9
Laravel version: 5.8.30
Package version: 3.1
Description
I am trying to export excel file. I do all things in the documentation and the process work with no errors. but the excel file does not download.. I'm using Ubuntu OS.
UserExport.php
<?php
namespace App\Exports;
use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
class UsersExport implements FromCollection
{
/**
*/
public function collection()
{
return User::all();
}
}
ExportExcelController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;
class ExportExcelController extends Controller
{
public function export()
{
return Excel::download(new UsersExport, 'users.xlsx');
}
}
I was seeing the same behavior. I got around it by clearing out all caches and recreating the config cache.
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:cache
I was using the package with inertia-vue and using an <a></a> in place of the <Link></Link> tag worked the trick

Laravel class undefined after config:clear

App\Constant\ProductConstant.php
<?php
namespace App\Constant;
use App\Constant\BaseConstant;
class ProductConstant extends BaseConstant {
const TITLE = "title";
}
Product.php
<?php
namespace App\Models;
use App\Constant\ProductConstant;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $table = 'products';
protected $fillable = [ProductConstant::TITLE, ProductConstant::IMAGE, ProductConstant::EXPIRY_DATE, ProductConstant::MAX_PARTICIPANTS, ProductConstant::TOTAL_PARTICIPANTS];
Error
Undefined class constant 'App\Constant\ProductConstant::TITLE'
After I've executed php artisan config:clear. May I know what's the reason?
do not run php artisan config:clear in local system , it may break your project
delete this file bootstrap/cache/config.php
and run project again
run php artisan cache:clear to clear cache of .env file

while retrieving data from WHMCS API I'm getting error as follows : InvalidArgumentException View [SME_Hosting] not found

I have created a controller and the coding in my controller file is as shown below
This is the controller code
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use DarthSoup\Whmcs\Facades\Whmcs;
use DarthSoup\Whmcs\WhmcsServiceProvider;
class GetProductController extends Controller
{
public function show(){
$products = Whmcs::GetProducts([
]);
return view('SME_Hosting',['products'=>$products]);
}}
This is my Route
Route::get('/SME_Hosting','GetProductController#show');
I'm getting same error even after clearing the cache by using the below functions:
php artisan config:cache
php artisan config:clear

Resources