Route::get('/biller-
info','MyDomain\Http\Controllers\BillPaymentController#getBillerInfo');
All other routes for api are created like this.
Getting exception Target class [Mydomain\Http\Controllers\BillPaymentController] does not exist.
guzzlehttps is installed.
route - 127.0.0.1/biller-info
path - api > packages > mydomain-shop > src > Http > Controllers > BillPaymentController.php
BillPaymentController.php
<?php
namespace MyDomain\Http\Controllers;
use Exception;
use Illuminate\Http\Request;
use MyDomain\Enums\Permission;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use MyDomain\Exceptions\MyDomainException;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Http;
class BillPaymentController extends CoreController
{
public function getBillerInfo()
{
$response = Http::get('https://reqres.in/api/products/3');
dd($response->collect());
}
}
Loading configuration files and clearing cache did the TRICK!!
composer dump-autoload
php artisan route:clear
Related
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'));
}
}
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}
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
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
In my web browser I am getting this error:
FatalErrorException in UserController.php line 18:
Class 'App\Report'
not found
It seems that UserControler.php page cannot find report.php page.
Here is my folder structure:
lumen
-api
--report.php // file where model Report is
---Http
----Controller
------UserController.php // file where i get error
-bootstrap
- ...
Header of UserController.php
namespace App\Http\Controllers;
use Illuminate\Database\Schema\Blueprint;
use App\Report; // it seems here is problem
use App\User; // with user model is same problem
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;
class UserController extends Controller {
...
Header of report.php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Report extends Model {
...
I am using Apache, Ubuntu, PHP 5.5 with Lumen framework
First of all model file name should be same as your class name here
lumen
-api
--report.php // This should be Report.php
---Http
----Controller
------UserController.php // file where i get error
-bootstrap
- ...
Also your Report.php Model will be under app directory same directory where your User Model resides