0
I’m making the following mistake:
Reflectionexception in Container.php line 731: Class App Defeito does not exist
I’m using Laravel 5.4, I’ve checked apparently this all right.
Code: Defeito.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Defeito extends Model {
protected $table = 'defeito';
public $timestamps = false;
}
Code: Controller
:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use League\Flysystem\Exception;
class DefeitoController extends Controller
{
private $defeitos;
public function __construct(Defei $defeitos)
{
$this -> defeitos = $defeitos;
}
public function salvar(Request $request) {
try {
$defeito = new $this -> defeitos;
$defeito -> assunto = $request -> input('assunto');
$defeito -> duvida = $request -> input('duvida');
$defeito -> satisfacao = $request -> input('satisfacao');
$defeito -> contato = $request -> input('contato');
$defeito->save();
return response()->json(['status' => 1,
'msg' => 'Defeito salvo com sucesso']);
} catch (Exception $e ) {
return response()->json(['status' => 0,
'msg' => 'Houve um erro ao salvar o defeito']);
}
}
}
Route: API
Route::post('clientes/salvar', 'ClienteController@salvar');
Route: Web
Route::get('/defeito', function () {
return view('template/form-defeitos');
});
Would not be
App\Models\Defeito
?– Woss
no error: Undefined namespace Model.
– Douglas William
Even with
Models
, plural?– Woss
that’s right .....
– Douglas William
was all right, but now began to give this mistake.
– Douglas William
Then edit your question and enter the codes. If it worked before, also put what you changed in the project.
– Woss
in Routecollection.php line 161 at Routecollection->match(Object(Request)) in Router.php line 533, I just put some Forms.
– Douglas William
All the places I’ve seen, the models in the Laravel framework are in the namespace
Models
, then you must have done something wrong. Edit the question and enter the codes.– Woss
Possible duplicate of Class not found Laravel
– novic
The model namespace must be namespace
App\Models;
– Miguel