當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tag::create方法代碼示例

本文整理匯總了PHP中Tag::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tag::create方法的具體用法?PHP Tag::create怎麽用?PHP Tag::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tag的用法示例。


在下文中一共展示了Tag::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_should_bind_sql_bind_in_using_active_records

 public function test_should_bind_sql_bind_in_using_active_records()
 {
     $Tag = new Tag();
     $Tag->create(array('name' => 'Tag 1'));
     $Tag->create(array('name' => 'Tag 2'));
     $this->assertTrue($Tags = $Tag->find(array('conditions' => array('name IN (?)', $Tag->find()))));
     $this->assertEqual($Tags[0]->name, 'Tag 1');
     $this->assertEqual($Tags[1]->name, 'Tag 2');
 }
開發者ID:joeymetal,項目名稱:v1,代碼行數:9,代碼來源:_AkActiveRecord_finders.php

示例2: run

 public function run()
 {
     DB::table('tags')->delete();
     Tag::create(array('name' => 'spring'));
     Tag::create(array('name' => 'summer'));
     Tag::create(array('name' => 'apple'));
 }
開發者ID:ahumellihuk,項目名稱:blogging-platform,代碼行數:7,代碼來源:TagTableSeeder.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Tag::create(['name' => $faker->word]);
     }
 }
開發者ID:rudihartomo,項目名稱:Laravel-RestAPI,代碼行數:7,代碼來源:TagsTableSeeder.php

示例4: generate

 private function generate()
 {
     $tags = array('auth' => 'auth', 'eloquent' => 'eloquent');
     foreach ($tags as $name => $slug) {
         Tag::create(array('name' => $name, 'slug' => $slug));
     }
 }
開發者ID:kcsamita,項目名稱:laravelsnippets,代碼行數:7,代碼來源:TagSeeder.php

示例5: run

 public function run()
 {
     $tags = array_values(Lang::get('tags'));
     foreach ($tags as $tag) {
         Tag::create(array('name' => $tag));
     }
 }
開發者ID:wcoder,項目名稱:basont,代碼行數:7,代碼來源:TagsSeeder.php

示例6: run

 public function run()
 {
     DB::table('tags')->delete();
     Tag::create(['name' => 'Announcements']);
     Tag::create(['name' => 'Engineering']);
     Tag::create(['name' => 'Features']);
 }
開發者ID:pogliozzy,項目名稱:larabase,代碼行數:7,代碼來源:TagsTableSeeder.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Tag::create(['title' => $faker->firstname()]);
     }
 }
開發者ID:ayooby,項目名稱:whatisit,代碼行數:7,代碼來源:TagsTableSeeder.php

示例8: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Tag::create([]);
     }
 }
開發者ID:SunRey,項目名稱:blog.dev,代碼行數:7,代碼來源:TagsTableSeeder.php

示例9: createComponentPageEditForm

 protected function createComponentPageEditForm($name)
 {
     $form = $this->createPageFormBase($name, false);
     if (!$form->isSubmitted()) {
         $id = $this->getParam("id");
         $page = Page::find($id);
         $values = $page->getValues();
         $values["tags"] = $page->Tags->fetchColumn("id");
         $form->setDefaults($values);
     }
     $presenter = $this;
     $form->onSubmit[] = function ($form) use($presenter) {
         $values = $form->values;
         try {
             $page = Page::create($values);
             $page->Tags = array_map(function ($id) {
                 return Tag::create($id);
             }, $values["tags"]);
             $page->save();
             $presenter->flashMessage("Page '{$page->name}' was changed!");
             $presenter->redirect("default", array("id" => $page->id));
         } catch (ModelException $e) {
             $page->addErrorsToForm($form);
         }
     };
 }
開發者ID:janmarek,項目名稱:Ormion,代碼行數:26,代碼來源:PagePresenter.php

示例10: testNewRecordWithNewReferenced

 public function testNewRecordWithNewReferenced()
 {
     $page = Page::create(array("name" => "English article", "description" => "Description", "text" => "Text in english.", "allowed" => true));
     $page->Tags[] = Tag::create(array("name" => "Society", "url" => "society"));
     $page->Tags[] = Tag::create(array("name" => "Previte", "url" => "previte"));
     $page->save();
     $this->assertEquals(2, count(Page::findByName("English article")->Tags));
 }
開發者ID:janmarek,項目名稱:Ormion,代碼行數:8,代碼來源:ManyToManyTest.php

示例11: test_create_tag

 public function test_create_tag()
 {
     $t = Tag::create(array('tag_text' => $this->text, 'tag_slug' => $this->slug));
     $this->assertType('Tag', $t);
     $this->assertEquals($t->tag_slug, $this->slug);
     $this->assertEquals($t->tag_text, $this->text);
     $t->delete();
 }
開發者ID:psaintlaurent,項目名稱:Habari,代碼行數:8,代碼來源:tagTest.php

示例12: run

 public function run()
 {
     $tags = array('Winning', 'Bi-Winning', 'Win Here', 'Win There', 'Win Win Everywhere', 'Can\'t Stop', 'Won\'t Stop', 'Feel Like Losing', 'Party Hard', 'Relationships', 'Travel', 'Charlie Sheen');
     foreach ($tags as $tag) {
         $name = array('name' => $tag);
         Tag::create($name);
     }
 }
開發者ID:j-beere,項目名稱:laravel-blog,代碼行數:8,代碼來源:TagTableSeeder.php

示例13: store

 /**
  * Store a newly created tag in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Tag::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Tag::create($data);
 }
開發者ID:mkwarren21,項目名稱:blog.dev,代碼行數:13,代碼來源:TagsController.php

示例14: store

 /**
  * Store a newly created tag in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Tag::validate($data = Input::all());
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Tag::create($data);
     return Redirect::route('admin.tags.index');
 }
開發者ID:pogliozzy,項目名稱:larabase,代碼行數:14,代碼來源:TagsController.php

示例15: run

 public function run()
 {
     Tag::truncate();
     $template = 'app/views/admin/template.blade.php';
     $info = file_get_contents($template);
     $values = array('Phone', 'Tablet', 'Laptop', 'Accessories');
     foreach ($values as $value) {
         Tag::create(array('name' => $value, 'slug' => Str::slug($value), 'template' => $info, 'block' => 0));
     }
 }
開發者ID:VoDongMy,項目名稱:VoDongMy,代碼行數:10,代碼來源:TagSeeder.php


注:本文中的Tag::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。