本文整理汇总了PHP中app\Page::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::find方法的具体用法?PHP Page::find怎么用?PHP Page::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Page
的用法示例。
在下文中一共展示了Page::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Requests\UpdatePageRequest $request, $id)
{
$page = Page::find($id);
$page->update($request->all());
$page->save();
return redirect('admin/page/1/edit')->with('message', 'გვერდი განახლებულია');
}
示例2: show
public function show($id)
{
$data['project'] = Publish::find($id);
$data['url_cv'] = Page::find(1)->sender;
$data['projects'] = Publish::where('type', 'article')->orderBy('updated_at', 'DESC')->take(3)->get();
return view('project', $data);
}
示例3: updatePage
/**
* @param Request $request
* @param $id
* @return mixed
*/
private function updatePage(Request $request, $id)
{
$this->validate($request, ['title' => 'required', 'content' => 'required', 'page_type' => 'required', 'state' => 'required']);
$page = $this->page->find($id);
$page->update($request->all());
return $page;
}
示例4: save
/**
* Save page
*
* @return \Illuminate\Http\JsonResponse
*/
public function save()
{
$input = \Input::except('_token');
$input['name'] = strtolower($input['name']);
$validator = \Validator::make($input, ['name' => 'required|alpha_dash|max:255|unique:pages' . (!empty($input['id']) ? ',name,' . $input['id'] : ''), 'route' => 'required|unique:pages' . (!empty($input['id']) ? ',route,' . $input['id'] : '')]);
// When fails
if ($validator->fails()) {
return response()->json(['errors' => $validator->messages()]);
}
// Fix php tag in data
if (strpos($input['data'], '<?php') !== 0) {
$input['data'] = '<?php ' . str_replace('<?php', '', $input['data']);
}
// Save changes
$page = empty($input['id']) ? new Page() : Page::find($input['id']);
$page->fill($input);
$page->save();
try {
// Do not overwrite existing view file
if (!empty($input['id']) || empty($input['id']) && !file_exists($page->getViewPath())) {
file_put_contents($page->getViewPath(), $input['content']);
}
file_put_contents($page->getDataPath(), $input['data']);
// Response
return response()->json(['success' => 'Settings saved', 'redirect' => url('/admin/pages/list')]);
} catch (\ErrorException $e) {
return response()->json(['success' => false, 'errors' => ['permissions' => [$e->getMessage()]]]);
}
}
示例5: update
public function update(Request $request)
{
$input = $request->all();
$page = Page::find(1);
$page->update(['user_id' => Auth::user()->id, 'is_active' => 1, 'meta_title' => $input['meta_title'], 'meta_desc' => $input['meta_desc'], 'title_h1' => $input['title_h1'], 'title_h2' => $input['title_h2'], 'desc' => $input['desc'], 'content' => $input['content'], 'sender' => $input['sender']]);
$page->cover->update(['name' => $input['background_image_name'], 'url' => 'cover']);
if (isset($input['background_image'])) {
$file = base_path() . '/public/assets/images/about/cover.jpg';
$img = Image::make($input['background_image']);
$img->save($file);
}
foreach ($page->pictures as $key => $pic) {
if (isset($input['about_image_name_' . $key])) {
$pic->picture->name = $input['about_image_name_' . $key];
$pic->picture->save();
}
if (isset($input['about_image_' . $key])) {
$unique_name = md5(microtime());
$file = base_path() . '/public/assets/images/about/' . $unique_name . '.jpg';
$img = Image::make($input['about_image_' . $key]);
$img->save($file);
$pic->picture->url = $unique_name;
$pic->picture->save();
}
}
return redirect()->route('about');
}
示例6: parentPath
public function parentPath()
{
if (!$this->parent_id) {
return false;
}
$parent = \App\Page::find($this->parent_id)->first();
return $parent->path;
}
示例7: updateContact
public function updateContact(Request $request)
{
$params = $request->input();
$page = Page::find(2);
$page->text = $params['text'];
$page->save();
return redirect()->action('HomeController@contact');
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$page = Page::find($id);
$page->title = $request->input('title');
$page->body = $request->input('body');
$page->slug = $request->input('slug');
$page->save();
return redirect()->route('page.show', [$page->slug]);
}
示例9: update
public function update($data)
{
$page = null;
if (isset($data['id'])) {
$page = Page::find($data['id']);
$page->update($data);
}
return $page;
}
示例10: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$page = Page::find(1);
$news = News::find($id);
if ($news->types == 'news') {
return view('newsDetail')->with(['page' => $page, 'news' => $news]);
} elseif ($news->types == 'development') {
return view('developmentDetail')->with(['page' => $page, 'news' => $news]);
}
}
示例11: about
public function about()
{
// // foreach($user as $users){
// // echo 'Name ==>' . $users->name. '<br/>';
// // echo 'Email ==>' . $users->email. '<br/>';
// // }
// $user = DB::table('users')->where('name','wesarut')->first();
// echo 'Name ==> ';
// echo count($user->name) == '1' ? $user->name : 'error';
$user = Page::find(5);
return view('page.about', ['qqq' => $user]);
}
示例12: update
public function update(Request $request)
{
$input = $request->all();
$page = Page::find(4);
$page->update(['user_id' => Auth::user()->id, 'is_active' => 1, 'meta_title' => $input['meta_title'], 'meta_desc' => $input['meta_desc'], 'title_h1' => $input['title_h1'], 'desc' => $input['desc'], 'content' => $input['content'], 'sender' => $input['sender']]);
$page->cover->update(['name' => $input['background_image_name'], 'url' => 'cover']);
if (isset($input['background_image'])) {
$file = base_path() . '/public/assets/images/contact/cover.jpg';
$img = Image::make($input['background_image']);
$img->save($file);
}
return redirect()->route('contact_admin');
}
示例13: show
public function show($id)
{
$user = Page::findOrFail($id);
$user_id = $user->user_id;
$page = Page::find($id);
$comment = $page->hasManyComments()->paginate(3);
if ($user->count() == 0) {
return view('index.content', ['name' => Null])->withPage(Null)->withErrors('Not found!')->withComments(Null);
} else {
$user = User::find($user_id)->name;
return view('index.content', ['name' => $user])->withPage($page)->withErrors(Null)->withComments($comment);
}
}
示例14: update
public function update(Requests\PageRequest $request)
{
$input = Request::all();
$page = Page::find($input['id']);
$page->body = $input['body'];
$page->title = $input['title'];
$page->slug = $input['slug'];
$page->save();
// Log Update in Activity Table
Activity::log(['contentId' => $page->id, 'contentType' => 'Page', 'action' => 'Update', 'description' => 'Update a Page', 'details' => \Auth::user()->id, 'updated' => '']);
// Set Flash Message
session()->flash('flash_message', '' . $page->title . ' Updated!');
return redirect('pages/' . $page->slug . '');
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['title' => 'required|unique:pages,title,' . $id . '|max:255', 'body' => 'required']);
$page = Page::find($id);
$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('保存失败!');
}
}