/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     schema::create('user', function (Blueprint $table) {
         $table->increments('id');
         $table->string('user_name', 25)->unique();
         $table->string('password');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     schema::create('identitas', function (Blueprint $table) {
         $table->increments('nama');
         $table->string('alamat');
         $table->string('jenis_kelamin');
         $table->string('tanggal_masuk');
         $table->timestamps();
     });
 }
 public function up()
 {
     schema::create('roles', function (Blueprint $table) {
         $table->integer('id_rol')->unique();
         $table->string('nombre_rol', 50);
         $table->integer('prioridad');
         $table->timestamps();
         $table->integer('id_participante')->unsigned();
         $table->foreign('id_participante')->references('id_participante')->on('participantes')->onDelete('cascade');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('tags', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
     // Articles & Tags = article & tags = article_tags
     schema::create('article_tag', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('article_id')->unsigned();
         $table->integer('tag_id')->unsigned();
         $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
         $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
         $table->timestamps();
     });
 }
 /**
  * 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', 60);
         $table->boolean('is_active')->default(1);
         $table->boolean('confirmed')->default(0);
         $table->string('verification_key', 20)->unique();
         $table->rememberToken();
         $table->timestamps();
     });
     Schema::create('roles', function (Blueprint $table) {
         $table->increments('id');
         $table->string('role', 15);
         $table->timestamps();
     });
     schema::create('user_roles', function (Blueprint $table) {
         $table->integer('user_id')->unsigned()->index();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->integer('role_id')->unsigned()->index();
         $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
     });
     Schema::create('companies', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name', 80);
         $table->string('email')->unique();
         $table->string('api_key', 60);
         $table->string('verification_key', 20)->unique();
         $table->string('domain_url', 100);
         $table->boolean('is_active')->default(0);
         $table->boolean('confirmed')->default(0);
         $table->timestamps();
     });
     Schema::create('users_companies', function (Blueprint $table) {
         $table->integer('user_id')->unsigned()->index();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->integer('company_id')->unsigned()->index();
         $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
         $table->boolean('is_active');
         $table->timestamps();
     });
 }
Esempio n. 6
0
 public function database()
 {
     if (!\Schema::hasTable('addons')) {
         \Schema::create('addons', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->integer('active')->default(0);
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE addons ADD INDEX `name`(`name`)");
     } catch (\Exception $e) {
     }
     /**
      * settings table
      */
     if (!\Schema::hasTable('configurations')) {
         \Schema::create('configurations', function (Blueprint $table) {
             $table->increments('id');
             $table->string('slug');
             $table->text('value');
             $table->timestamps();
         });
     }
     try {
         //@\DB::statement("ALTER TABLE configurations ADD INDEX `id`(`id`)");
         @\DB::statement("ALTER TABLE configurations ADD INDEX `slug`(`slug`)");
     } catch (\Exception $e) {
     }
     //update some configurations
     app('App\\Repositories\\ConfigurationRepository')->save(['enable-bigpipe' => 0]);
     app('App\\Repositories\\ConfigurationRepository')->save(['ajaxify_frontend' => 0]);
     app('App\\Repositories\\ConfigurationRepository')->save(['enable-realtime-activity' => 0]);
     app('App\\Repositories\\ConfigurationRepository')->save(['allow-files-types' => 'exe,txt,zip,rar,doc,mp3,jpg,png,css,psd,pdf,ppt,pptx,xls,xlsx,html,docx,fla,avi,mp4']);
     //let remove any php file already uploaded to the size
     $basePath = base_path('uploads/files/');
     if (is_dir($basePath)) {
         $fileSystem = app('files');
         $files = $fileSystem->allFiles($basePath);
         foreach ($files as $file) {
             $ext = $ext = pathinfo($file, PATHINFO_EXTENSION);
             if (strtolower($ext) == 'exe') {
                 @unlink($file);
             }
         }
     }
     /**
      * Languages table
      */
     if (!\Schema::hasTable('languages')) {
         \Schema::create("languages", function (Blueprint $table) {
             $table->increments('id');
             $table->string('var');
             $table->string("name");
             $table->integer('active')->default(0);
             $table->timestamps();
         });
         \DB::table('languages')->insert(['var' => 'en', 'name' => 'English Language', 'active' => 1]);
     }
     /**
      * User tables
      */
     if (!\Schema::hasTable('users')) {
         \Schema::create('users', function (Blueprint $table) {
             $table->increments('id');
             $table->string('fullname');
             $table->string('username');
             $table->string('email_address');
             $table->string('password');
             $table->string('genre')->default('male');
             $table->text('bio')->nullable();
             $table->text('profile_details')->nullable();
             $table->text('privacy_info')->nullable();
             $table->text('design_info')->nullable();
             $table->text('cover')->nullable();
             $table->string('country')->nullable();
             $table->integer('fully_started')->default(0);
             $table->text('avatar')->nullable();
             $table->string('auth')->default('');
             $table->string('auth_id')->default('');
             $table->integer('verified')->default(0);
             $table->integer('admin')->default(0);
             $table->integer('active')->default(0);
             $table->integer('activated')->default(0);
             $table->string('hash', 300)->default('');
             $table->string('remember_token', 300)->default('');
             $table->integer('last_active_time')->nullable();
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE users ADD INDEX `fullname`(`fullname`)");
         @\DB::statement("ALTER TABLE users ADD INDEX `username`(`username`)");
         @\DB::statement("ALTER TABLE users ADD INDEX `email_address`(`email_address`)");
         @\DB::statement("ALTER TABLE users ADD INDEX `genre`(`genre`)");
         @\DB::statement("ALTER TABLE users ADD INDEX `password`(`password`)");
         @\DB::statement("ALTER TABLE users ADD INDEX `country`(`country`)");
         @\DB::statement("ALTER TABLE users ADD INDEX `last_active_time`(`last_active_time`)");
     } catch (\Exception $e) {
     }
     /**custom fields***/
     if (!\Schema::hasTable('custom_fields')) {
         \Schema::create('custom_fields', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->text('description');
             $table->string('field_type')->default('text');
             $table->string('type')->default('profile');
             $table->text('data')->nullable();
             $table->timestamps();
         });
     }
     //help add some fields to the site
     $this->addCustomFields();
     /**Post table**/
     if (!\Schema::hasTable('posts')) {
         \Schema::create('posts', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->integer('to_user_id')->nullable();
             $table->text('text')->nullable();
             $table->text('content_type')->nullable();
             $table->text('type_content')->nullable();
             $table->text('type')->nullable();
             $table->string('type_id')->default('');
             $table->integer('community_id')->nullable();
             $table->integer('page_id')->nullable();
             $table->text('link')->nullable();
             $table->text('tags')->nullable();
             $table->integer('privacy')->default(1);
             $table->integer('shared')->nullable();
             $table->integer('shared_id')->nullable();
             $table->integer('shared_from')->nullable();
             $table->integer('shared_count')->nullable();
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE posts ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `to_user_id`(`to_user_id`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `content_type`(`content_type`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `type`(`type`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `type_id`(`type_id`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `community_id`(`community_id`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `page_id`(`page_id`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `privacy`(`privacy`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `created_at`(`created_at`)");
         @\DB::statement("ALTER TABLE posts ADD INDEX `updated_at`(`updated_at`)");
     } catch (\Exception $e) {
     }
     /***coments***/
     if (!\Schema::hasTable('comments')) {
         \Schema::create('comments', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->text('text');
             $table->string('type');
             $table->string('type_id');
             $table->text('img_path')->nullable();
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE comments ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE comments ADD INDEX `type`(`type`)");
         @\DB::statement("ALTER TABLE comments ADD INDEX `type_id`(`type_id`)");
         @\DB::statement("ALTER TABLE comments ADD INDEX `created_at`(`created_at`)");
     } catch (\Exception $e) {
     }
     /***likes table**/
     if (!\Schema::hasTable('likes')) {
         \Schema::create('likes', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->string('type');
             $table->integer('type_id');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE likes ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE likes ADD INDEX `type`(`type`)");
         @\DB::statement("ALTER TABLE likes ADD INDEX `type_id`(`type_id`)");
     } catch (\Exception $e) {
     }
     /**connection table**/
     if (!\Schema::hasTable('connections')) {
         \Schema::create('connections', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->integer('to_user_id');
             $table->integer('way')->default(2);
             $table->integer('confirmed')->default(0);
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE connections ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE connections ADD INDEX `to_user_id`(`to_user_id`)");
         @\DB::statement("ALTER TABLE connections ADD INDEX `way`(`way`)");
     } catch (\Exception $e) {
     }
     /**Notification table**/
     if (!\Schema::hasTable('notifications')) {
         \Schema::create('notifications', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->integer('to_user_id');
             $table->text('title')->nullable();
             $table->text('content')->nullable();
             $table->text('data')->nullable();
             $table->integer('seen')->default(0);
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE notifications ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE notifications ADD INDEX `to_user_id`(`to_user_id`)");
     } catch (\Exception $e) {
     }
     /**Blocked users**/
     if (!\Schema::hasTable('blocked_users')) {
         \Schema::create('blocked_users', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->integer('block_id');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE blocked_users ADD INDEX `user_id`(`user_id`)");
     } catch (\Exception $e) {
     }
     /**User get notifications table**/
     if (!\Schema::hasTable('notification_receivers')) {
         \Schema::create('notification_receivers', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->string('type');
             $table->integer('type_id');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE notification_receivers ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE notification_receivers ADD INDEX `type`(`type`)");
         @\DB::statement("ALTER TABLE notification_receivers ADD INDEX `type_id`(`type_id`)");
     } catch (\Exception $e) {
     }
     /**Hashtags table**/
     if (!\Schema::hasTable('hashtags')) {
         \Schema::create('hashtags', function (Blueprint $table) {
             $table->increments('id');
             $table->string('hash');
             $table->integer('count');
             $table->timestamps();
         });
     }
     /**Reports table**/
     if (!\Schema::hasTable('reports')) {
         \Schema::create('reports', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->text('url');
             $table->string('type');
             $table->text('reason');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE reports ADD INDEX `type`(`type`)");
     } catch (\Exception $e) {
     }
     /**Additional pages table***/
     if (!\Schema::hasTable('additional_pages')) {
         \Schema::create('additional_pages', function (Blueprint $table) {
             $table->increments('id');
             $table->string('slug');
             $table->string('title');
             $table->text('content');
             $table->timestamps();
         });
     }
     $this->addAdditionalPages();
     /**Help system***/
     if (!\Schema::hasTable('helps')) {
         \Schema::create('helps', function (Blueprint $table) {
             $table->increments('id');
             $table->string('title');
             $table->string('slug');
             $table->text('content');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE helps ADD INDEX `slug`(`slug`)");
     } catch (\Exception $e) {
     }
     $this->addHelps();
     /***Communities***/
     if (!\Schema::hasTable('communities')) {
         \Schema::create('communities', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->string('title');
             $table->string('slug');
             $table->text('description')->nullable();
             $table->text('info')->nullable();
             $table->text('moderators')->nullable();
             $table->integer('privacy')->default(0);
             $table->integer('can_join')->default(1);
             $table->integer('can_post')->default(1);
             $table->integer('can_invite')->default(1);
             //$table->integer('can_create_category');
             $table->integer('searchable')->default(1);
             $table->string('logo')->nullable();
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE communities ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE communities ADD INDEX `slug`(`slug`)");
         @\DB::statement("ALTER TABLE communities ADD INDEX `created_at`(`created_at`)");
         @\DB::statement("ALTER TABLE communities ADD INDEX `privacy`(`privacy`)");
         @\DB::statement("ALTER TABLE communities ADD INDEX `searchable`(`searchable`)");
     } catch (\Exception $e) {
     }
     //communities members
     if (!\Schema::hasTable('community_members')) {
         \Schema::create('community_members', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('community_id');
             $table->integer('user_id');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE community_members ADD INDEX `community_id`(`community_id`)");
     } catch (\Exception $e) {
     }
     //community categories
     if (!\Schema::hasTable('community_categories')) {
         \Schema::create('community_categories', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('community_id');
             $table->string('title');
             $table->string('slug');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE community_categories ADD INDEX `community_id`(`community_id`)");
         @\DB::statement("ALTER TABLE community_categories ADD INDEX `slug`(`slug`)");
     } catch (\Exception $e) {
     }
     //invited members
     if (!\Schema::hasTable('invited_members')) {
         \Schema::create('invited_members', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->integer('type_id');
             $table->string('type');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE invited_members ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE invited_members ADD INDEX `type_id`(`type_id`)");
         @\DB::statement("ALTER TABLE invited_members ADD INDEX `type`(`type`)");
     } catch (\Exception $e) {
     }
     //photos
     if (!\Schema::hasTable('photos')) {
         \schema::create('photos', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->string('slug');
             $table->string('path');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE photos ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE photos ADD INDEX `slug`(`slug`)");
         @\DB::statement("ALTER TABLE photos ADD INDEX `path`(`path`)");
     } catch (\Exception $e) {
     }
     if (!\Schema::hasTable('photo_albums')) {
         \Schema::create('photo_albums', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->string('title');
             $table->string('slug');
             $table->string('default_photo')->nullable();
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE photo_albums ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE photo_albums ADD INDEX `slug`(`slug`)");
     } catch (\Exception $e) {
     }
     //pages
     if (!\Schema::hasTable('pages')) {
         \Schema::create('pages', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->integer('category_id');
             $table->string('title');
             $table->string('slug');
             $table->string('description')->nullable();
             $table->text('info')->nullable();
             $table->string('website')->nullable();
             $table->string('logo')->nullable();
             $table->string('cover')->nullable();
             $table->integer('verified')->default(0);
             //$table->integer('can_post')->default(0);
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE pages ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE pages ADD INDEX `slug`(`slug`)");
         @\DB::statement("ALTER TABLE pages ADD INDEX `title`(`title`)");
         @\DB::statement("ALTER TABLE pages ADD INDEX `description`(`description`)");
     } catch (\Exception $e) {
     }
     if (!\Schema::hasTable('page_categories')) {
         \Schema::create('page_categories', function (Blueprint $table) {
             $table->increments('id');
             $table->string('title');
             $table->string('slug');
             $table->string('description');
             $table->timestamps();
         });
     }
     $this->addPagesCategories();
     //message table
     if (!\Schema::hasTable('messages')) {
         \Schema::create('messages', function (Blueprint $table) {
             $table->increments('id');
             $table->text('text');
             $table->integer('sender');
             $table->integer('receiver');
             $table->string('image')->nullable();
             $table->integer('conversation_id');
             $table->integer('sender_status')->default(0);
             $table->integer('receiver_status')->default(0);
             $table->integer('seen')->default(0);
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE messages ADD INDEX `sender`(`sender`)");
         @\DB::statement("ALTER TABLE message ADD INDEX `receiver`(`receiver`)");
         @\DB::statement("ALTER TABLE messages ADD INDEX `conversation_id`(`conversation_id`)");
         @\DB::statement("ALTER TABLE messages ADD INDEX `sender_status`(`sender_status`)");
         @\DB::statement("ALTER TABLE messages ADD INDEX `receiver_status`(`receiver_status`)");
         @\DB::statement("ALTER TABLE messages ADD INDEX `seen`(`seen`)");
         @\DB::statement("ALTER TABLE messages ADD INDEX `created_at`(`created_at`)");
     } catch (\Exception $e) {
     }
     if (!\Schema::hasTable('message_conversation')) {
         \Schema::create('message_conversation', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user1');
             $table->integer('user2');
             $table->timestamps();
         });
     }
     //newsletter
     if (!\Schema::hasTable('newsletters')) {
         \Schema::create('newsletters', function (Blueprint $table) {
             $table->increments('id');
             $table->string('subject');
             $table->text('content');
             $table->string('to');
             $table->timestamps();
         });
     }
     //v1.3
     if (!\Schema::hasTable('post_hide')) {
         \Schema::create('post_hide', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('post_id');
             $table->integer('user_id');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE post_hide ADD INDEX `user_id`(`user_id`)");
         @\DB::statement("ALTER TABLE post_hide ADD INDEX `post_id`(`post_id`)");
     } catch (\Exception $e) {
     }
     //v1.4
     if (!\Schema::hasTable('page_admins')) {
         \Schema::create('page_admins', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('page_id');
             $table->integer('user_id');
             $table->string('type');
             $table->integer('approved')->default(0);
             $table->timestamps();
         });
     }
     //v3.0
     if (!\Schema::hasTable('must_avoid_users')) {
         \Schema::create('must_avoid_users', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id');
             $table->timestamps();
         });
     }
     try {
         @\DB::statement("ALTER TABLE must_avoid_users ADD INDEX `user_id`(`user_id`)");
     } catch (\Exception $e) {
     }
     //run updates for database
     $this->runUpdate();
 }