php - Registration Form Type

374

I'm trying to modify my registration form to include a type (Restaurant or Consumer). I need a checkbox that once checked will indicate the account should be a Restaurant. (Not checked = Consumer).

I've researched Gates but it's not exactly what i'm looking for. My thought process was to make a boolean attribute in the user migration.

seeder

public function run() {
    DB::table('users')->insert([
    'name' => "admin",
    'email' => '[email protected]',
    'password' => bcrypt('admin'),
    // 'type' => true
    ]);
}   

migration

Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        // $table->boolean('type');
        $table->rememberToken();
        $table->timestamps();
    });

Upon the user checking the box, i want the restaurant users to be able to edit certain properties. With the consumer having no permissions, only viewing rights.

15

Answer

Solution:

you can do it like this Schema

Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        $table->boolean('type')->default(0);
        $table->rememberToken();
        $table->timestamps();
    });

Then you can run the migration:

public function run() {
    DB::table('users')->insert([
    'name' => "admin",
    'email' => '[email protected]',
    'password' => bcrypt('admin'),
    'type' => 1
    ]);
}  

People are also looking for solutions to the problem: php - Losing Cookies after succesful login

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.