本文整理汇总了PHP中Article::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::with方法的具体用法?PHP Article::with怎么用?PHP Article::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::with方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$article = Article::with('profile')->get();
View::share('selected_option', 'Ver Artículos');
return View::make('article.list')->with('article', $article);
}
示例2: index
public function index()
{
$articles = Cache::want('index.index.articles', 60, function () {
return Article::with('category', 'tags')->take(10)->orderBy('id', 'desc')->select(array('id', 'title', 'cid', 'description', 'litpic', 'created_at', 'updated_at'))->where('cid', '>', '0')->get();
});
$values = array('articles' => $articles);
return View::make('index.index', $values);
}
示例3: show
public function show($id)
{
$article = Cache::want('article_' . $id, 0, function () use($id) {
return Article::with('tags')->findOrFail($id, ['id', 'cid', 'description', 'title', 'content_html as content', 'created_at', 'updated_at']);
});
$values = array('title' => $article->title . '_', 'description' => $article->description, 'article' => $article);
return View::make('article.show', $values);
}
示例4: show
public function show($id)
{
$category = Cache::want('category_' . $id, 0, function () use($id) {
return Category::findOrFail($id);
});
$articles = Article::with('tags')->where('cid', '=', $category->id)->orderBy('id', 'desc')->paginate(15);
$values = array('title' => $category->name . '_', 'category' => $category, 'articles' => $articles);
return View::make('category.show', $values);
}
示例5: all
public function all($page = 1)
{
$limit = 5;
$offset = ($page - 1) * $limit;
$articles = Article::take($limit)->skip($offset)->active()->orderBy('created_at', 'desc')->get();
Paginator::setBaseUrl(Config::get('app.url') . '/articles');
Paginator::setCurrentPage($page);
$totalItems = Article::with('id')->active()->count();
$paginator = PrettyPaginator::make($articles->toArray(), $totalItems, $limit);
return View::make('article/all', ['articles' => $articles, 'setting' => Config::get('setting'), 'paginate' => $paginator]);
}
示例6: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$query = \Article::with('user');
//过滤处理
if ($cid = Input::get('cid')) {
$query->where('cid', '=', $cid);
}
if ($title = Input::get('title')) {
$query->where('title', 'like', '%' . $title . '%');
}
//查询最终文章列表
$articles = $query->orderBy('id', 'desc')->paginate(20);
$values = array('articles' => $articles, 'categories' => \Category::where('final', '=', '1')->get(['id', 'name']));
return View::make('admin/article/index', $values);
}
示例7: getpost
public function getpost($id)
{
$article = Article::with('user')->find($id);
return View::make('articles.post', compact('article'));
}
示例8: articles
public function articles(User $user)
{
return View::make('home')->with('user', $user)->with('articles', Article::with('tags')->where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->get());
}
示例9: update
/**
* Update the specified resource in storage.
* PUT /article/{id}
*
* @param int $id
* @return Response
*/
public function update($id)
{
$rules = ['title' => 'required|max:100', 'content' => 'required', 'tags' => array('required', 'regex:/^\\w+$|^(\\w+,)+\\w+$/')];
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$article = Article::with('tags')->find($id);
$article->update(Input::only('title', 'content'));
$resolved_content = Markdown::parse(Input::get('content'));
$article->resolved_content = $resolved_content;
$tags = array_unique(explode(',', Input::get('tags')));
if (str_contains($resolved_content, '<p>')) {
$start = strpos($resolved_content, '<p>');
$length = strpos($resolved_content, '</p>') - $start - 3;
$article->summary = substr($resolved_content, $start + 3, $length);
} elseif (str_contains($resolved_content, '</h')) {
$start = strpos($resolved_content, '<h');
$length = strpos($resolved_content, '</h') - $start - 4;
$article->summary = substr($resolved_content, $start + 4, $length);
}
$article->save();
foreach ($article->tags as $tag) {
if (($index = array_search($tag->name, $tags)) !== false) {
unset($tags[$index]);
} else {
$tag->count--;
$tag->save();
$article->tags()->detach($tag->id);
}
}
foreach ($tags as $tagName) {
$tag = Tag::whereName($tagName)->first();
if (!$tag) {
$tag = Tag::create(array('name' => $tagName));
}
$tag->count++;
$article->tags()->save($tag);
}
return Redirect::route('article.show', $article->id);
} else {
return Redirect::route('article.edit', $id)->withInput()->withErrors($validator);
}
}
示例10: articles
public function articles()
{
return View::make('admin.articles.list')->with('articles', Article::with('user', 'tags')->orderBy('created_at', 'desc')->get())->with('page', 'articles');
}
示例11: array
});
Route::post('login', array('before' => 'csrf', function () {
$rules = array('email' => 'required|email', 'password' => 'required|min:6', 'remember_me' => 'boolean');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'block' => 0), (bool) Input::get('remember_me'))) {
return Redirect::intended('home');
} else {
return Redirect::to('login')->withInput()->with('message', array('type' => 'danger', 'content' => 'E-mail or password error or be locked'));
}
} else {
return Redirect::to('login')->withInput()->withErrors($validator);
}
}));
Route::get('home', array('before' => 'auth', function () {
return View::make('home')->with('user', Auth::user())->with('articles', Article::with('tags')->where('user_id', '=', Auth::id())->orderBy('created_at', 'desc')->get());
}));
Route::get('logout', array('before' => 'auth', function () {
Auth::logout();
return Redirect::to('/');
}));
Route::get('register', function () {
return View::make('users.create');
});
Route::post('register', array('before' => 'csrf', function () {
$rules = array('email' => 'required|email|unique:users,email', 'nickname' => 'required|min:4|unique:users,nickname', 'password' => 'required|min:6|confirmed');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$user = User::create(Input::only('email', 'password', 'nickname'));
$user->password = Hash::make(Input::get('password'));
if ($user->save()) {
示例12: article_recycle
/**
* [category_recycle 内容回收站]
* @return [type] [description]
*/
public function article_recycle($slug = 1)
{
$article = new Article();
//获取顶级分类
$count = $article->with('belongsToCategory')->where(['is_del' => 1])->count();
//分页
$page = new page($count, 15, $slug);
$arcData = $article->with('belongsToCategory')->where(['is_del' => 1])->limit(15)->offset(($slug - 1) * 15)->orderBy('id', 'desc')->get()->toArray();
//分页html代码
$page = $page->getPage();
$this->smarty->assign('title', '内容回收站_ISisWeb中文网后台管理_ISirPHPFramework');
$this->smarty->assign('page', $page);
$this->smarty->assign('arcData', $arcData);
$this->smarty->display('Admin/Article/recycle.html');
// die();
// $this->view = View::make('/Admin/Article/recycle')
// ->with('arcData',$arcData)
// ->with('page',$page)
// ->with('title','内容回收站_ISirWeb中文网后台');
}
示例13: getArticles
public function getArticles()
{
return Response::json(Article::with('user', 'tags')->where('user_id', Auth::id())->get());
}
示例14: artice
/**
* [artice 文章内容]
* @return [type] [description]
*/
public function artice($slug)
{
$webSite = Website::find(1)->toArray();
$arcData = Article::with('belongsToCategory')->find($slug)->toArray();
//print_r($arcData);
$hotArcData = Article::with('belongsToCategory')->where(['is_del' => 0])->get()->toArray();
$linkData = Link::where(['is_look' => 1])->get()->toArray();
//print_r($linkData);
$cateData = Category::where(['is_del' => 0])->get()->toArray();
//print_r($cateData);
$item = [];
foreach ($cateData as $k => $v) {
if (!isset($item[$v['id']])) {
$item[$v['id']] = $v;
} else {
$item[$v['id']] = $v;
}
}
//上一篇
$pre = Article::get_pre($slug);
//print_r($pre);
//下一篇
$next = Article::get_next($slug);
//print_r($next);
//相关文章
$this->smarty->assign('pre', $pre);
$this->smarty->assign('next', $next);
$this->smarty->assign('webSite', $webSite);
$this->smarty->assign('hotArcData', $hotArcData);
$this->smarty->assign('cateData', $item);
$this->smarty->assign('slug', $slug);
$this->smarty->assign('linkData', $linkData);
$this->smarty->assign('article', $arcData);
$this->smarty->display('Index/article.html');
}