本文整理汇总了PHP中app\models\Page::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::save方法的具体用法?PHP Page::save怎么用?PHP Page::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Page
的用法示例。
在下文中一共展示了Page::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postAdd
public function postAdd(Request $request)
{
$name = $request->input('name');
$content = $request->input('content');
$status = $request->input('status') ? 1 : 2;
try {
if (isset($name) && !empty($name)) {
$table = new Page();
$table->name = $name;
$table->create_time = date("Y-m-d H:i:s");
$table->content = $content;
$table->status = $status;
$rs = $table->save();
if ($rs) {
$this->message = 'Thêm mới thành công !';
} else {
$this->error = true;
$this->error_message = 'Thêm mới không thành công !';
}
} else {
$this->error = true;
$this->error_message = 'Tên trang không được để trống';
}
} catch (Exception $e) {
$this->error = true;
$this->error_message = $e->getMessage();
}
return $this->ResponseData();
}
示例2: actionCreate
/**
* Creates a new Page model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Page();
$pages = Page::find()->all();
$request = Yii::$app->request;
$parent_id = $request->get('page_id', 0);
if ($model->load(Yii::$app->request->post())) {
$model->parent_id = $parent_id;
if ($model->type == 4) {
$model->template = 'gallery';
} else {
if ($model->type == 3) {
if ($parent_id == 13) {
$model->template = 'news';
} else {
$model->template = 'sub-news';
}
} else {
if ($model->type == 1) {
$model->template = "links";
}
}
}
if ($model->save()) {
return $this->redirect(['index']);
}
} else {
return $this->render('create', ['model' => $model, 'pages' => $pages, 'parent_id' => $parent_id]);
}
}
示例3: postSavePage
/**
* Saved edited page; called viea ajax
* @return String
*/
public function postSavePage()
{
$okay = true;
$page_id = $_REQUEST['page_id'];
$page_content = $_REQUEST['thedata'];
if ($page_id > 0) {
$page = Page::find($page_id);
} else {
$page = new Page();
$slugify = new Slugify();
$browser_title = $_REQUEST['browser_title'];
$page->browser_title = $browser_title;
$page->slug = $slugify->slugify($browser_title);
// verify that the slug is not already in the db
$results = Page::where('slug', $slugify->slugify($browser_title))->get();
foreach ($results as $result) {
$okay = false;
}
}
$page->page_content = $page_content;
if ($okay) {
$page->save();
echo "OK";
} else {
echo "Browser title is already in use";
}
}
示例4: updatePost
public function updatePost(Request $request, Page $page)
{
$page->fill($request->all());
$page->meta = $request->get('meta', []);
$page->save();
return $this->redirectAction('update', $page);
}
示例5: postStore
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function postStore(Request $request)
{
$rules = array('title' => 'required', 'content' => 'required');
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return redirect()->back()->withErrors($validator);
} else {
// create the data for our user
$page = new Page();
$page->title = $request->input('title');
$page->content = $request->input('content');
$page->slug = Str::slug($request->input('title'));
$page->active = 1;
//$page->menu_id = $request->input('menu_id');
$page->meta_keywords = $request->input('meta_keywords');
$page->meta_description = $request->input('meta_description');
if ($page->save()) {
$request->session()->flash('alert-success', 'New page has been created successfully');
return redirect('admin/pages');
} else {
return redirect('admin/pages/create')->withInput(Input::get());
}
exit;
}
}
示例6: actionCreate
/**
* Creates a new Page model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Page();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例7: actionCreate
/**
* @return string|\yii\web\Response
*/
public function actionCreate()
{
$model = new Page();
$model->loadDefaultValues();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['list']);
}
return $this->render('create', ['model' => $model]);
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//
$this->validate($request, ['ueditor' => 'required']);
$page = new Page();
$page->content = Input::get('editor');
$page->user_id = Auth::user()->id;
if ($page->save()) {
return Redirect::to('admin/page');
} else {
return Redirect::back()->withInput()->withErrors('保存失败!');
}
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['title' => 'required|unique:pages|max:255', 'content' => 'required']);
$page = new Page();
$page->title = e(Input::get('title'));
$page->thumb = Input::get('thumb') ? e(Input::get('thumb')) : '';
$page->content = e(Input::get('content'));
$page->user_id = Auth::user()->id;
if ($page->save()) {
return Redirect::to('admin');
} else {
return Redirect::back()->withInput($request->input())->withErrors('保存失败!');
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//
$this->validate($request, ['title' => 'required|unique:pages|max:255', 'body' => 'required']);
$page = new Page();
$page->title = Input::get('title');
$page->body = Input::get('body');
$page->user_id = 1;
//Auth::user()->id;
if ($page->save()) {
return Redirect::to('admin');
} else {
return Redirect::back()->withInput()->withErrors('保存失败!');
}
}
示例11: store
public function store()
{
$validation = new PageValidator();
if ($validation->passes()) {
$page = new Page();
$page->title = Input::get('title');
$page->slug = Str::slug(Input::get('title'));
$page->body = Input::get('body');
$page->user_id = Sentry::getUser()->id;
$page->save();
Notification::success('The page was saved.');
return Redirect::route('admin.pages.edit', $page->id);
}
return Redirect::back()->withInput()->withErrors($validation->errors);
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['key' => 'required|unique:pages|max:255', 'description' => 'required|max:255', 'keywords' => 'required|max:255', 'title' => 'required|max:255', 'page_title' => 'required|max:255', 'text' => 'required', 'elements' => '']);
if ($validator->fails()) {
return redirect('admin/pages/create')->withErrors($validator)->withInput($request->all());
}
$page = new Page();
$page->key = $request->key;
$page->description = $request->description;
$page->keywords = $request->keywords;
$page->title = $request->title;
$page->page_title = $request->page_title;
$page->text = $request->text;
$page->elements = $request->elements;
$page->save();
return redirect('admin/pages');
}
示例13: store
/**
* Save a page.
*
* @return Redirect
*/
public function store(Request $request)
{
// store
$lang = $request->session()->get('language');
$page = new Page();
$page->shop_id = $request->shop_id;
$page->slug = $request->slug;
$data = $request->except(['shop_id', 'slug', '_token', '_method']);
$page->{$lang} = $data;
if ($lang == config('app.locale')) {
$page->default = $data;
}
$page->save();
// redirect
$request->session()->flash('success', trans('pages.page') . ' ' . trans('crud.created'));
return redirect('admin/pages/' . $page->id . '/edit');
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$validator = \Validator::make($request->all(), ['title' => 'required|max:255', 'keywords' => 'max:255', 'url' => 'required|max:255|alpha_dash|unique:pages', 'description' => 'required|max:1000', 'content' => 'required|max:40000', 'active' => 'boolean']);
if (!$validator->fails()) {
$page = new Page();
$page->title = $request->get("title");
$page->url = $request->get("url");
$page->keywords = $request->get("keywords");
$page->description = $request->get("description");
$page->content = $request->get("content");
$page->active = $request->has("active");
$page->save();
} else {
$this->throwValidationException($request, $validator);
}
return redirect()->back();
}
示例15: store
public function store()
{
$input = Input::only('browserTitle', 'pageTitle', 'active', 'publishedDate', 'content', 'layout', 'sidebars');
$validate = $this->validate($input);
if ($validate->passes()) {
$slug = Str::slug($input['pageTitle']);
//save
$page = new Page();
if (is_array($input['sidebars'])) {
$page->sidebars = implode(',', $input['sidebars']);
}
$page->browserTitle = $input['browserTitle'];
$page->pageTitle = $input['pageTitle'];
$page->slug = $slug;
$page->active = $input['active'];
$page->publishedDate = $input['publishedDate'];
$page->content = $input['content'];
$page->layout = $input['layout'];
$page->save();
return Redirect::to('admin/pages')->withStatus('Page Created');
}
return Redirect::back()->withStatus($validate->errors(), 'danger')->withInput();
}