Article


POS Laravel adminlte vuejs #2 membuat table

Membuat database

edit database schema user defaul laravel
        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->rememberToken();
            $table->string('photo')->nullable();
            $table->string('api_token')->nullable();
            $table->char('role', 1)->comment('0: developer, 1: admin, 2: finance, 3: casier');
            $table->unsignedBigInteger('store_id')->nullable();
            $table->timestamps();
            $table->softDeletes();            
        });

Membuat tabel store
php artisan make:model Store -m
        Schema::create('stores', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->boolean('status')->default(false);
            $table->string('address');
            $table->string('phone');
            $table->timestamps();
            $table->softDeletes();
        });
 

Membuat table customer
$  php artisan make:model Customer -m

        Schema::create('customers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nik')->unique();
            $table->string('name');
            $table->string('address');
            $table->string('phone');
            $table->unsignedBigInteger('user_id');
            $table->integer('point');
            $table->integer('deposit');
            $table->timestamps();
            $table->softDeletes();
          
            $table->foreign('courier_id')->references('id')->on('users');
        });

Membuat table category
$ php artisan make:model Category -m
        Schema::create('categories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('description')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

Membuat table product
$ php artisan make:model Product -m
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('description')->nullable();
            $table->string('stock');
            $table->string('price');
            $table->integer('category_id');
            $table->timestamps();
            $table->softDeletes();
        });

Membuat table sales
$ php artisan make:model Sales -m

        Schema::create('sales', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('invoice')->unique();
            $table->integer('customer_id');
            $table->integer('user_id');
            $table->integer('total');
            $table->timestamps();
            $table->softDeletes();
        });

$ php artisan make:model Sales_detail -m

        Schema::create('sales_details', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('sales_id');
            $table->integer('product_id');
            $table->integer('qty');
            $table->integer('price');
            $table->timestamps();
            $table->softDeletes();
        });
 

$ php artisan migrate

 

Posted in Laravel, Linux, PHP on Aug 29, 2020