本文整理汇总了PHP中app\Article类的典型用法代码示例。如果您正苦于以下问题:PHP Article类的具体用法?PHP Article怎么用?PHP Article使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Article类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(Article $article, Requests\CreateArticleRequest $request)
{
//$article = Article::findOrFail($id);
$article->update($request->all());
$this->syncTags($article, $request->input('tags_list'));
return redirect('articles');
}
示例2: destroy
public function destroy(Article $article)
{
// $id から $article へ変更
$article->delete();
\Flash::warning('記事を削除しました。');
return redirect()->route('articles.index');
}
示例3: includeAttachments
/**
* Include attachments.
*
* @param \App\Article $article
* @param \League\Fractal\ParamBag|null $params
* @return \League\Fractal\Resource\Collection
* @throws \Exception
*/
public function includeAttachments(Article $article, ParamBag $params = null)
{
$transformer = new \App\Transformers\AttachmentTransformer($params);
$parsed = $this->getParsedParams();
$attachments = $article->attachments()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
return $this->collection($attachments, $transformer);
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param ArticleRequest $request
* @param Article $article
* @return Response
*/
public function update(ArticleRequest $request, Article $article)
{
$article->update($request->all());
$article->tags()->sync($request->get('tag_list'));
session()->flash('success', 'Запись ' . $request->get('title') . ' обновлена');
return redirect()->route('article.index');
}
示例5: store
public function store()
{
$article = new Article();
$article->fill(\Input::only(['title', 'content']));
$article->save();
return redirect('/');
}
示例6: save
private function save(Article $article, array $inputs)
{
$article->title = $inputs['title'];
$article->description = $inputs['description'];
$article->image = $inputs['image'];
$article->save();
}
示例7: create
public function create()
{
// dd(\Session::all());
$model = new Portal();
$portals = $model->getPortals(["parent" => 0]);
if ($portals && is_array($portals)) {
foreach ($portals as $portal) {
switch ($portal->name) {
case '今日要闻':
$positions[2] = $portal->id;
break;
case '图片新闻':
$positions[4] = $portal->id;
break;
case '媒体报导':
$positions[3] = $portal->id;
break;
}
$pids[] = $portal->id;
}
$article_model = new Article();
foreach ($pids as $pid) {
$articles[$pid] = $article_model->getArticles(['Portal_id' => $pid]);
}
return view("index", ["portals" => $portals, 'articles' => $articles, 'positions' => $positions]);
}
return view("index");
}
示例8: destroy
public function destroy(Article $article)
{
$article->delete();
Cache::forget('article:' . $article->id);
Cache::forget('article:all');
return redirect('/');
}
示例9: update
public function update(Article $article, ArticleRequest $request)
{
// $article = Article::findOrFail($id);
$article->update($request->all());
$article->tags()->sync($request->input('tag_list'));
return redirect('articles');
}
示例10: detail
public function detail($slug, Request $request)
{
$slug = Input::get('slug');
$articleModel = new Article();
$article = $articleModel->where('slug', $slug)->firstOrFail();
return $article;
}
示例11: destroy
public function destroy(Article $article)
{
// $article = Article::findOrFail($id);
$article->delete();
\Session::flash('flash_message', '記事を削除しました。');
// return redirect('articles');
return redirect()->route('articles.index');
}
示例12: index
public function index()
{
$article = new Article();
$article->title = 'feiyi';
$article->content = '哈哈';
$result = $article->save();
var_dump($result);
}
示例13: postIndex
public function postIndex(Request $request)
{
$article = new Article();
$this->validate($request, ['title' => 'required', 'body' => 'required']);
$article->fill($request->all());
$article->save();
return redirect('admin/create');
}
示例14: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$Article = new Article();
$rslist = $Article->paginate(10);
$rslist->setPath("article");
$pages = new BootstrapThreePresenter($rslist);
return view("Admin/article/list")->with(["pages" => $pages, "rslist" => $rslist->toArray()]);
}
示例15: update
public function update(Article $article, Requests\ArticleRequest $request)
{
//type hinting ArticleRequest lets us do validation
//$article = Article::findOrFail($id);
$article->update($request->all());
$article->tags()->sync($request->input('tag_list'));
return redirect('articles');
}