Answer the question
In order to leave comments, you need to log in
Why does FormController does not exist error occur in laravel?
Laravel Framework 5.8.38
tell me where to dig? why is there an error
ReflectionException - Class App\Http\Controllers\Site\FormController does not exist
app/Http/Middleware/Cors.php at line 18 in Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
app/Http/Middleware/SetLocale. php at line 20 in Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
public/index.php at line 53 in Illuminate\Foundation\Http\Kernel::handle
Route::group(['prefix' => '/api/v1', 'namespace' => 'Site', 'middleware' => ['api','cors']], function() {
Route::post("form/send", "[email protected]")
});
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Accept-Patch', '*')
->header('Allow', 'GET, POST, PUT, DELETE, OPTIONS, PATCH')
->header('Access-Control-Allow-Credentials', 'true')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, PATCH')
->header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization')
->header('Access-Control-Request-Headers', 'X-Requested-With, accept, content-type');
}
}
namespace App\Http\Controllers\Site;
use App\Http\Controllers\Controller;
use App\Models\Form;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class FormController extends Controller
{
private $form;
private $formFields;
public function send(Request $request) {
$time = time();
$this->formFields = $request->all();
$this->formFields["ip"] = request()->server("REMOTE_ADDR");
$this->form = new Form($this->formFields);
if($this->saveForm()) {
if($this->sendEmail()) {
return response()->json(["status" => "success"]);
}
}
}
//........
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question