當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。