本文整理汇总了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');
}
示例2: run
public function run()
{
DB::table('tags')->delete();
Tag::create(array('name' => 'spring'));
Tag::create(array('name' => 'summer'));
Tag::create(array('name' => 'apple'));
}
示例3: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Tag::create(['name' => $faker->word]);
}
}
示例4: generate
private function generate()
{
$tags = array('auth' => 'auth', 'eloquent' => 'eloquent');
foreach ($tags as $name => $slug) {
Tag::create(array('name' => $name, 'slug' => $slug));
}
}
示例5: run
public function run()
{
$tags = array_values(Lang::get('tags'));
foreach ($tags as $tag) {
Tag::create(array('name' => $tag));
}
}
示例6: run
public function run()
{
DB::table('tags')->delete();
Tag::create(['name' => 'Announcements']);
Tag::create(['name' => 'Engineering']);
Tag::create(['name' => 'Features']);
}
示例7: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Tag::create(['title' => $faker->firstname()]);
}
}
示例8: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Tag::create([]);
}
}
示例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);
}
};
}
示例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));
}
示例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();
}
示例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);
}
}
示例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);
}
示例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');
}
示例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));
}
}