当前位置: 首页>>代码示例>>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;未经允许,请勿转载。