本文整理汇总了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'));
}
示例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]);
}
}
示例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();
}
}
示例4: create
public function create()
{
$user = $this->auth();
$data = Input::get();
$data['userId'] = $user->_id;
$result = Tag::create($data);
return $this->output($result->_id);
}
示例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]);
}
}
示例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->validRecaller($recaller) && ! $this->tokenRetrievalAttempted)
{
$this->tokenRetrievalAttempted = true;
list($id, $token) = explode("|", $recaller, 2);
$this->viaRemember = ! is_null($user = $this->provider->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]);
}
示例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)]);
}
}
示例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();
}
示例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();
}
示例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));
}
}
示例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;
}
示例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');
}
}
示例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]));
}
}
}
示例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]);
}
}
示例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]);
}
}