[Seri] - Website đồng hồ - Tạo bảng keyword và thư mục chưa view keyword

Tiếp tục phần thứ hai này mình sẽ tạo phần quản lý từ khoá. Đầu tiên là tạo csdl và folder chứa keyword

Các bạn làm lần lượt các bước như sau nhé

Tạo migrate

Để tạo file migrate các bạn run câu lệnh sau 

php artisan make:migration create_keywords_table

Nội dung file sẽ là 

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKeywordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('keywords', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('k_name');
            $table->string('k_slug')->unique();
            $table->string('k_description')->nullable();
            $table->tinyInteger('k_hot')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('keywords');
    }
}

Tao thư mục 

Cùng cấp với category các bạn tạo cho mình 1 folder keyword và trong đó tạo tiếp 3 file index create, update như category nhé.

Video hướng dẫn 

 

Để lại comment của bạn nếu gặp khó khăn

Bài viết liên quan