這篇文章主要介紹laravel使用命令行結合代碼創(chuàng)建數(shù)據(jù)表的方法,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
十余年的靈壽網站建設經驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。全網整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調整靈壽建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“靈壽網站設計”,“靈壽網站推廣”以來,每個客戶項目都認真落實執(zhí)行。
雖然可以直接在數(shù)據(jù)庫中創(chuàng)建數(shù)據(jù)表,但是不便于以后項目的遷移?,F(xiàn)使用命令行結合代碼的方式來進行生成。
php artisan make:migration create_table_customers
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateTableCustomers extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('customers', function (Blueprint $table) { $table->increments('id'); $table->string('mobile')->nullable()->unique(); $table->string('email')->unique(); $table->string('website')->default('website')->comment('站點:applet、website'); $table->string('store_id')->default('1')->comment('店鋪 ID'); $table->string('first_name'); $table->string('last_name'); $table->integer('appellation')->comment('稱謂'); $table->dateTime('birthday')->comment('生日'); $table->string('province')->comment('省'); $table->string('city')->comment('市'); $table->string('district')->comment('區(qū)/縣'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('customers'); } }
php artisan migrate
以上是“l(fā)aravel使用命令行結合代碼創(chuàng)建數(shù)據(jù)表的方法”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
分享名稱:laravel使用命令行結合代碼創(chuàng)建數(shù)據(jù)表的方法
當前URL:http://www.muchs.cn/article34/ippgse.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網站、小程序開發(fā)、云服務器、虛擬主機、ChatGPT、移動網站建設
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)