I have started a new project with Laravel 8.
I use the starter kit Laravel Breeze.
But I can't customize fields.
I have changed fields in the migration and Register Controller and User model.
here is my code:
migration file.
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
class TblUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tbl_users', function (Blueprint $table) {
$table->id();
$table->string('fullname');
$table->string('username');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('phone');
$table->string('organization_type');
$table->string('community_dev_auth_id');
$table->string('file_names');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tbl_users');
}
}
register controller file.
<?php
namespace AppHttpControllersAuth;
use AppHttpControllersController;
use AppModelsUser;
use AppProvidersRouteServiceProvider;
use IlluminateAuthEventsRegistered;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
use IlluminateSupportFacadesHash;
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*
* @return IlluminateViewView
*/
public function create()
{
return view('auth.register');
}
/**
* Handle an incoming registration request.
*
* @param IlluminateHttpRequest $request
* @return IlluminateHttpRedirectResponse
*
* @throws IlluminateValidationValidationException
*/
public function store(Request $request)
{
$request->validate([
'fullname' => 'required|string|max:255',
'username' => 'required|string|max:255',
'email' => 'required|senter code heretring|email|max:255|unique:users',
'phone' => 'required|string|max:255',
'organization' => 'required|string|max:255',
'community' => 'required|string|max:255',
// 'phone' => 'required|string|max:255',
'password' => 'required|string|min:8',
]);
Auth::login($user = User::create([
'fullname' => $request->fullname,
'username' => $request->username,
'email' => $request->email,
'phone' => $request->phone,
'organization_type' => $request->organization,
'community_dev_auth_id' => $request->community,
'password' => Hash::make($request->password),
]));
event(new Registered($user));
return redirect(RouteServiceProvider::HOME);
}
}
user model file.
<?php
namespace AppModels;
use IlluminateContractsAuthMustVerifyEmail;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'fullname',
'username',
'email',
'phone',
'organization',
'community',
'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
I have run this project, but it returns this error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'ambulance_dubai.users' doesn't exist (SQL: select count(*) as
aggregate from users
where email
= [email protected])
Please help me.
Best Regards.
question from:
https://stackoverflow.com/questions/66063589/how-to-solve-this-problem-in-laravel-8-sqlstate42s02-base-table-or-view-no 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…