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


PHP Tag::create方法代碼示例

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


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

示例1: store

 /**
  * Store a newly created Tag in storage.
  *
  * @param CreateTagRequest $request
  *
  * @return Response
  */
 public function store(CreateTagRequest $request)
 {
     $input = $request->all();
     $tag = Tag::create($input);
     Flash::message('Tag saved successfully.');
     return redirect(route('admin.tags.index'));
 }
開發者ID:jclyons52,項目名稱:mycourse-rocks,代碼行數:14,代碼來源:AdminTagController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         \App\Models\Tag::create(['name' => $faker->word]);
     }
 }
開發者ID:nbinkunwar,項目名稱:laravel5_rest,代碼行數:12,代碼來源:TagsTableSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         $tag = Tag::create(['name' => $faker->domainWord]);
         $tag->save();
     }
 }
開發者ID:katzumi,項目名稱:talent4startups,代碼行數:13,代碼來源:TagTableSeeder.php

示例4: create

 public function create()
 {
     $user = $this->auth();
     $data = Input::get();
     $data['userId'] = $user->_id;
     $result = Tag::create($data);
     return $this->output($result->_id);
 }
開發者ID:guodong,項目名稱:wish-api,代碼行數:8,代碼來源:TagController.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tags')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 30; $i++) {
         Tag::create(['name' => $faker->unique()->word]);
     }
 }
開發者ID:byhbt,項目名稱:laravel-skeleton,代碼行數:13,代碼來源:TagTableSeeder.php

示例6: run

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Model::unguard();
        $lipsum = new LoremIpsumGenerator();
        Role::create(['title' => 'Administrator', 'slug' => 'admin']);
        Role::create(['title' => 'Redactor', 'slug' => 'redac']);
        Role::create(['title' => 'User', 'slug' => 'user']);
        User::create(['username' => 'GreatAdmin', 'email' => 'fathir.irhas@outlook.com', 'password' => bcrypt('admin'), 'seen' => true, 'role_id' => 1, 'confirmed' => true]);
        User::create(['username' => 'GreatRedactor', 'email' => 'fatheer.eerhas@gmail.com', 'password' => bcrypt('redac'), 'seen' => true, 'role_id' => 2, 'valid' => true, 'confirmed' => true]);
        User::create(['username' => 'Walker', 'email' => 'fathir139@yahoo.co.id', 'password' => bcrypt('walker'), 'role_id' => 3, 'confirmed' => true]);
        User::create(['username' => 'Slacker', 'email' => 'slacker@la.fr', 'password' => bcrypt('slacker'), 'role_id' => 3, 'confirmed' => true]);
        Contact::create(['name' => 'Dupont', 'email' => 'dupont@la.fr', 'text' => 'Lorem ipsum inceptos malesuada leo fusce tortor sociosqu semper, facilisis semper class tempus faucibus tristique duis eros, cubilia quisque habitasse aliquam fringilla orci non. Vel laoreet dolor enim justo facilisis neque accumsan, in ad venenatis hac per dictumst nulla ligula, donec mollis massa porttitor ullamcorper risus. Eu platea fringilla, habitasse.']);
        Contact::create(['name' => 'Durand', 'email' => 'durand@la.fr', 'text' => ' Lorem ipsum erat non elit ultrices placerat, netus metus feugiat non conubia fusce porttitor, sociosqu diam commodo metus in. Himenaeos vitae aptent consequat luctus purus eleifend enim, sollicitudin eleifend porta malesuada ac class conubia, condimentum mauris facilisis conubia quis scelerisque. Lacinia tempus nullam felis fusce ac potenti netus ornare semper molestie, iaculis fermentum ornare curabitur tincidunt imperdiet scelerisque imperdiet euismod.']);
        Contact::create(['name' => 'Martin', 'email' => 'martin@la.fr', 'text' => 'Lorem ipsum tempor netus aenean ligula habitant vehicula tempor ultrices, placerat sociosqu ultrices consectetur ullamcorper tincidunt quisque tellus, ante nostra euismod nec suspendisse sem curabitur elit. Malesuada lacus viverra sagittis sit ornare orci, augue nullam adipiscing pulvinar libero aliquam vestibulum, platea cursus pellentesque leo dui. Lectus curabitur euismod ad, erat.', 'seen' => true]);
        Tag::create(['tag' => 'Tag1']);
        Tag::create(['tag' => 'Tag2']);
        Tag::create(['tag' => 'Tag3']);
        Tag::create(['tag' => 'Tag4']);
        Post::create(['title' => 'Post 1', 'slug' => 'post-1', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/mega-champignon.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 1]);
        Post::create(['title' => 'Post 2', 'slug' => 'post-2', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/goomba.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => '<p>Lorem ipsum convallis ac curae non elit ultrices placerat netus metus feugiat, non conubia fusce porttitor sociosqu diam commodo metus in himenaeos, vitae aptent consequat luctus purus eleifend enim sollicitudin eleifend porta. Malesuada ac class conubia condimentum mauris facilisis conubia quis scelerisque lacinia, tempus nullam felis fusce ac potenti netus ornare semper. Molestie iaculis fermentum ornare curabitur tincidunt imperdiet scelerisque, imperdiet euismod scelerisque torquent curae rhoncus, sollicitudin tortor placerat aptent hac nec. Posuere suscipit sed tortor neque urna hendrerit vehicula duis litora tristique congue nec auctor felis libero, ornare habitasse nec elit felis inceptos tellus inceptos cubilia quis mattis faucibus sem non.</p>

<p>Odio fringilla class aliquam metus ipsum lorem luctus pharetra dictum, vehicula tempus in venenatis gravida ut gravida proin orci, quis sed platea mi quisque hendrerit semper hendrerit. Facilisis ante sapien faucibus ligula commodo vestibulum rutrum pretium, varius sem aliquet himenaeos dolor cursus nunc habitasse, aliquam ut curabitur ipsum luctus ut rutrum. Odio condimentum donec suscipit molestie est etiam sit rutrum dui nostra, sem aliquet conubia nullam sollicitudin rhoncus venenatis vivamus rhoncus netus, risus tortor non mauris turpis eget integer nibh dolor. Commodo venenatis ut molestie semper adipiscing amet cras, class donec sapien malesuada auctor sapien arcu inceptos, aenean consequat metus litora mattis vivamus.</p>

<pre>
<code class="language-php">protected function getUserByRecaller($recaller)
{
	if ($this-&gt;validRecaller($recaller) &amp;&amp; ! $this-&gt;tokenRetrievalAttempted)
	{
		$this-&gt;tokenRetrievalAttempted = true;

		list($id, $token) = explode("|", $recaller, 2);

		$this-&gt;viaRemember = ! is_null($user = $this-&gt;provider-&gt;retrieveByToken($id, $token));

		return $user;
	}
}</code></pre>

<p>Feugiat arcu adipiscing mauris primis ante ullamcorper ad nisi, lobortis arcu per orci malesuada blandit metus tortor, urna turpis consectetur porttitor egestas sed eleifend. Eget tincidunt pharetra varius tincidunt morbi malesuada elementum mi torquent mollis, eu lobortis curae purus amet vivamus amet nulla torquent, nibh eu diam aliquam pretium donec aliquam tempus lacus. Tempus feugiat lectus cras non velit mollis sit et integer, egestas habitant auctor integer sem at nam massa himenaeos, netus vel dapibus nibh malesuada leo fusce tortor. Sociosqu semper facilisis semper class tempus faucibus tristique duis eros, cubilia quisque habitasse aliquam fringilla orci non vel, laoreet dolor enim justo facilisis neque accumsan in.</p>

<p>Ad venenatis hac per dictumst nulla ligula donec, mollis massa porttitor ullamcorper risus eu platea, fringilla habitasse suscipit pellentesque donec est. Habitant vehicula tempor ultrices placerat sociosqu ultrices consectetur ullamcorper tincidunt quisque tellus, ante nostra euismod nec suspendisse sem curabitur elit malesuada lacus. Viverra sagittis sit ornare orci augue nullam adipiscing pulvinar libero aliquam vestibulum platea cursus pellentesque leo dui lectus, curabitur euismod ad erat curae non elit ultrices placerat netus metus feugiat non conubia fusce porttitor. Sociosqu diam commodo metus in himenaeos vitae aptent consequat luctus purus eleifend enim sollicitudin eleifend, porta malesuada ac class conubia condimentum mauris facilisis conubia quis scelerisque lacinia.</p>

<p>Tempus nullam felis fusce ac potenti netus ornare semper molestie iaculis, fermentum ornare curabitur tincidunt imperdiet scelerisque imperdiet euismod. Scelerisque torquent curae rhoncus sollicitudin tortor placerat aptent hac, nec posuere suscipit sed tortor neque urna hendrerit, vehicula duis litora tristique congue nec auctor. Felis libero ornare habitasse nec elit felis, inceptos tellus inceptos cubilia quis mattis, faucibus sem non odio fringilla. Class aliquam metus ipsum lorem luctus pharetra dictum vehicula, tempus in venenatis gravida ut gravida proin orci, quis sed platea mi quisque hendrerit semper.</p>
', 'active' => true, 'user_id' => 2]);
        Post::create(['title' => 'Post 3', 'slug' => 'post-3', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/rouge-shell.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 2]);
        Post::create(['title' => 'Post 4', 'slug' => 'post-4', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/rouge-shyguy.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 2]);
        PostTag::create(['post_id' => 1, 'tag_id' => 1]);
        PostTag::create(['post_id' => 1, 'tag_id' => 2]);
        PostTag::create(['post_id' => 2, 'tag_id' => 1]);
        PostTag::create(['post_id' => 2, 'tag_id' => 2]);
        PostTag::create(['post_id' => 2, 'tag_id' => 3]);
        PostTag::create(['post_id' => 3, 'tag_id' => 1]);
        PostTag::create(['post_id' => 3, 'tag_id' => 2]);
        PostTag::create(['post_id' => 3, 'tag_id' => 4]);
        Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 2, 'post_id' => 1]);
        Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 2, 'post_id' => 2]);
        Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 3, 'post_id' => 1]);
    }
開發者ID:MFathirIrhas,項目名稱:codeblog,代碼行數:63,代碼來源:DatabaseSeeder.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $colors = ['#B3B5B4', '#25AAE2', '#AB9364', '#92278F', '#0E76BD', '#F7941D', '#3AB54A', '#808281'];
     foreach (range(0, 30) as $index) {
         $name = $faker->word;
         Tag::create(['name' => $name, 'slug' => $name, 'description' => $faker->sentence, 'topic_count' => 0, 'color' => $faker->randomElement($colors)]);
     }
 }
開發者ID:jiketao,項目名稱:jiketao-laravel,代碼行數:14,代碼來源:TagsTableSeeder.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @param URI int $fact_id
  * @return Response
  */
 public function store(Request $request)
 {
     if (!$request->input('tag_name')) {
         return $this->respondUnprocessed();
     }
     $tag_name = $request->input('tag_name');
     Tag::create(['tag_name' => $tag_name]);
     return $this->respondCreated();
 }
開發者ID:RichNwankwo,項目名稱:Gladysrepo,代碼行數:16,代碼來源:TagController.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $this->beforeRun();
     DB::table('Tag')->truncate();
     $csv = new \mnshankar\CSV\CSV();
     $tags = $csv->fromFile(dirname(__FILE__) . '/csv/Tag.csv')->toArray();
     foreach ($tags as $t) {
         \App\Models\Tag::create($t);
     }
     $this->afterRun();
 }
開發者ID:hungphongbk,項目名稱:ulibi,代碼行數:16,代碼來源:TagSeeder.php

示例10: savePostTags

 protected function savePostTags($postID, $tags)
 {
     foreach ($tags as $tag) {
         $resultTag = Tag::where(\DB::Raw('BINARY name'), $tag);
         if ($resultTag->count()) {
             $tagID = $resultTag->first()->id;
         } else {
             $resultTag = Tag::create(array('name' => $tag));
             $tagID = $resultTag->id;
         }
         PostTag::create(array('post_id' => $postID, 'tag_id' => $tagID));
     }
 }
開發者ID:vanhonit,項目名稱:lazada,代碼行數:13,代碼來源:PostController.php

示例11: saveTags

 public function saveTags(Product $product, array $tags)
 {
     $results = [];
     foreach ($tags as $tag) {
         $tag = trim($tag);
         $find = Tag::where('name', $tag)->first();
         if (!$find) {
             $find = Tag::create(['name' => $tag]);
         }
         $results[] = $find;
     }
     $product_ids = collect($results)->pluck('id');
     $product->tags()->attach($product_ids->toArray());
     return $results;
 }
開發者ID:amteknologi,項目名稱:e-commerce,代碼行數:15,代碼來源:ProductRepository.php

示例12: store

 public function store()
 {
     $tags = \Input::get('tags');
     if ($tags && count($tags)) {
         $results = array();
         foreach ($tags as $tag) {
             $resultTag = Tag::where(\DB::Raw('BINARY name'), $tag);
             if (!$resultTag->count()) {
                 $resultTag = Tag::create(array('name' => $tag));
                 array_push($results, array($tag => $resultTag));
             } else {
                 array_push($results, array($tag => 'Exsiting'));
             }
         }
         Cache::forget('all_tag');
         return self::makeResponse($results, 201);
     } else {
         return self::makeResponse(array(), 400, 'Bad Request');
     }
 }
開發者ID:vanhonit,項目名稱:lazada,代碼行數:20,代碼來源:TagController.php

示例13: postCreate

 /**
  * Responds to requests to POST /article/create
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function postCreate(Request $request)
 {
     $input = $request->all();
     $input['user_id'] = Auth::id();
     $input['tags'] = array_map('trim', explode(',', $input['tags']));
     $input['task_id'] = $input['task_id'] ? $input['task_id'] : null;
     if ($input['action'] == "Odoslať") {
         $input['state'] = Article::PUBLISHED;
     } else {
         $input['state'] = Article::DRAFT;
     }
     if ($article = Article::findBySlugOrId($input['id'])) {
         $article->update($input);
         $article->resluggify()->save();
     } else {
         $article = Article::create($input);
     }
     ArticleTagMapper::where('article_id', '=', $article->id)->delete();
     foreach ($input['tags'] as $tagName) {
         if ($tagName) {
             if (!($tag = Tag::where('name', '=', $tagName)->first())) {
                 $tag = Tag::create(['name' => $tagName]);
             }
             ArticleTagMapper::create(['article_id' => $article->id, 'tag_id' => $tag->id]);
         }
     }
     if ($request->ajax()) {
         $count = Auth::user()->articles()->draft()->count();
         return response()->json(['id' => $article->id, 'status' => 'success', 'count' => $count]);
     } else {
         if ($input['action'] == "Odoslať") {
             flash()->success('Článok bol publikovaný');
             return redirect()->action('UserController@getProfile', ['id' => Auth::user()->slug]);
         } else {
             flash()->success('Článok bol uložený');
             return redirect(URL::action('ArticleController@getDraft', ['id' => $article->slug]));
         }
     }
 }
開發者ID:psiskova,項目名稱:blog-academy,代碼行數:45,代碼來源:ArticleController.php

示例14: tagMockFacts

 /**
  * @param $user
  */
 public function tagMockFacts($user)
 {
     // create two tags
     $tag_id = Tag::create(['tag_name' => 'Test Tag1'])->id;
     $tag_id2 = Tag::create(['tag_name' => 'Test Tag2'])->id;
     $facts = Fact::where('user_id', $user->id)->get();
     foreach ($facts as $fact) {
         // Basically a 50/50 coin flip whether a tag is going to get tag 1 or tag 2
         rand(0, 1) ? \App\Models\TaggedFact::create(['fact_id' => $fact->id, 'tag_id' => $tag_id]) : \App\Models\TaggedFact::create(['fact_id' => $fact->id, 'tag_id' => $tag_id2]);
     }
 }
開發者ID:RichNwankwo,項目名稱:Gladysrepo,代碼行數:14,代碼來源:FactSelectorTest.php

示例15: seedTags

 public function seedTags($type, array $names)
 {
     foreach ($names as $i => $name) {
         Tag::create(['type' => $type, 'name' => faker()->translate($name), 'draft' => 0, 'online' => 1, 'order_column' => $i]);
     }
 }
開發者ID:spatie-custom,項目名稱:blender,代碼行數:6,代碼來源:TagSeeder.php


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