本文整理汇总了PHP中app\Article::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::find方法的具体用法?PHP Article::find怎么用?PHP Article::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postUpdate
public function postUpdate(Requests\Admin\ArticleRequest $request, $type, $act, $id = 0)
{
$article = new Article();
if ($act == 'edit') {
$article = Article::find($id);
}
$article->user_id = \Auth::id();
$article->node_id = $request->input('node');
$article->title = $request->input('title');
$article->seo_title = $request->input('seo_title');
$article->description = $request->input('description');
$article->keywords = $request->input('keywords');
$article->type = $request->input('type');
$article->image = $request->input('get_image');
$article->outline = $request->input('outline') ?: str_limit(strip_tags($request->input('content')));
$article->content = $request->input('content');
$article->order = $request->input('order');
$article->views = $request->input('views');
$article->hot = $request->input('hot') ? 1 : 0;
$article->status = $request->input('status') ? 1 : 0;
$article->recommend = $request->input('recommend') ? 1 : 0;
$article->show_index = $request->input('show_index') ? 1 : 0;
if ($article->save()) {
$info = ['from' => 'update', 'status' => 'success'];
j4flash($info);
return redirect('admin/article/index/' . $type);
} else {
return redirect()->back()->withErrors(['err' => lang('submit failed')])->withInput();
}
}
示例2: destroy
public function destroy($id)
{
$article = Article::find($id);
$article->delete();
Flash::error('Article is deleted successfully...');
return redirect('/admin/articles');
}
示例3: destroy
public function destroy($id)
{
$article = Article::find($id);
$article->delete();
Flash::error('Se ha borrado el artículo ' . $article->title . ' exitosamente!');
return redirect()->route('admin.articles.index');
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
$article = Article::find($id);
$article->delete();
return Redirect::to('admin/articles');
}
示例5: search
public function search()
{
$key = Input::get('key');
$id = Article::max('id');
for ($cnt = 1; $id > 0; $id--) {
$article = Article::find($id);
if (stripos($article['title'], $key) || stripos($article['text'], $key)) {
$articles[$cnt] = $article;
$cnt++;
} else {
if (stristr($article['tags'], $key)) {
$articles[$cnt] = $article;
$cnt++;
}
}
if ($id == 1 && $cnt == 1) {
$articles[$cnt] = null;
}
}
foreach ($articles as $article) {
$str = explode('__more__', $article['text']);
$article['text'] = (string) $str[0];
}
// return view('article.search', compact('articles'));
if ($articles['1'] == null) {
return view('errors.search_404');
} else {
return view('article.search', compact('articles'));
}
// return $articles;
}
示例6: edit
public function edit($id)
{
$article = Cache::rememberForever('article:' . $id, function () use($id) {
return Article::find($id);
});
return view('article.edit', ['article' => $article]);
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
$article = Article::find($id);
// dd($article);
return view('atricles.show', compact('$article'));
}
示例8: store
public function store($articleId)
{
$comment = Request::user()->comments()->create(['body' => Request::input('body')]);
$article = Article::find($articleId);
$article->comments()->save($comment);
return redirect()->back();
}
示例9: 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)
{
$article = Article::find($id);
dd($article);
$article->title = $request->title;
dd($article);
}
示例10: updateArticle
public function updateArticle(Request $request, $id)
{
$article = Article::find($id);
$article->title = $request->input('title');
$article->content = $request->input('content');
$article->save();
return response()->json($article);
}
示例11: updateArticle
public function updateArticle(Request $request, $id)
{
$article = Article::find($id);
$article->article_name = $request->input('article_name');
$article->article_description = $request->input('article_description');
$article->save();
return response()->json($article);
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$article = Article::find($id);
if (!$article) {
return $this->respondNotFound('Article does not exist.');
}
return $this->respond(['data' => $this->articleTransformer->transform($article)]);
}
示例13: view
public function view($id)
{
//funcion helper que nos trae Laravel
$article = Article::find($id);
//dd($article);
//Retornamos a la valores a la vista que se encuentra en la carpeta test de view.
return view('test.index', ['article' => $article]);
}
示例14: view
public function view($id)
{
$article = Article::find($id);
$article->category;
$article->user;
$article->tags;
return view('test.index', ['prueba' => $article]);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$article = Article::find($request->route()->parameter('articles'));
if (!$article || !can_manage_article($article)) {
return redirect('/');
}
return $next($request);
}