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


PHP Topic::create方法代码示例

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


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

示例1: create

 public function create(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:3', 'body' => 'required', 'published' => 'required|date']);
     Topic::create($request->all());
     \Session::flash('flash_message', 'Topic successfully added!');
     return redirect('/');
 }
开发者ID:shanonim,项目名称:itaema,代码行数:7,代码来源:TopicsController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|unique:topics', 'title' => 'required|unique:topics', 'description' => 'required']);
     $topic = Topic::create($request->all());
     \Session::flash('success', $topic->name . ' topic is successfully created.');
     return redirect('topics');
 }
开发者ID:phpclub,项目名称:GA-Exam,代码行数:12,代码来源:TopicsController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     $input = Input::all();
     $input['user_id'] = Auth::user()->id;
     Topic::create($input);
     return redirect('topics');
 }
开发者ID:gentcys,项目名称:fzzt,代码行数:14,代码来源:TopicsController.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('topics')->delete();
     $topics = array(['title' => '柠檬香茅火锅仓山万达店', 'body' => '首先,服务态度真的是太好了;其次,分量非常足;然后,上菜也相当的快;最后,老板还推荐用最优惠的付款方式。', 'user_id' => 1], ['title' => '逆风网咖', 'body' => '福州第一家网咖,也是将网咖精神执行的最好的一家网咖,无烟无污染,全戴尔显示器机械键盘,请的服务生也都是学生妹。', 'user_id' => 2], ['title' => 'EmailCoffee', 'body' => '坐落正祥广场的一家咖啡管,装修风格独特,咖啡正宗,人少不吵杂,很多人都是一坐一个下午,服务生也是很漂亮。', 'user_id' => 3], ['title' => '重庆小面万达店', 'body' => '这家面馆在万达4号门,人进人出,生意很不错,味道也很好虽然有点辣', 'user_id' => 4], ['title' => '欢乐园网咖', 'body' => '福建第一家网咖连锁店,算得上常山地区真正意义上的网咖的,环境优雅,配置齐全高端', 'user_id' => 5], ['title' => '万达影院', 'body' => '每个周末都有特价电影票,偶尔遇上什么大片做特价就去看看吧,绝对是享受', 'user_id' => 6], ['title' => '高更牛排', 'body' => '一家专门做牛排西餐的店铺,价格比经典牛排优惠许多,但料一点没有减少', 'user_id' => 7], ['title' => '表哥茶餐厅', 'body' => '正宗香港品牌,致力于推广香港饮食文化,不过价格是有点偏贵', 'user_id' => 8], ['title' => '鼓岭', 'body' => '位置位于鼓山旁边,但空气比鼓山上的更清新环境比鼓山更好游客少', 'user_id' => 9]);
     foreach ($topics as $topic) {
         Topic::create($topic);
     }
 }
开发者ID:gentcys,项目名称:fzzt,代码行数:13,代码来源:TopicsTableSeeder.php

示例5: store

 /**
  * Save a new or existing topic
  * if the given topic is new, we add score to user
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|unique:topics,title', 'description' => 'required']);
     $topic = Topic::create($request->except('image'));
     $this->uploadImage($request, $topic);
     Score::create(['user_id' => Auth::user()->id, 'reference' => 'topic', 'score' => 5]);
     return redirect()->to('topics/' . $topic->slug);
 }
开发者ID:enhive,项目名称:vev,代码行数:15,代码来源:TopicController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('topics')->truncate();
     Eloquent::unguard();
     $topics = [['id' => 1, 'menu_id' => 6, 'title' => 'Post Liberalisation', 'parent' => 0, 'level' => 0], ['id' => 2, 'menu_id' => 6, 'title' => 'LPG', 'parent' => 1, 'level' => 1], ['id' => 3, 'menu_id' => 6, 'title' => 'Liberalization', 'parent' => 2, 'level' => 2], ['id' => 4, 'menu_id' => 6, 'title' => 'Budget 1992', 'parent' => 3, 'level' => 3], ['id' => 5, 'menu_id' => 6, 'title' => 'World pressure', 'parent' => 3, 'level' => 3], ['id' => 6, 'menu_id' => 6, 'title' => 'Privatization', 'parent' => 2, 'level' => 2], ['id' => 7, 'menu_id' => 6, 'title' => 'Disinvestment', 'parent' => 6, 'level' => 3], ['id' => 8, 'menu_id' => 6, 'title' => 'Globalization', 'parent' => 2, 'level' => 2], ['id' => 9, 'menu_id' => 6, 'title' => 'BRICS', 'parent' => 1, 'level' => 1], ['id' => 10, 'menu_id' => 6, 'title' => 'Pre Liberalisation', 'parent' => 0, 'level' => 0], ['id' => 11, 'menu_id' => 6, 'title' => 'Land reforms', 'parent' => 10, 'level' => 1], ['id' => 12, 'menu_id' => 6, 'title' => 'International', 'parent' => 0, 'level' => 0], ['id' => 13, 'menu_id' => 6, 'title' => 'Summits', 'parent' => 12, 'level' => 1]];
     foreach ($topics as $topic) {
         Topic::create($topic);
     }
 }
开发者ID:nitin-prodigi,项目名称:mesa,代码行数:14,代码来源:TopicsTableSeeder.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:50', 'ip' => 'required|ip', 'content' => 'required', 'user_id' => 'required']);
     if ($topic = Topic::create(Input::all())) {
         return redirect()->route('bbs.topic.show', [$topic]);
     } else {
         return redirect()->back()->withInput()->withErrors('发表新帖失败!');
     }
 }
开发者ID:suowei,项目名称:saoju,代码行数:14,代码来源:TopicController.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::lists('id')->toArray();
     $nodes = Category::where('type_id', '=', Category::TYPE_TOPIC)->lists('id')->toArray();
     $faker = Faker\Factory::create();
     foreach (range(1, 18) as $index) {
         Topic::create(['title' => 'topic ' . $faker->sentence(), 'body' => implode('<br>', $faker->paragraphs(8)), 'user_id' => $faker->randomElement($users), 'type_id' => Topic::TYPE_TOPIC, 'category_id' => $faker->randomElement($nodes), 'last_comment_user_id' => $faker->randomElement($users)]);
     }
 }
开发者ID:jvlstudio,项目名称:3N1WebSite,代码行数:14,代码来源:TopicTableSeeder.php

示例9: create

 public function create(Request $request)
 {
     //バリデーションを行う(正常:新規データ1件登録して一覧画面へ, 異常:メッセージを表示して入力画面へ)
     //バリデーションメッセージは resources/lang/ja/validation.phpを参照
     $this->validate($request, ['title' => 'required|min:3', 'body' => 'required', 'eyecatch' => 'image|max:2000', 'published' => 'required|date']);
     //新規データ1件登録
     Topic::create($request->all());
     //一覧画面へリダイレクト
     \Session::flash('flash_message', 'Topic successfully added!');
     return redirect('/');
 }
开发者ID:fumiyasac,项目名称:laravel-minimum-tutorial,代码行数:11,代码来源:TopicsController.php

示例10: create

 public function create(CreatorListener $observer, $data)
 {
     $data['user_id'] = auth()->id();
     $data['created_at'] = Carbon::now();
     $data['updated_at'] = Carbon::now();
     $data['body_original'] = $data['body'];
     $data['body'] = app('markdown')->convertMarkdownToHtml($data['body']);
     $data['excerpt'] = Topic::makeExcerpt($data['body']);
     $topic = Topic::create($data);
     if (!$topic) {
         return $observer->creatorFailed($topic->getErrors());
     }
     auth()->user()->increment('topic_count', 1);
     //TODO
     //Robot::notify($data['body_original'], 'Topic', $topic, Auth::user());
     return $observer->creatorSucceed($topic);
 }
开发者ID:yhbyun,项目名称:l5-forum,代码行数:17,代码来源:TopicCreator.php

示例11: create

 public function create(CreatorListener $observer, $data)
 {
     $data['user_id'] = Auth::id();
     $data['created_at'] = Carbon::now()->toDateTimeString();
     $data['updated_at'] = Carbon::now()->toDateTimeString();
     $markdown = new Markdown();
     $data['body_original'] = $data['body'];
     $data['body'] = $markdown->convertMarkdownToHtml($data['body']);
     $data['excerpt'] = Topic::makeExcerpt($data['body']);
     // Validation
     $this->form->validate($data);
     $topic = Topic::create($data);
     if (!$topic) {
         return $observer->creatorFailed($topic->getErrors());
     }
     Auth::user()->increment('topic_count', 1);
     Robot::notify($data['body_original'], 'Topic', $topic, Auth::user());
     return $observer->creatorSucceed($topic);
 }
开发者ID:stevejobsii,项目名称:phphub-laravel5.1,代码行数:19,代码来源:TopicCreator.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     Topic::create($request->all());
     return redirect('/forum/topic');
 }
开发者ID:soywod,项目名称:MAD,代码行数:11,代码来源:TopicController.php

示例13: add_topic

 public function add_topic(Request $request)
 {
     Topic::create(['topic_title' => $request->input('topic_title'), 'opening_post' => $request->input('opening_post'), 'user_id' => Auth::user()->id, 'op_edited_at' => date('Y-m-d H:i:s')]);
     return redirect('home');
 }
开发者ID:JosephsPlace,项目名称:Laravel-Forum,代码行数:5,代码来源:HomeController.php

示例14: store

 public function store(TopicRequest $request)
 {
     $topic = new Topic();
     $topic->create($request->all());
     return redirect()->action('WebBoardController@allChannel');
 }
开发者ID:JesadaMTK,项目名称:issara,代码行数:6,代码来源:WebBoardController.php

示例15: storeTopic

 public function storeTopic(Request $request)
 {
     $asistente = Topic::create($request->all());
     return redirect()->route('forum');
 }
开发者ID:elNapoli,项目名称:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代码行数:5,代码来源:ForumController.php


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