本文整理汇总了PHP中app\Page::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::create方法的具体用法?PHP Page::create怎么用?PHP Page::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Page
的用法示例。
在下文中一共展示了Page::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
*/
public function store(Request $request)
{
$this->validate($request, ['title' => 'required', 'content' => 'required', 'page_type' => 'required', 'state' => 'required']);
$data = $request->all();
$data['publish_at'] = date('Y-m-d H:i:s', strtotime($data['publish_at']));
unset($data['_token']);
$page = $this->page->create($data);
return redirect()->route('pages.show', $page->id);
}
示例2: store
public function store(Request $request)
{
$this->validate($request, ['id' => 'required']);
Page::create($request->all());
$request->flash();
return redirect("/admin/pages");
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(PageRequest $request)
{
//
$input = $request->all();
Page::create($input);
return redirect('paginas');
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
\App\Page::create(['user_id' => 1, 'slug' => 'home', 'route' => 'home', 'status' => 1]);
\App\Page::create(['user_id' => 1, 'slug' => 'about', 'route' => 'about', 'status' => 1]);
\App\Page::create(['user_id' => 1, 'slug' => 'contact', 'route' => 'contact', 'status' => 1]);
}
示例5: run
public function run()
{
DB::table('pages')->delete();
Page::create(['name' => 'News Items', 'alias' => 'news', 'description' => 'News you can use.', 'created_by' => 1, 'modified_by' => 1]);
Page::create(['name' => 'Pop Culture', 'alias' => 'popCulture', 'description' => 'Celebrities, and stuff.', 'created_by' => 1, 'modified_by' => 1]);
Page::create(['name' => 'Food Blog', 'alias' => 'food', 'description' => 'Getting hungry yet?', 'created_by' => 1, 'modified_by' => 1]);
}
示例6: run
public function run()
{
DB::table('pages')->delete();
for ($i = 0; $i < 10; $i++) {
Page::create(['title' => 'Title ' . $i, 'slug' => 'first-page', 'body' => 'Body ' . $i, 'user_id' => 1]);
}
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['title' => 'required']);
$item = Page::create($request->all());
Flash::success("Запись - {$item->id} сохранена");
return redirect(route('admin.pages.index'));
}
示例8: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create(Request $request)
{
$token = str_random(32);
$inputs = $request->all();
$userId = Auth::user()->id;
$vacancy = Page::where('userId', '=', $userId, 'and', 'status', '=', '1')->get();
if (count($vacancy)) {
Page::create(['userId' => $userId, 'title' => $inputs['title'], 'content' => $inputs['content'], 'email' => $inputs['email'], 'status' => 1, 'token' => $token]);
return redirect('/')->with('message', 'Вакансия создана');
} else {
$text = 'Спасибо за размещение, в данный момент вакансия на модерации.';
Mail::raw($text, function ($message) {
$userEmail = Auth::user()->email;
$message->from('laravel@example.com', 'Laravel');
$message->to($userEmail);
});
Page::create(['userId' => $userId, 'title' => $inputs['title'], 'content' => $inputs['content'], 'email' => $inputs['email'], 'status' => 0, 'token' => $token]);
Mail::send('emails.template', ['token' => $token, 'title' => $inputs['title'], 'content' => $inputs['content']], function ($message) {
$userEmail = User::where('user_type', '=', 'admin')->first();
$message->from('laravel@example.com', 'Laravel');
$message->to($userEmail->email);
});
return redirect('/')->with('message', 'Проверьте почту');
}
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('pages')->delete();
for ($i = 0; $i < count($this->items); $i++) {
$row = array_combine(['title', 'text'], $this->items[$i]);
Page::create($row);
}
}
示例10: storepage
public function storepage()
{
if (Page::create(Input::all())) {
return Redirect::to('admin/page_publish')->withErrors(Null);
} else {
return Redirect::back()->withInput()->withErrors('page store fail!');
}
}
示例11: store
/**
* Store a newly created page in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, ["name" => "required", "slug" => "required|unique:page", "enabled" => "required|accepted"]);
$input = $request->input();
$input["user_id"] = $request->user()->id;
Page::create($input);
return redirect()->action("PanelController@edit", $input["slug"]);
}
示例12: 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', 'content' => 'required']);
$input = $request->all();
Page::create($input);
Session::flash('flash_message', 'Stránka vytvořena.');
return redirect()->route('pages.index');
}
示例13: run
public function run()
{
DB::table('pages')->delete();
for ($i = 0; $i < 10; $i++) {
Page::create(['title' => 'Title ' . $i, 'slug' => 'first-page', 'body' => 'Body ' . $i, 'user_id' => 1]);
}
DB::table('users')->delete();
User::create(['name' => 'admin@aneng.com', 'email' => 'admin@aneng.com ', 'password' => bcrypt('000000')]);
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return Response
*/
public function store(Request $request)
{
//
$this->validate($request, $this->rules);
$request['user_id'] = $request->user()->id;
$input = Input::all();
Page::create($input);
return Redirect::route('superadmin.pages.index')->with('message', 'Page created');
}
示例15: edit
public function edit(Request $request)
{
$page_menu_position = [Page::HEADER_MENU => trans('admin_common.Header Menu'), Page::FOOTER_MENU => trans('admin_common.Footer Menu')];
$id = 0;
if (isset($request->id)) {
$id = $request->id;
}
$modelData = new \stdClass();
if ($id > 0) {
try {
$modelData = Page::findOrFail($id);
} catch (ModelNotFoundException $e) {
session()->flash('message', trans('admin_common.Invalid Page'));
return redirect(url('admin/page'));
}
}
/**
* form is submitted check values and save if needed
*/
if ($request->isMethod('post')) {
/**
* validate data
*/
$rules = ['page_position' => 'required|integer|not_in:0', 'page_slug' => 'required|max:255|unique:page,page_slug', 'page_title' => 'required|max:255', 'page_content' => 'required', 'page_ord' => 'required|integer'];
if (isset($modelData->page_id)) {
$rules['page_slug'] = 'required|max:255|unique:page,page_slug,' . $modelData->page_id . ',page_id';
}
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
/**
* get data from form
*/
$data = $request->all();
if (isset($data['page_active'])) {
$data['page_active'] = 1;
} else {
$data['page_active'] = 0;
}
/**
* save or update
*/
if (!isset($modelData->page_id)) {
Page::create($data);
} else {
$modelData->update($data);
}
/**
* clear cache, set message, redirect to list
*/
Cache::flush();
session()->flash('message', trans('admin_common.Page saved'));
return redirect(url('admin/page'));
}
return view('admin.page.page_edit', ['modelData' => $modelData, 'page_menu_position' => $page_menu_position]);
}