当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::hasTable方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Schema::hasTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::hasTable方法的具体用法?PHP Schema::hasTable怎么用?PHP Schema::hasTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Schema的用法示例。


在下文中一共展示了Schema::hasTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if (Schema::hasTable('categories')) {
         $categories = Category::getAllFromCache();
         view()->share('categories', $categories);
     }
 }
开发者ID:mikolajszczepanski,项目名称:NuPtr,代码行数:12,代码来源:CategoryServiceProvider.php

示例2: schedule

 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     if (Schema::hasTable('migrations') && Schema::hasTable('users')) {
         $banned = User::banned()->get();
         $all = User::all();
         $schedule->call(function () use($banned) {
             foreach ($banned as $u) {
                 if ($u->banned_until != null) {
                     if ($u->banned_until < Carbon::now()->toDateTimeString()) {
                         $u->update(array('is_banned' => 0, 'banned_until' => null));
                     }
                 }
             }
         })->when(function () use($banned) {
             return $banned->count() > 0;
         })->cron('* * * * *');
         $schedule->call(function () use($all) {
             $now = Carbon::now();
             $now->subMinutes(15);
             // A user is offline if they do nothing for 15 minutes
             foreach ($all as $u) {
                 if ($u->last_active != null && $u->last_active < $now->toDateTimeString()) {
                     $u->update(array('is_online' => 0));
                 }
             }
         })->when(function () use($all) {
             return $all->count() > 0;
         })->cron('* * * * *');
     }
 }
开发者ID:fetch404,项目名称:fetch404,代码行数:36,代码来源:Kernel.php

示例3: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!DbSchema::hasTable('jobs')) {
         DbSchema::create('jobs', function (Blueprint $table) {
             $table->bigIncrements('id');
             $table->string('queue');
             $table->longText('payload');
             $table->tinyInteger('attempts')->unsigned();
             $table->tinyInteger('reserved')->unsigned();
             $table->unsignedInteger('reserved_at')->nullable();
             $table->unsignedInteger('available_at');
             $table->unsignedInteger('created_at');
             $table->index(['queue', 'reserved', 'reserved_at']);
         });
     }
     if (!DbSchema::hasTable('failed_jobs')) {
         DbSchema::create('failed_jobs', function (Blueprint $table) {
             $table->increments('id');
             $table->text('connection');
             $table->text('queue');
             $table->longText('payload');
             $table->timestamp('failed_at');
         });
     }
 }
开发者ID:microweber,项目名称:microweber,代码行数:30,代码来源:JobsQueue.php

示例4: setSource

 protected function setSource($source)
 {
     if ($source instanceof EloquentBuilder) {
         return $this->source = new Source\SEloquentBuilder($this, $source);
     }
     if ($source instanceof QueryBuilder) {
         return $this->source = new Source\SQueryBuilder($this, $source);
     }
     if ($source instanceof Model) {
         return $this->source = $source->exists ? new Source\SCollection($this, with(new Collection())->push($source)) : new Source\SModel($this, $source);
     }
     if ($source instanceof Collection) {
         return $this->source = new Source\SCollection($this, $source);
     }
     if ($source instanceof ArrayObject) {
         return $this->source = new Source\SArrayObject($this, $source);
     }
     if (is_array($source)) {
         return $this->source = new Source\SArray($this, $source);
     }
     if (is_string($source) && Schema::hasTable($source)) {
         return $this->source = new Source\SDb($this, $source);
     }
     throw new DataSetException(' "source" must be a table name, an eloquent model or an eloquent builder. you passed: ' . get_class($this->source));
 }
开发者ID:jooorooo,项目名称:LaraGrid,代码行数:25,代码来源:DataSource.php

示例5: getPermissions

 private function getPermissions()
 {
     if (!Schema::hasTable('permissions')) {
         return [];
     }
     return Permission::with('roles')->get();
 }
开发者ID:antonioribeiro,项目名称:veveystore,代码行数:7,代码来源:AuthServiceProvider.php

示例6: test_tables_exist

 /**
  * Ensures the migrations ran and tables exist in the database.
  */
 public function test_tables_exist()
 {
     $expectedTables = ['users', 'password_resets', 'email_addresses', 'phone_numbers', 'addresses'];
     foreach ($expectedTables as $table) {
         $this->assertTrue(Schema::hasTable($table));
     }
 }
开发者ID:autocar,项目名称:contactable,代码行数:10,代码来源:DatabaseTables.php

示例7: test_tables_exist

 /**
  * Ensures the migrations ran and tables exist in the database.
  */
 public function test_tables_exist()
 {
     $expectedTables = ['pages'];
     foreach ($expectedTables as $table) {
         $this->assertTrue(Schema::hasTable($table));
     }
 }
开发者ID:sasin91,项目名称:laravel-pages,代码行数:10,代码来源:DatabaseTables.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  Request    $request
  * @param  Closure    $next
  * @return mixed
  * @throws \Exception
  */
 public function handle($request, Closure $next)
 {
     if (!file_exists(base_path('.env')) || !Schema::hasTable('users')) {
         throw new \Exception('Asgard is not yet installed');
     }
     return $next($request);
 }
开发者ID:Houbsi,项目名称:Core,代码行数:15,代码来源:AsgardInstalledMiddleware.php

示例9: show

 public function show()
 {
     if (Schema::hasTable('migrations')) {
         return redirect(route('home.show'));
     }
     return view('core.installer.index');
 }
开发者ID:fetch404,项目名称:fetch404,代码行数:7,代码来源:InstallController.php

示例10: schedule

 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule $schedule
  *
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     // Check that the schedules table exists. This
     // could cause a fatal error if the app is
     // still being setup or the db has not yet
     // been configured. This is a relatively ugly
     // hack as this schedule() method is core to
     // the framework.
     try {
         DB::connection();
         if (!Schema::hasTable('schedules')) {
             throw new Exception('Schema schedules does not exist');
         }
     } catch (Exception $e) {
         return;
     }
     // Load the schedule from the database
     foreach (DbSchedule::all() as $job) {
         $command = $schedule->command($job['command'])->cron($job['expression']);
         // Check if overlapping is allowed
         if (!$job['allow_overlap']) {
             $command = $command->withoutOverlapping();
         }
         // Check if maintenance mode is allowed
         if ($job['allow_maintenance']) {
             $command = $command->evenInMaintenanceMode();
         }
         if ($job['ping_before']) {
             $command = $command->pingBefore($job['ping_before']);
         }
         if ($job['ping_after']) {
             $command->thenPing($job['ping_after']);
         }
     }
 }
开发者ID:eveseat,项目名称:seat,代码行数:42,代码来源:Kernel.php

示例11:

 function __construct($table, $primaryKey, $meta_key = 'iid', $fields = [])
 {
     parent::__construct($table, $primaryKey, $meta_key, $fields);
     if (!Schema::hasTable($this->table())) {
         $this->build();
     }
 }
开发者ID:kyleing,项目名称:laravel-tool,代码行数:7,代码来源:MetaTableOperator.php

示例12: 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

示例13: getDatabaseConfig

 /**
  * @return array
  */
 public function getDatabaseConfig()
 {
     if (Schema::hasTable('options')) {
         $table = $this->app['db']->table('options');
         return $this->changeConfigWithHelpers($table->where('type', 'config')->lists('value', 'key'));
     }
 }
开发者ID:jayaregalinada,项目名称:common,代码行数:10,代码来源:OptionServiceProvider.php

示例14: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     if (!isset(self::$app)) {
         self::$app = AppFactory::create();
     }
     if (!Schema::hasTable('users')) {
         Schema::create('users', function ($table) {
             $table->increments('id');
             $table->string('name');
         });
     }
     DB::insert('insert into users (name) values (?)', array('Test User'));
     if (!Schema::hasTable('posts')) {
         Schema::create('posts', function ($table) {
             $table->increments('id');
             $table->string('title');
             $table->integer('created_by')->unsigned()->nullable();
             $table->integer('updated_by')->unsigned()->nullable();
             $table->integer('deleted_by')->unsigned()->nullable();
             $table->timestamps();
             $table->timestamp('deleted_at')->nullable();
             $table->foreign('created_by')->references('id')->on('users');
             $table->foreign('updated_by')->references('id')->on('users');
             $table->foreign('deleted_by')->references('id')->on('users');
         });
     }
 }
开发者ID:nstapelbroek,项目名称:culpa-laravel-5,代码行数:27,代码来源:CulpaTest.php

示例15: getPermissions

 /**
  * Fetch the collection of site permissions.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function getPermissions()
 {
     if (!Schema::hasTable('roles')) {
         return new Collection();
     }
     return Permission::with('roles')->get();
 }
开发者ID:papertank,项目名称:origami-auth,代码行数:12,代码来源:AuthServiceProvider.php


注:本文中的Illuminate\Support\Facades\Schema::hasTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。