當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Schema::create方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Schema::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Schema::create方法的具體用法?PHP Schema::create怎麽用?PHP Schema::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Schema的用法示例。


在下文中一共展示了Schema::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: migrateTables

 private function migrateTables()
 {
     Schema::create('users', function ($table) {
         $table->increments('id');
         $table->string('username');
         $table->timestamps();
     });
     Schema::create('posts', function ($table) {
         $table->integer('user_id')->unsigned()->nullable();
         $table->increments('id');
         $table->string('title');
         $table->text('description');
         $table->timestamps();
         $table->foreign('user_id')->references('id')->on('users')->onUpdate('restrict')->onDelete('set null');
     });
     Schema::create('revisions', function ($table) {
         $table->increments('id');
         $table->string('revisionable_type');
         $table->integer('revisionable_id');
         $table->integer('user_id')->nullable();
         $table->string('key');
         $table->text('old_value')->nullable();
         $table->text('new_value')->nullable();
         $table->timestamps();
         $table->index(['revisionable_id', 'revisionable_type']);
     });
 }
開發者ID:pionl,項目名稱:revision,代碼行數:27,代碼來源:FunctionalTestCase.php

示例2: createSchema

 public function createSchema()
 {
     if (!DbSchema::hasTable('sessions')) {
         try {
             DbSchema::create('sessions', function ($table) {
                 $table->string('id')->unique();
                 $table->longText('payload');
                 $table->integer('last_activity');
             });
         } catch (QueryException $e) {
         }
     }
     $exec = $this->getSystemSchemas();
     $builder = new DbUtils();
     foreach ($exec as $data) {
         // Creates the schema
         if (!method_exists($data, 'get')) {
             break;
         }
         $schemaArray = $data->get();
         if (!is_array($schemaArray)) {
             break;
         }
         foreach ($schemaArray as $table => $columns) {
             $builder->build_table($table, $columns);
         }
     }
 }
開發者ID:kamilmiesiac,項目名稱:microweber,代碼行數:28,代碼來源:DbInstaller.php

示例3: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('articles', function (Blueprint $table) {
         $table->increments('id');
         $table->unsignedInteger('category_id')->index();
         $table->string('title')->index();
         $table->string('alias')->index();
         $table->string('author_alias')->nullable()->index();
         $table->string('blade_template')->nullable();
         $table->text('body')->nullable();
         $table->dateTime('publish_up')->nullable();
         $table->dateTime('publish_down')->nullable();
         $table->text('parameters')->nullable();
         $table->unsignedInteger('order')->default(1);
         $table->integer('hits')->default(0);
         $table->boolean('published')->default(false)->index();
         $table->boolean('authenticated')->default(false);
         $table->boolean('featured')->default(false);
         $table->string('authorization', 20)->default('can');
         $table->unsignedInteger('created_by')->nullable()->index();
         $table->unsignedInteger('updated_by')->nullable()->index();
         $table->timestamps();
         $table->foreign('category_id')->references('id')->on('categories');
     });
     Schema::create('article_permission', function (Blueprint $table) {
         $table->unsignedInteger('article_id')->index();
         $table->unsignedInteger('permission_id')->index();
         $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
         $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
     });
 }
開發者ID:yajra,項目名稱:cms-core,代碼行數:36,代碼來源:2015_12_20_100007_create_articles_table.php

示例4: up

 public function up()
 {
     Schema::create('addresses', function (Blueprint $table) {
         $table->increments('id');
         $table->morphs('addressable');
         $table->integer('country_id')->unsigned()->index();
         $table->string('organization')->nullable();
         $table->string('name_prefix');
         $table->string('name_suffix')->nullable();
         $table->string('first_name');
         $table->string('last_name');
         $table->string('street');
         $table->string('building_number')->nullable();
         $table->string('building_flat')->nullable();
         $table->string('city');
         $table->string('city_prefix')->nullable();
         $table->string('city_suffix')->nullable();
         $table->string('state')->nullable();
         $table->string('state_code')->nullable();
         $table->string('postcode');
         $table->string('phone')->nullable();
         $table->float('lat')->nullable();
         $table->float('lng')->nullable();
         foreach (config('addressable.flags', []) as $flag) {
             $table->boolean('is_' . $flag)->default(false)->index();
         }
         $table->timestamps();
     });
 }
開發者ID:draperstudio,項目名稱:laravel-addressable,代碼行數:29,代碼來源:create_addresses_table.php

示例5: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email')->unique();
         $table->string('password');
         $table->boolean('active');
         $table->boolean('banned');
         $table->string('register_ip');
         $table->string('country_code');
         $table->string('locale');
         $table->string('activation_key');
         $table->boolean('su');
         $table->rememberToken();
         $table->timestamps();
     });
     $user = \Laralum::newUser();
     $user->name = env('USER_NAME', 'admin');
     $user->email = env('USER_EMAIL', 'admin@admin.com');
     $user->password = bcrypt(env('USER_PASSWORD', 'admin123'));
     $user->active = true;
     $user->banned = false;
     $user->register_ip = "";
     $user->country_code = env('USER_COUNTRY_CODE', 'ES');
     $user->locale = env('USER_LOCALE', 'en');
     $user->activation_key = str_random(25);
     $user->su = true;
     $user->save();
 }
開發者ID:ConsoleTVs,項目名稱:Laralum,代碼行數:35,代碼來源:2014_10_12_000000_create_users_table.php

示例6: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('attachments', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('path');
         $table->string('extension', 20);
         $table->integer('uploaded_to');
         $table->boolean('external');
         $table->integer('order');
         $table->integer('created_by');
         $table->integer('updated_by');
         $table->index('uploaded_to');
         $table->timestamps();
     });
     // Get roles with permissions we need to change
     $adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
     // Create & attach new entity permissions
     $ops = ['Create All', 'Create Own', 'Update All', 'Update Own', 'Delete All', 'Delete Own'];
     $entity = 'Attachment';
     foreach ($ops as $op) {
         $permissionId = DB::table('role_permissions')->insertGetId(['name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)), 'display_name' => $op . ' ' . $entity . 's', 'created_at' => \Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()]);
         DB::table('permission_role')->insert(['role_id' => $adminRoleId, 'permission_id' => $permissionId]);
     }
 }
開發者ID:ssddanbrown,項目名稱:bookstack,代碼行數:30,代碼來源:2016_10_09_142037_create_attachments_table.php

示例7: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('oauth_grants', function (Blueprint $t) {
         $t->string('id', 40)->primary();
         $t->timestamps();
     });
 }
開發者ID:nicklaw5,項目名稱:ticketing-system-api,代碼行數:12,代碼來源:2015_10_19_000002_create_oauth_grants_table.php

示例8: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('notification_types', function (Blueprint $table) {
         $table->increments('id');
         $table->string('type');
     });
 }
開發者ID:GHarutyunyan,項目名稱:cms,代碼行數:12,代碼來源:2016_07_09_172132_create_notification_types_table.php

示例9: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create($this->getTableName(), function (Blueprint $table) {
         $table->string('id', 191);
         $table->text('value')->nullable();
     });
 }
開發者ID:ionutmilica,項目名稱:laravel-settings,代碼行數:12,代碼來源:9999_12_20_142530_CreateSettingsTable.php

示例10: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('profesor', function (Blueprint $table) {
         $table->integer('pro_tipo');
         $table->timestamps();
     });
 }
開發者ID:Rayotz,項目名稱:TiMsRw,代碼行數:12,代碼來源:2015_12_22_164927_create_profesor_table.php

示例11: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('site_visits', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
     });
 }
開發者ID:GHarutyunyan,項目名稱:cms,代碼行數:12,代碼來源:2016_07_23_152610_create_site_visits_table.php

示例12: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('posts', function (Blueprint $table) {
         $table->engine = 'InnoDB';
         $table->increments('id');
         $table->integer('user_id')->unsigned();
         $table->string('title', 191);
         $table->string('slug', 191)->unique();
         $table->string('type', 10);
         $table->string('media', 191);
         $table->string('thumbnail', 191);
         $table->string('featured', 191);
         $table->boolean('safe')->default(true);
         $table->boolean('resized')->default(false);
         $table->boolean('reported')->default(false);
         $table->string('source', 191)->nullable();
         // Cache fields
         $table->integer('reports')->default(0)->unsigned();
         $table->integer('comments')->default(0)->unsigned();
         $table->integer('likes')->default(0)->unsigned();
         $table->integer('dislikes')->default(0)->unsigned();
         $table->integer('points')->default(0);
         $table->timestamps();
         $table->softDeletes();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
     });
 }
開發者ID:vjaykoogu,項目名稱:smile-media-laravel,代碼行數:32,代碼來源:2015_07_17_094129_CreatePostsTable.php

示例13: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('roles', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('label')->nullable();
         $table->text('description')->nullable();
         $table->nullableTimestamps();
     });
     Schema::create('permissions', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('label')->nullable();
         $table->text('description')->nullable();
         $table->nullableTimestamps();
     });
     Schema::create('permission_role', function (Blueprint $table) {
         $table->integer('permission_id')->unsigned();
         $table->integer('role_id')->unsigned();
         $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
         $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
         $table->primary(['permission_id', 'role_id']);
     });
     Schema::create('role_user', function (Blueprint $table) {
         $table->integer('role_id')->unsigned();
         $table->integer('user_id')->unsigned();
         $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->primary(['role_id', 'user_id']);
     });
 }
開發者ID:wi-development,項目名稱:my-framework,代碼行數:36,代碼來源:2016_09_23_104307_create_roles_tables.php

示例14: up

 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('comments', function (Blueprint $t) {
         $t->engine = 'InnoDB';
         $t->increments('id');
         $t->text('message');
         $t->string('commentable_type');
         $t->integer('commentable_id');
         $t->integer('author_id');
         $t->timestamps();
         $t->integer('project_id');
         $t->string('attachment')->nullable();
         $t->string('line_code')->nullable();
         $t->string('commit_id')->nullable();
         $t->boolean('system')->default(false);
         $t->text('st_diff')->nullable();
         $t->integer('updated_by_id')->nullable();
         $t->boolean('is_award')->default(false);
         $t->softDeletes();
         $t->index('author_id');
         $t->index('commit_id');
         $t->index(['created_at', 'id']);
         $t->index('created_at');
         $t->index('is_award');
         $t->index('line_code');
         $t->index(['commentable_id', 'commentable_type']);
         $t->index('commentable_type');
         $t->index(['project_id', 'commentable_type']);
         $t->index('project_id');
         $t->index('updated_at');
     });
 }
開發者ID:xiaobailc,項目名稱:Gitamin,代碼行數:35,代碼來源:2015_12_08_144959_CreateCommentsTable.php

示例15: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('idUser');
         $table->string('firstname');
         $table->string('name');
         $table->string('email')->unique();
         $table->string('phone');
         $table->string('fixphone');
         $table->string('street');
         $table->integer('codePostal');
         $table->string('town');
         $table->string('country');
         $table->date('birthday');
         $table->string('statut');
         $table->integer('idGie');
         $table->integer('idGaec');
         $table->float('tauxHoraire');
         $table->string('type');
         $table->string('password');
         $table->rememberToken();
         $table->timestamps();
     });
 }
開發者ID:BBerthod,項目名稱:AgreenWeb,代碼行數:30,代碼來源:2014_10_12_000000_create_users_table.php


注:本文中的Illuminate\Support\Facades\Schema::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。