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


PHP Topic::save方法代碼示例

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


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

示例1: add

 public function add()
 {
     $user = new Topic();
     $user->user_id = '123';
     $user->save();
     //$results = DB::table('topic')->get();
     // $results = Topic::create(['u_id'=>'103621']);
     // return view('m_wc.index');
 }
開發者ID:Wsmallnews,項目名稱:laravel,代碼行數:9,代碼來源:TestController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $topic = new Topic($request->all());
     if ($topic->save()) {
         return $topic;
     } else {
         return $errors;
     }
 }
開發者ID:kikyous,項目名稱:laravel,代碼行數:15,代碼來源:TopicController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(TopicRequest $request)
 {
     $topic = new Topic();
     $topic->title = $request->input('title');
     $topic->content = $request->input('content');
     $topic->user_id = $request->user()->id;
     $topic->save();
     return Redirect::action('TopicController@index');
 }
開發者ID:prudywsh,項目名稱:tpe,代碼行數:15,代碼來源:TopicController.php

示例4: store

 /**
  * Store the topic
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:128|min:12', 'body' => 'required|min:32', 'category' => 'required|exists:category,id'], ['title.*' => 'หัวข้อต้องมีความยาว 12-128 ตัวอักษร', 'body.*' => 'เนื้อหาต้องมีความยาวไม่น้อยกว่า 32 ตัวอักษร', 'category.*' => 'กรุณาเลือกหมวดหมู่ด้วย']);
     $topic = new App\Topic();
     $topic->title = $request->title;
     $topic->body = clean($request->body);
     $topic->user_id = $request->user()->id;
     $topic->category_id = $request->category;
     $topic->save();
     return redirect()->action('TopicController@show', ['id' => $topic->id]);
 }
開發者ID:theballkyo,項目名稱:zgm-mc-web,代碼行數:17,代碼來源:TopicController.php

示例5: store

 public function store(Request $request, $lecture_id, $subject_id)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required']);
     $subject = Subject::find($subject_id);
     Log::info('$subject_id: ' . $subject->title);
     $topic = new Topic();
     $topic->title = $request->title;
     $topic->description = $request->description;
     $topic->topic_content = $request->topic_content;
     $topic->subject()->associate($subject);
     $topic->save();
     return redirect('/lectures/' . $lecture_id . '/subjects/' . $subject_id . '/topics');
 }
開發者ID:nouzun,項目名稱:gamification,代碼行數:13,代碼來源:TopicController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $topics = ['Idea Generation', 'Naming', 'Domain names', 'Hosting', 'Market research', 'Forms and Surveys', 'Mockups and Wireframing', 'Design', 'Development', 'Bootcamps', 'Incubaters and Accelerators', 'Deployment', 'Social tools', 'MVP', 'Marketing', 'Early Users', 'Presentations', 'Product Demo', 'Launching', 'Analytics', 'Mobile Analytics', 'Customer Support', 'Project Management', 'Collaboration and Communication', 'Productivity', 'Bugtracking and Feedback', 'Shop', 'Payments', 'Outsourcing', 'Raising Capital', 'Investors', 'Sales', 'CRM', 'Legal', 'Finance', 'HR', 'Learning', 'Books', 'Videos', 'Articles', 'Blogs', 'Newsletters'];
     foreach ($topics as $topic) {
         $t = new Topic();
         if ($t->validate(['name' => $topic])) {
             $t->name = $topic;
             if ($t->save()) {
                 $this->command->info("Added topic: {$topic}");
             }
         } else {
             $this->command->info($t->errors());
         }
         // Topic::create(["name" => $topic]);
     }
 }
開發者ID:startupwrench,項目名稱:startupwrench,代碼行數:22,代碼來源:TopicTableSeeder.php

示例7: addTopic

 public function addTopic()
 {
     Input::merge(array_map('trim', Input::all()));
     $pageslug = Input::get('pageslug');
     $coremenu = Menu::where('slug', $pageslug)->first();
     if ($coremenu->exists()) {
         $level = (int) Input::get('level');
         $parent = Input::get('id');
         $name = Input::get('val');
         $mn = new Topic();
         $mn->menu_id = $coremenu->id;
         $mn->title = ucwords($name);
         $mn->parent = $parent;
         $mn->level = $level;
         $mn->save();
     }
     return 1;
 }
開發者ID:nitin-prodigi,項目名稱:mesa,代碼行數:18,代碼來源:TopicController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $token = JWTAuth::getToken();
     $user = JWTAuth::toUser($token);
     $validator = Validator::make($request->all(), ['title' => 'required|max:255', 'content' => 'required']);
     if ($validator->fails()) {
         return response()->json(['errors' => $validator->errors()], 400);
     }
     $topic = new Topic();
     $topic->title = $request->title;
     $topic->user()->associate($user);
     $topic->save();
     $post = new Post();
     $post->content = $request->content;
     $post->topic()->associate($topic);
     $post->user()->associate($user);
     $post->save();
     return response()->json(['topic' => $topic, 'post' => $post], 201);
 }
開發者ID:uTosTan,項目名稱:codesamples,代碼行數:25,代碼來源:TopicController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //Default for number of images in the post
     $num_img = 0;
     $locationID = null;
     $taglist = null;
     if (Auth::user()->uuid) {
         if ($request->data) {
             $json = $request->data;
             $topicUUID = rand(0, 10) . str_random(12) . rand(0, 10);
             $topicSlug = str_slug($json['title'], "-") . '-' . $topicUUID;
             //Reviews
             if ($json['reviews'] != 'false') {
                 $count = 0;
                 foreach ($json['reviews'] as $review) {
                     //there is a bug that says name is empty sometime
                     if (!empty($review['name'])) {
                         $review_data[$count] = array('topic_uuid' => $topicUUID, 'user_uuid' => Auth::user()->uuid, 'criteria' => $review['name'], 'scores' => $review['rating'], 'is_template' => TRUE, 'created_at' => date("Y-m-d H:i:s"));
                         $count++;
                     }
                 }
                 Reviews::insert($review_data);
             }
             //Location
             if (!empty($json['location'])) {
                 $locationID = $json['location']['id'];
                 //Check location exists, if not create
                 $location_exist = DB::table('locations')->where('external_id', $locationID)->count();
                 if ($location_exist == 0) {
                     $location = new Location();
                     $location->source = 'facebook';
                     //hardcode for now
                     $location->external_id = $locationID;
                     $location->name = $json['location']['name'];
                     $location->category = !empty($json['location']['category']) ? $json['location']['category'] : null;
                     $location->street = !empty($json['location']['location']['street']) ? $json['location']['location']['street'] : null;
                     $location->city = !empty($json['location']['location']['city']) ? $json['location']['location']['city'] : null;
                     $location->state = !empty($json['location']['location']['state']) ? $json['location']['location']['state'] : null;
                     $location->country = !empty($json['location']['location']['country']) ? $json['location']['location']['country'] : null;
                     $location->zip = !empty($json['location']['location']['zip']) ? $json['location']['location']['zip'] : null;
                     $location->latitude = $json['location']['location']['latitude'];
                     $location->longitude = $json['location']['location']['longitude'];
                     $location->save();
                 }
                 //GEt the ID
             }
             //Tag list - to store in the topic table
             if (!empty($json['tags'])) {
                 $taglist = implode(",", $json['tags']);
             }
             //Images
             if (!empty($json['images'])) {
                 $count = 0;
                 //Insert images in another table
                 foreach ($json['images'] as $image) {
                     $img_data[$count] = array('topic_uuid' => $topicUUID, 'user_uuid' => Auth::user()->uuid, 'filename' => $image, 'created_at' => date("Y-m-d H:i:s"));
                     $count++;
                 }
                 $num_img = $count;
                 TopicImages::insert($img_data);
             }
             $topic = new Topic();
             $topic->uuid = $topicUUID;
             $topic->type = $json['type'];
             $topic->uid = Auth::user()->uuid;
             $topic->topic = clean($json['title']);
             $topic->body = preg_replace('/(<[^>]+) style=".*?"/i', '$1', clean($json['body']));
             $topic->text = clean($json['text']);
             $topic->category = $json['categories'];
             $topic->slug = $topicSlug;
             $topic->num_img = $num_img;
             $topic->tags = $taglist;
             $topic->location_id = $locationID;
             $topic->save();
             $tag_data = array();
             $count = 0;
             //Tags - to store in tags table
             if (!empty($json['tags'])) {
                 //Insert tags in another table
                 foreach ($json['tags'] as $tag) {
                     Redis::zadd('post:tag' . $tag, $topic->uuid, $topic->uuid);
                     Redis::sadd('post:' . $topic->uuid . ':tags', $tag);
                     //Master link of tags
                     Redis::sadd('post:tags', $tag);
                     $tag_data[$count] = array('topic_uuid' => $topicUUID, 'title' => clean($tag), 'created_at' => date("Y-m-d H:i:s"));
                     $count++;
                 }
                 Tags::insert($tag_data);
             }
             $topicEvents = Topic::find($topic->id);
             event(new \App\Events\TopicPostEvent($topicEvents));
             $data = array("slug" => $topicSlug, "author" => Auth::user()->displayname, "type" => $json['type'], "topic_uuid" => $topicUUID);
             return $data;
         }
//.........這裏部分代碼省略.........
開發者ID:ktardthong,項目名稱:qanya,代碼行數:101,代碼來源:TopicController.php

示例10: uploadImage

 private function uploadImage(Request $request, Topic $topic)
 {
     if (!$request->hasFile('image')) {
         return;
     }
     $file = $request->file('image');
     $ext = $file->getClientOriginalExtension();
     $name = md5($topic->title) . '.' . $ext;
     $file->move('uploads/topics', $name);
     Image::make('uploads/topics/' . $name)->fit(400, 300)->save();
     $topic->image = $name;
     $topic->save();
 }
開發者ID:enhive,項目名稱:vev,代碼行數:13,代碼來源:TopicController.php

示例11: topic

 public function topic(Request $request)
 {
     $topic = new Topic();
     $topic->name = $request->name;
     $topic->description = $request->description;
     $image_name = uploadFileToS3($request, 'avatar', 300, $topic->avatar_url);
     if ($image_name != null) {
         $topic->avatar_name = $image_name;
         $topic->avatar_url = $this->s3_url . $image_name;
     }
     $topic->class_id = $request->class_id;
     $topic->author_id = $this->user->id;
     $topic->deadline = $request->deadline;
     $topic->save();
     $class = StudyClass::find($request->class_id);
     foreach ($class->registers as $register) {
         $notification = new Notification();
         $notification->actor_id = $this->user->id;
         $notification->product_id = $topic->id;
         $notification->receiver_id = $register->user->id;
         $notification->type = 5;
         $notification->save();
         $data = array("message" => "Lớp " . $class->name . ": " . $this->user->name . " vừa tạo một topic mới ", "link" => url('group/class/' . $request->class_id . '#/topic/' . $topic->id), 'created_at' => format_date_full_option($notification->created_at), "receiver_id" => $notification->receiver_id);
         $publish_data = array("event" => "notification", "data" => $data);
         Redis::publish('colorme-channel', json_encode($publish_data));
     }
     return response()->json($topic, 200);
 }
開發者ID:Kaelcao,項目名稱:colormev2,代碼行數:28,代碼來源:GroupController.php


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