本文整理汇总了PHP中Article::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::all方法的具体用法?PHP Article::all怎么用?PHP Article::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
// $custom = User::leftJoin('articles' , 'users.id' ,'=','articles.user_id')->get();
// print_r($custom);
//var_dump(User::custom());
$data['title'] = "Articles";
$data['module'] = "articles";
$data['view_file'] = "articles";
/*
|Find all articles with specific user
|Model User
|Model Article
*/
$user = User::with("articles")->find(1);
/*
|Find all articles with specific coloumns
|Model Article
*/
$data['articles'] = Article::all();
/*
|Find article by id & relation to user
|Model Article
|Model User
*/
/* BOTH ARE SIMILAR */
// $user = Article::with("users")->find(3);
// $user = Article::find(3);
/* BOTH ARE SIMILAR */
$users = Article::all();
foreach ($users as $user) {
// var_dump($user->users->name);
}
$this->tamplate->front($data);
// $this->tamplate->admin($data);
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//should move this to model
//$articles = DB::collection('articles')->get();
$articles = Article::all();
return Response::json($articles);
}
示例3: index_get
function index_get()
{
$articles = Article::all()->toArray();
$newResult = array();
foreach ($articles as $key => $article) {
/**
* Get Today's Date
* @var DateTime
*/
$today = new DateTime();
/**
* Get Time Article was Posted
* @var DateTime
*/
$time = new DateTime($article['time_posted']);
/**
* Get Time Interval
* @var [type]
*/
$interval = (int) $today->diff($time)->format('%i');
// $interval = $interval->format('%i');
if ($interval < 10) {
$value['new'] = true;
}
$year = (int) $time->format('Y');
$month = $time->format('F');
$newResult[$year][$month][] = $article;
}
$this->response($newResult);
}
示例4: index_q2
public function index_q2()
{
$q2 = new Article($this->db, MyConst::$tables["Q2"], MyConst::$cols["Q2"]);
$this->f3->set('q2', $q2->all());
$this->f3->set('view', 'q2/list.html');
echo Template::instance()->render('layout.htm');
}
示例5: testIndexReturnAllArticles
public function testIndexReturnAllArticles()
{
$allArticlesFromDatabaseCount = Article::all()->count();
$response = $this->call("GET", "/article/", $params = array(), $file = array(), $server = array(), null);
$articles = json_decode($response->getContent(), true);
$this->assertResponseStatus(200);
$this->assertEquals($allArticlesFromDatabaseCount, count($articles));
}
示例6: edit
public function edit()
{
$data['title'] = "Articles";
$data['module'] = "articles";
$data['view_file'] = "articles";
$data['articles'] = Article::all(['title', 'content']);
$this->tamplate->admin($data);
}
示例7: testRun
public function testRun()
{
$seeder = new \ProdData\ArticleSeeder();
$seeder->run();
$articles = Article::all();
$this->assertEquals(count($articles), 1);
foreach ($articles as $article) {
//make sure that the default article header contains at least the project name
$this->assertTrue(strpos($article->title, "Hackademic") !== false);
//...and a link to github
$this->assertTrue(strpos($article->content, "github.com/") !== false);
}
}
示例8: push_by_openids
/**
* 按openid推送
*/
public function push_by_openids()
{
$openids = Article::all()->toArray();
$openid_arr = [];
foreach ($openids as $k => $v) {
$openid_arr[] = $v['openid'];
}
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=" . $this->token;
$media_id = $this->media_id;
$data = ['touser' => $openid_arr, 'mpnews' => ['media_id' => $media_id], 'msgtype' => 'mpnews'];
echo json_encode($data);
$res = $this->sendPost($url, json_encode($data));
var_dump($res);
}
示例9: index
/**
* Display a listing of the resource.
* GET /articles
*
* @return Response
*/
public function index()
{
$article = Article::all();
return View::make('article.viewall')->with('article', $article);
}
示例10: Category
<?php
require_once 'article.php';
require_once 'category.php';
//start app
$params = $_GET;
var_dump($params);
$categoryClass = new Category();
$categories = $categoryClass->all();
$article = new Article();
if ($params && isset($params['category_id'])) {
$articles = $article->byCategory($params['category_id']);
$view = 'views/list.php';
} else {
$articles = $article->all();
$view = 'views/list.php';
}
if ($params && isset($params['article_id'])) {
$article = $article->single($params['article_id']);
//ja ovdje prepisujem varijablu koja je na početku prazna instanca klase (a ona od atributa ima onaj $this->db koji vraća kontaš? da
// var_dump($article);die;
$view = 'views/article.php';
}
// var_dump($articles);
?>
<!DOCTYPE html>
<html>
<head>
<title>SCMS</title>
<meta charset="utf-8">
示例11: actionShowArticles
function actionShowArticles()
{
$this->view->render('articles', Article::all(), 'admin');
}
示例12: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$articles = Article::all();
return View::make('articles.index')->with('articles', $articles);
}
示例13: index
/**
* Display a listing of articles
*
* @return Response
*/
public function index()
{
$articles = Article::all();
return View::make('admin.articles.index', compact('articles'));
}
示例14: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$message = Session::get('message');
$articles = Article::all();
return View::make('articles', ['articles' => $articles, 'message' => $message]);
}
示例15: build_backend_subactions
function build_backend_subactions()
{
global $backend_subactions, $pluginpages_handlers;
$backend_subactions = url_action_subactions(array("_index" => url_action_alias(array("login")), "index" => url_action_alias(array("login")), "_prelude" => function (&$data, $url_now, &$url_next) {
global $ratatoeskr_settings, $admin_grp, $ste, $languages;
if ($admin_grp === NULL) {
$admin_grp = Group::by_name("admins");
}
$ste->vars["all_languages"] = array();
$ste->vars["all_langcodes"] = array();
foreach ($languages as $code => $data) {
$ste->vars["all_languages"][$code] = $data["language"];
$ste->vars["all_langcodes"][] = $code;
}
ksort($ste->vars["all_languages"]);
sort($ste->vars["all_langcodes"]);
/* Check authentification */
if (isset($_SESSION["ratatoeskr_uid"])) {
try {
$user = User::by_id($_SESSION["ratatoeskr_uid"]);
if ($user->pwhash == $_SESSION["ratatoeskr_pwhash"] and $user->member_of($admin_grp)) {
if (empty($user->language)) {
$user->language = $ratatoeskr_settings["default_language"];
$user->save();
}
load_language($user->language);
if ($url_next[0] == "login") {
$url_next = array("content", "write");
}
$data["user"] = $user;
$ste->vars["user"] = array("id" => $user->get_id(), "name" => $user->username, "lang" => $user->language);
return;
/* Authentification successful, continue */
} else {
unset($_SESSION["ratatoeskr_uid"]);
}
} catch (DoesNotExistError $e) {
unset($_SESSION["ratatoeskr_uid"]);
}
}
load_language();
/* If we are here, user is not logged in... */
$url_next = array("login");
}, "login" => url_action_simple(function ($data) {
global $ste, $admin_grp;
if (!empty($_POST["user"])) {
try {
$user = User::by_name($_POST["user"]);
if (!PasswordHash::validate($_POST["password"], $user->pwhash)) {
throw new Exception();
}
if (!$user->member_of($admin_grp)) {
throw new Exception();
}
/* Login successful. */
$_SESSION["ratatoeskr_uid"] = $user->get_id();
$_SESSION["ratatoeskr_pwhash"] = $user->pwhash;
load_language($user->language);
$data["user"] = $user;
$ste->vars["user"] = array("id" => $user->get_id(), "name" => $user->username, "lang" => $user->language);
} catch (Exception $e) {
$ste->vars["login_failed"] = True;
}
if (isset($data["user"])) {
throw new Redirect(array("content", "write"));
}
}
echo $ste->exectemplate("/systemtemplates/backend_login.html");
}), "logout" => url_action_simple(function ($data) {
unset($_SESSION["ratatoeskr_uid"]);
unset($_SESSION["ratatoeskr_pwhash"]);
load_language();
throw new Redirect(array("login"));
}), "content" => url_action_subactions(array("write" => function (&$data, $url_now, &$url_next) {
global $ste, $translation, $textprocessors, $ratatoeskr_settings, $languages, $articleeditor_plugins;
list($article, $editlang) = array_slice($url_next, 0);
if (!isset($editlang)) {
$editlang = $data["user"]->language;
}
if (isset($article)) {
$ste->vars["article_editurl"] = urlencode($article) . "/" . urlencode($editlang);
} else {
$ste->vars["article_editurl"] = "";
}
$url_next = array();
$default_section = Section::by_id($ratatoeskr_settings["default_section"]);
$ste->vars["section"] = "content";
$ste->vars["submenu"] = isset($article) ? "articles" : "newarticle";
$ste->vars["textprocessors"] = array();
foreach ($textprocessors as $txtproc => $properties) {
if ($properties[1]) {
$ste->vars["textprocessors"][] = $txtproc;
}
}
$ste->vars["sections"] = array();
foreach (Section::all() as $section) {
$ste->vars["sections"][] = $section->name;
}
$ste->vars["article_section"] = $default_section->name;
/* Check Form */
//.........这里部分代码省略.........