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


PHP Post::retag方法代碼示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  PostFormRequest $request
  * @param  Post $post
  * @return Response
  */
 public function update(PostFormRequest $request, $post)
 {
     $post->fill($request->all());
     $post->save();
     if ($tags = $request->input('tags')) {
         $post->retag($request->input('tags'));
     }
     return $post->load('tagged');
 }
開發者ID:xEdelweiss,項目名稱:my-perfect-back-end,代碼行數:16,代碼來源:PostsController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['published_at' => 'date_format:"Y-m-d H:i:s"', 'categories' => 'array|not_inInArray:1|integerInArray|existsInArray:post_category,id', 'status' => 'in:published,draft,trash', 'visibility' => 'in:public,private', 'tags' => 'array|stringInAarray', 'title' => 'min:1|max:100', 'slug' => 'required|alpha_dash|min:1|max:100', 'content' => ''];
     $validator = Validator::make(Input::only(array_keys($rules)), $rules);
     if ($validator->fails()) {
         throw new ResourceException($validator->errors()->first());
     }
     $post = new Post();
     $fields = ['slug', 'status', 'visibility', 'published_at'];
     foreach ($fields as $key => $field) {
         if (Input::has($field)) {
             $post->{$field} = Input::get($field);
         }
     }
     //field which can null/empty string
     $fields = ['title', 'content'];
     foreach ($fields as $key => $field) {
         if (Input::get($field) === '') {
             $post->{$field} = null;
         } elseif (Input::has($field)) {
             $post->{$field} = Input::get($field);
         }
     }
     $post->save();
     $post->categories()->sync(Input::get('categories', []));
     if (Input::has('tags')) {
         $post->retag(Input::get('tags'));
     }
     return $this->show($post->id);
 }
開發者ID:TolotraRam,項目名稱:laravel-angular-cms,代碼行數:35,代碼來源:PostController.php


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