本文整理汇总了PHP中app\models\Tag::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::lists方法的具体用法?PHP Tag::lists怎么用?PHP Tag::lists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::lists方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id)
{
$article = Article::findOrFail($id);
//Calls for tag list
$tags = Tag::lists('name', 'id');
return view('articles.edit', compact('article', 'tags'));
}
示例2: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$tags = Tag::lists("name", "id");
$article = Article::with("tags")->find($id);
$categories = Category::lists("name", "id");
// dd($article->tags->lists("id"));
return view("dashboard.articles.edit", compact("article", "categories", "tags"));
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
$lessonIds = \App\Models\Lesson::lists('id')->toArray();
$tagIds = \App\Models\Tag::lists('id')->toArray();
foreach (range(1, 30) as $index) {
DB::table('lesson_tag')->insert(['lesson_id' => $faker->randomElement($lessonIds), 'tag_id' => $faker->randomElement($tagIds)]);
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
$topics = c2a(Topic::lists('id'));
$tags = c2a(Tag::lists('id'));
foreach (range(0, 30) as $index) {
topic_tag_relationship::create(['topic_id' => $faker->randomElement($topics), 'tag_id' => $faker->randomElement($tags)]);
}
}
示例5: run
public function run()
{
$faker = Faker::create();
$tags = Tag::lists('id')->toArray();
for ($i = 1; $i <= 50; $i++) {
PostTag::create(['post_id' => $i, 'tag_id' => $faker->randomElement($tags)]);
PostTag::create(['post_id' => $i, 'tag_id' => $faker->randomElement($tags)]);
PostTag::create(['post_id' => $i, 'tag_id' => $faker->randomElement($tags)]);
}
}
示例6: editPreparation
public function editPreparation($product)
{
$item = Item::find($product->organizations->first()->pivot->id);
$itemtags = $item->tags->lists(['id'])->toArray();
$book = $product->is;
$bookauthors = $book->authors->lists(['id'])->toArray();
$categories = $this->getCategoriesByRecursion($item->cat_id);
$authors = Author::get()->lists('full_name', 'id');
$editors = ['' => ''] + Editor::lists('e_name', 'id')->all();
$tags = Tag::lists('tag_name', 'id');
return compact('product', 'itemtags', 'authors', 'editors', 'categories', 'tags', 'book', 'item', 'bookauthors', 'categories');
}
示例7: updateMap
public function updateMap($request)
{
$id = $request->route('map');
$map = Map::findOrFail($id);
$values = $request->except('_token', '_method', '_section', 'tags');
$map->fill($values);
if ($request->has('tags') && is_array($request->tags)) {
$tagList = Tag::lists('id')->toArray();
$cleanTags = array_intersect($request->tags, $tagList);
$map->tags()->sync($cleanTags);
}
return $map->save();
}
示例8: handle
/**
* Execute the command.
*
* @return array of fieldnames => values
*/
public function handle()
{
$fields = $this->fieldList;
if ($this->id) {
$fields = $this->fieldsFromModel($this->id, $fields);
} else {
$when = Carbon::now()->addHour();
$fields['publish_date'] = $when->format('M-j-Y');
$fields['publish_time'] = $when->format('g:i A');
}
foreach ($fields as $fieldName => $fieldValue) {
$fields[$fieldName] = old($fieldName, $fieldValue);
}
return array_merge($fields, ['allTags' => Tag::lists('tag')->all()]);
}
示例9: run
/**
* Seed the posts table
*/
public function run()
{
// Pull all the tag names from the file
$tags = Tag::lists('tag')->all();
Post::truncate();
// Don't forget to truncate the pivot table
DB::table('post_tag_pivot')->truncate();
factory(Post::class, 20)->create()->each(function ($post) use($tags) {
// 30% of the time don't assign a tag
if (mt_rand(1, 100) <= 30) {
return;
}
shuffle($tags);
$postTags = [$tags[0]];
// 30% of the time we're assigning tags, assign 2
if (mt_rand(1, 100) <= 30) {
$postTags[] = $tags[1];
}
$post->syncTags($postTags);
});
}
示例10: edit
/**
* @param $startup
* @return $this
*/
public function edit($startup)
{
$startup = Startup::where('url', '=', $startup)->firstOrFail();
$tags = Tag::lists('name', 'id')->all();
$stages = Stage::lists('name', 'id')->all();
$needs = Skill::lists('name', 'id')->all();
return view('startups.edit')->with('startup', $startup)->with('tags', $tags)->with('stages', $stages)->with('needs', $needs);
}
示例11: edit
public function edit(Article $article)
{
$tags = Tag::lists('name', 'id');
return view('article.edit', compact('article', 'tags'));
}
示例12: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$tags = Tag::lists('name', 'id');
return view('forum.create', compact('tags'));
}
示例13: function
$factory->define(Issue::class, function (Generator $faker) use($dates) {
return array_merge(['issue' => $faker->unique()->numberBetween(1, 30), 'published_at' => $faker->dateTimeThisYear], $dates);
});
// 文章
$factory->define(PublishingArticle::class, function (Generator $faker) use($dates) {
$issues = Issue::lists('issue')->toArray();
$categoryIds = Category::lists('id')->toArray();
return array_merge(['issue' => $faker->randomElement($issues), 'category_id' => $faker->randomElement($categoryIds), 'title' => $faker->sentence(), 'desc' => $faker->paragraph, 'url' => $faker->url, 'presenter' => $faker->name], $dates);
});
// 投稿
$factory->define(ContributeArticle::class, function (Generator $faker) use($dates) {
return array_merge(['title' => $faker->sentence(), 'desc' => $faker->paragraph, 'url' => $faker->url, 'presenter' => $faker->name], $dates);
});
// 文章标签
$factory->define(Tag::class, function (Generator $faker) use($dates) {
return array_merge(['name' => $faker->unique()->word], $dates);
});
// 文章和标签之间的关联关系
$factory->define(Taggable::class, function (Generator $faker) use($dates) {
$taggableIds = PublishingArticle::lists('id')->toArray();
$tagIds = Tag::lists('id')->toArray();
return ['tag_id' => $faker->randomElement($tagIds), 'taggable_id' => $faker->randomElement($taggableIds), 'taggable_type' => $faker->randomElement([PublishingArticle::class, ContributeArticle::class])];
});
// 订阅用户
$factory->define(Subscribe::class, function (Generator $faker) use($dates) {
return array_merge(['name' => $faker->name, 'email' => $faker->unique()->email, 'confirm_code' => getVerifyCode(), 'is_confirmed' => $faker->randomElement([0, 1])], $dates);
});
// 系统配置
$factory->define(SystemSetting::class, function (Generator $faker) {
return ['website_title' => 'Kratos', 'website_keywords' => 'K', 'website_dsec' => '', 'website_icp' => '', 'page_size' => '10', 'system_version' => 'alpha_1.0', 'system_author' => 'Kratos', 'system_author_website' => 'Kratos'];
});
示例14: composeProductsForm
public function composeProductsForm()
{
view()->composer('site.products.fields', function ($view) {
$view->with('categories', \App\Models\Category::lists('name', 'id'))->with('tags', \App\Models\Tag::lists('name', 'id'))->with('files', \App\Fileentry::lists('original_filename', 'id'));
});
}