estoy intentando agregar un cliente a mi base de datos llenando un formulario y cuando lo agrego me tira el siguiente error. Estoy usando Laravel 7 y MySQL como base de datos, nose si es de ayuda pero lo aclaro por las dudas.
'Class 'App\Customer' not found'
Esta es la migration: create_customers_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCustomersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->string('holding');
$table->string('company')->nullable();
$table->string('legal_entity')->nullable();
$table->string('email');
$table->string('country')->nullable();
$table->string('state')->nullable();
$table->string('city')->nullable();
$table->string('address')->nullable();
$table->string('postal')->nullable();
$table->string('cuit');
$table->string('website')->nullable();
$table->tinyInteger('status')->default('1');
$table->integer('id_parentCompany')->nullable();
$table->integer('created_by')->nullable();
$table->integer('updated_by')->nullable();
$table->timestamps();
});
}
Mi modelo Customer:
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
protected $fillable = ['holding','company','legal_entity','mobile_no','email','country','state','city','address','postal'
,'cuit','website','status'];
}
Y por ultimo el CustomerController:
namespace App\Http\Controllers\Backend;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Model\Product;
use App\Model\Supplier;
use App\Model\Unit;
use App\Model\Category;
use App\Model\Purchase;
use App\Model\Invoice;
use App\Model\InvoiceDetail;
use App\Model\Payment;
use App\Model\PaymentDetail;
use App\Model\Customer;
use Auth;
use Session;
use DB;
use PDF;
class CustomerController extends Controller
{
public function view(){
$allData = Customer::all();
return view('backend.customer.view-customer', compact('allData'));
}
public function add(){
return view('backend.customer.add-customer');
}
public function store(Request $request){
$customer = new Customer();
$customer->holding = $request->holding;
/*$customer->name = $request->name;*/
$customer->company = $request->company;
$customer->legal_entity = $request->legal_entity;
$customer->email = $request->email;
$customer->country = $request->country;
$customer->state = $request->state;
$customer->city = $request->city;
$customer->address = $request->address;
$customer->postal = $request->postal;
$customer->cuit = $request->cuit;
$customer->website = $request->website;
$customer->id_parentCompany = $request->id_parentCompany;
$customer->created_by = Auth::user()->id;
$customer->save();
Session::flash('success');
return redirect()->route('customers.view');
}
No entiendo porque salta ese error si en todo momento esta incluyendo al modelo de customer, en todos los archivos. Si alguien tiene alguna idea y me puede guiar se lo agradezco. Cabe aclarar que en mi base de datos el registro se guarda pero al momento de mostrarlo en la vista de customers donde estaria el listado, salta el error.