public function edit($id) { $article = Article::findOrFail($id); //Calls for tag list $tags = Tag::lists('name', 'id'); return view('articles.edit', compact('article', 'tags')); }
/** * 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")); }
/** * 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)]); } }
/** * 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)]); } }
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)]); } }
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'); }
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(); }
/** * 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()]); }
/** * 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); }); }
/** * @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); }
public function edit(Article $article) { $tags = Tag::lists('name', 'id'); return view('article.edit', compact('article', 'tags')); }
/** * 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')); }
$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']; });
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')); }); }