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


PHP Slug::setForObject方法代码示例

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


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

示例1: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table(DB_OBJECTS, function ($table) {
         $table->string('url')->nullable();
     });
     DB::table(DB_FIELDS)->where('name', 'slug')->delete();
     //add slug column to all tables that don't have it
     $objects = DB::table(DB_OBJECTS)->get();
     foreach ($objects as $object) {
         //add slug column
         if (Schema::hasColumn($object->name, 'slug')) {
             DB::table($object->name)->whereNull('slug')->update(['slug' => '']);
             DB::update('ALTER TABLE `' . $object->name . '` MODIFY `slug` VARCHAR(255) NOT NULL');
             Schema::table($object->name, function ($table) {
                 //$table->unique('slug');
             });
         } else {
             Schema::table($object->name, function ($table) {
                 $table->string('slug');
                 //->unique();
             });
             //set slug values
             Slug::setForObject($object);
         }
         //add created_by column, not sure why this wasn't added earlier
         if (!Schema::hasColumn($object->name, 'created_by')) {
             Schema::table($object->name, function ($table) {
                 $table->integer('created_by');
             });
         }
     }
 }
开发者ID:joshreisner,项目名称:avalon,代码行数:37,代码来源:2015_01_17_214846_objects_url.php

示例2: array

 Route::get('/', array('as' => 'home', 'uses' => 'ObjectController@index'));
 Route::get('/logout', 'LoginController@getLogout');
 Route::post('/upload/image', 'FileController@image');
 # Test routes
 Route::get('/schema/save', 'ObjectController@saveSchema');
 Route::get('/schema/load', 'ObjectController@loadSchema');
 Route::get('/image/test', 'FileController@test');
 Route::get('/slug/test', function () {
     $phrases = ['', 'and', 'this is a normal test', 'this is a really really really long test because it\'s amazing and great and am i at 50 YET???'];
     foreach ($phrases as $phrase) {
         echo '<p>' . $phrase . ' becomes <em>' . Slug::make($phrase, ['', 'normal-test', 'normal-test-1']) . '</em></p>';
     }
 });
 Route::get('/slug/object/{object_id}', function ($object_id) {
     $object = DB::table(DB_OBJECTS)->find($object_id);
     Slug::setForObject($object);
     die('object was ' . $object->name);
 });
 Route::get('cleanup', function () {
     FieldController::cleanup();
     FileController::findOrphans();
     FileController::cleanup();
 });
 # Complex instance routing, optionally with linked_id for related objects
 Route::get('/{object_name}/delete/{instance_id}', 'InstanceController@delete');
 Route::get('/{object_name}', 'InstanceController@index');
 Route::get('/{object_name}/export', 'InstanceController@export');
 Route::get('/{object_name}/create/{linked_id?}', 'InstanceController@create');
 Route::post('/{object_name}/reorder', 'InstanceController@reorder');
 Route::post('/{object_name}/{linked_id?}', 'InstanceController@store');
 Route::get('/{object_name}/{instance_id}/{linked_id?}', 'InstanceController@edit');
开发者ID:joshreisner,项目名称:avalon,代码行数:31,代码来源:routes.php


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