当前位置: 首页>>代码示例>>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;未经允许,请勿转载。