当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::tags方法代码示例

本文整理汇总了PHP中app\Article::tags方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::tags方法的具体用法?PHP Article::tags怎么用?PHP Article::tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Article的用法示例。


在下文中一共展示了Article::tags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 public function create(Request $request)
 {
     $article = new \App\Article(['title' => $request['title'], 'content' => $request['content'], 'description' => $request['description'], 'views' => 0, 'user_id' => auth()->user()->id, 'blog_id' => 1, 'category_id' => $request['category'] ? $request['category'] : 0]);
     $article->save();
     $array = explode(',', $request->tags);
     foreach ($array as $tag) {
         if (filter_var($tag, FILTER_VALIDATE_INT)) {
             $article->tags()->attach($tag);
         } else {
             $newTag = Tag::create(['name' => $tag]);
             $article->tags()->attach($newTag['id']);
         }
     }
     return redirect()->back()->with(['alert' => true, 'update' => true, 'class' => 'success', 'message' => 'Article crée avec succèss']);
 }
开发者ID:otsaan,项目名称:e-blog,代码行数:15,代码来源:ArticleController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  ArticleRequest  $request
  * @param  Article $article
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     $article->update($request->all());
     $article->tags()->sync($request->get('tag_list'));
     session()->flash('success', 'Запись ' . $request->get('title') . ' обновлена');
     return redirect()->route('article.index');
 }
开发者ID:belhard-user,项目名称:group2,代码行数:14,代码来源:BlogController.php

示例3: update

 public function update(Article $article, ArticleRequest $request)
 {
     // $article = Article::findOrFail($id);
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list'));
     return redirect('articles');
 }
开发者ID:mbrand12,项目名称:foundation5,代码行数:7,代码来源:ArticlesController.php

示例4: store

 public function store(ArticleRequest $request)
 {
     // Request use
     //		$input = Request::all();
     // check data input :: use ArticleRequest class
     //		$input = $request->all();
     //		Article::create($input);
     $article = new Article($request->all());
     // add image
     if ($request->hasFile('image')) {
         $image_filename = $request->file('image')->getClientOriginalName();
         $image_name = date("Ymd-His-") . $image_filename;
         $public_path = 'images/articles/';
         $destination = base_path() . $public_path;
         $request->file('image')->move($destination, $image_name);
         $article->image = $public_path . $image_name;
     }
     // add migration user_id
     /* form 1 */
     $article->user_id = Auth::user()->id;
     $article->save();
     /* form 2 */
     //		Auth::user()->articles()->save($article);
     // add many to many
     $tagsId = $request->input('tag_list');
     if (!empty($tagsId)) {
         $article->tags()->sync($tagsId);
     }
     return redirect('articles');
 }
开发者ID:tiscomsci29,项目名称:Laravel_2,代码行数:30,代码来源:ArticleController.php

示例5: includeTags

 /**
  * Include tags.
  *
  * @param  \App\Article                  $article
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeTags(Article $article, ParamBag $params = null)
 {
     $transformer = new \App\Transformers\TagTransformer($params);
     $parsed = $this->getParsedParams();
     $tags = $article->tags()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
     return $this->collection($tags, $transformer);
 }
开发者ID:linuxssm,项目名称:l5essential,代码行数:15,代码来源:ArticleTransformer.php

示例6: update

 public function update(Article $article, ArticleRequest $request)
 {
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list', []));
     \Flash::success('記事を更新しました。');
     return redirect()->route('articles.show', [$article->id]);
 }
开发者ID:ry-htr,项目名称:laravel-sample,代码行数:7,代码来源:ArticlesController.php

示例7: update

 public function update(Article $article, Requests\ArticleRequest $request)
 {
     //type hinting ArticleRequest lets us do validation
     //$article = Article::findOrFail($id);
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list'));
     return redirect('articles');
 }
开发者ID:bartolini69,项目名称:Laracast-Tutorials,代码行数:8,代码来源:ArticlesController.php

示例8: createTestStub

 /**
  * Stubbing test data.
  *
  * @param array $overrides
  */
 protected function createTestStub($overrides = [])
 {
     $this->user = !empty($overrides) ? factory(User::class)->create() : factory(User::class)->create($overrides);
     $this->user->attachRole(Role::find(2));
     $this->article = factory(Article::class)->create(['title' => 'title', 'author_id' => $this->user->id, 'content' => 'description']);
     $this->article->comments()->save(factory(Comment::class)->make(['author_id' => $this->user->id]));
     $this->article->tags()->attach(1);
     $this->article->attachments()->save(factory(Attachment::class)->make());
 }
开发者ID:pokev25,项目名称:l5essential,代码行数:14,代码来源:AuthTest.php

示例9: syncTags

 private function syncTags(Article $article, array $tags)
 {
     $currentTags = array_filter($tags, 'is_numeric');
     $newTags = array_diff($tags, $currentTags);
     foreach ($newTags as $newTag) {
         $tag = Tag::create(['name' => $newTag]);
         $tag->save();
         $currentTags[] = $tag->id;
     }
     $article->tags()->sync($currentTags);
 }
开发者ID:Arceopteryx,项目名称:superblog,代码行数:11,代码来源:ArticlesController.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $faker = Faker\Factory::create();
     DB::statement('set foreign_key_checks = 0');
     Article::truncate();
     DB::statement('set foreign_key_checks = 1');
     foreach (range(1, 30) as $index) {
         $article = new Article();
         $article->user_id = mt_rand(1, 2);
         $article->title = $faker->sentence(2);
         $article->body = $faker->sentence(20);
         $article->published_at = Carbon\Carbon::now()->subDays(mt_rand(0, 3650));
         $article->save();
         $article->tags()->attach($this->getRandomTagList());
     }
     Model::reguard();
 }
开发者ID:ganqzz,项目名称:laracasts-laravel5,代码行数:23,代码来源:ArticlesTableSeeder.php

示例11: store

 public function store(ArticleRequest $request)
 {
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = "blogfacilito_" . time() . bcrypt(\Auth::user()) . "." . $file->getClientOriginalExtension();
         $path = public_path() . "/images/articles/";
         $file->move($path, $name);
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     Flash::success("El articulo " . $article->title . " se ha creado satisfactoriamente!");
     return redirect()->route('admin.articles.index');
 }
开发者ID:blitzkriegcoding,项目名称:blog_cf,代码行数:19,代码来源:ArticlesController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ArticleRequest $request)
 {
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = 'blogfacilito_' . time() . '.' . $file->getClientOriginalExtension();
         $path = public_path() . '/images/articles/';
         $file->move($path, $name);
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     Flash::success('Se ha creado el articulo ' . $article->title . ' de forma exitosa!!');
     return redirect()->route('admin.articles.index');
 }
开发者ID:rikardote,项目名称:larablog,代码行数:25,代码来源:ArticlesController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ArticleRequest $request)
 {
     // Manipulacion de imagenes
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = 'IN_' . time() . '.' . $file->getClientOriginalExtension();
         $path = public_path() . '/images/articles/';
         $file->move($path, $name);
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     alert()->success('Enorabuena', 'El articulo ' . $article->title . ' ha sido creado con exito');
     Flash::success('El articulo ' . $article->title . ' ha sido creado con exito¡');
     return redirect()->route('admin.articles.index');
 }
开发者ID:EstevenJaviier,项目名称:Semillero-IN,代码行数:27,代码来源:ArticlesController.php

示例14: store

 public function store(ArticleRequest $request)
 {
     if ($request->file('image')) {
         //Manipulacion de imagenes
         $file = $request->file('image');
         $name = substr($file->getClientOriginalName(), 0, -4) . "_" . time() . '_image.' . $file->getClientOriginalExtension();
         $path = base_path() . '/public/images/articles/';
         $file->move($path, $name);
         $image->name = $name;
     }
     $article = new Article($request->all());
     $article->user_id = \Auth::user()->id;
     $article->save();
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->article_id = $article->id;
     //$image->article()->associate();
     $image->save();
     Flash::success('Se ha agregado el articulo de forma satisfactoria.');
     return redirect()->route('admin.articles.index');
 }
开发者ID:gratereaux,项目名称:practicing-laravel,代码行数:21,代码来源:ArticlesController.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Manipulación de imágenes
     if ($request->file('image')) {
         $file = $request->file('image');
         $name = 'blog_' . time() . '.' . $file->getClientOriginalExtension();
         $path = public_path() . '/images/articles/';
         $file->move($path, $name);
     }
     // NOTA : Se deben instanciar los modelos para poder acceder a las propiedades que no están en el formlario
     $article = new Article($request->all());
     $article->user_id = Auth::user()->id;
     $article->save();
     //El método "sync", nos permite llenar la tabla pivote, recibe como parámetro un array con los datos que se van a rellenar
     $article->tags()->sync($request->tags);
     $image = new Image();
     $image->name = $name;
     $image->article()->associate($article);
     $image->save();
     Session::flash('message_create', "El Artículo - " . $request->title . " - fue creado exitosamente!");
     return redirect()->route('admin.articles.index');
 }
开发者ID:JhonatanC,项目名称:laravelcodfa,代码行数:28,代码来源:ArticlesController.php


注:本文中的app\Article::tags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。