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('/'); }
/** * 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'); }
/** * 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'); }
/** * 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); } }
/** * 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); }
/** * 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); } }
/** * 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('发表新帖失败!'); } }
/** * 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)]); } }
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('/'); }
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); }
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); }
/** * 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'); }
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'); }
public function store(TopicRequest $request) { $topic = new Topic(); $topic->create($request->all()); return redirect()->action('WebBoardController@allChannel'); }
public function storeTopic(Request $request) { $asistente = Topic::create($request->all()); return redirect()->route('forum'); }