本文整理匯總了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('/');
}
示例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');
}
示例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');
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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('發表新帖失敗!');
}
}
示例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)]);
}
}
示例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('/');
}
示例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);
}
示例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);
}
示例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');
}
示例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');
}
示例14: store
public function store(TopicRequest $request)
{
$topic = new Topic();
$topic->create($request->all());
return redirect()->action('WebBoardController@allChannel');
}
示例15: storeTopic
public function storeTopic(Request $request)
{
$asistente = Topic::create($request->all());
return redirect()->route('forum');
}
開發者ID:elNapoli,項目名稱:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代碼行數:5,代碼來源:ForumController.php