当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::all方法代码示例

本文整理汇总了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);
 }
开发者ID:phpTomysql,项目名称:ci-hmvce,代码行数:35,代码来源:articles.php

示例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);
 }
开发者ID:nguyentienlong,项目名称:laravel.sandbox,代码行数:12,代码来源:ArticleController.php

示例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);
 }
开发者ID:karsanrichard,项目名称:nqcl,代码行数:30,代码来源:news.php

示例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');
 }
开发者ID:srccn,项目名称:hy,代码行数:7,代码来源:ArticleController.php

示例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));
 }
开发者ID:nguyentienlong,项目名称:laravel.sandbox,代码行数:8,代码来源:ArticleControllerTest.php

示例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);
 }
开发者ID:phpTomysql,项目名称:ci-hmvce,代码行数:8,代码来源:admin.php

示例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);
     }
 }
开发者ID:northdpole,项目名称:laravelTest,代码行数:13,代码来源:ArticleSeederTest.php

示例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);
 }
开发者ID:sky-L,项目名称:task,代码行数:17,代码来源:groupAction.php

示例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);
 }
开发者ID:tprifti,项目名称:Blog,代码行数:11,代码来源:ArticlesController.php

示例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">
开发者ID:G483,项目名称:scms,代码行数:31,代码来源:index.php

示例11: actionShowArticles

 function actionShowArticles()
 {
     $this->view->render('articles', Article::all(), 'admin');
 }
开发者ID:AJIACTOP,项目名称:MVC-Framework,代码行数:4,代码来源:ControllerAdmin.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::all();
     return View::make('articles.index')->with('articles', $articles);
 }
开发者ID:Nikesh-shrestha,项目名称:nlaravel,代码行数:10,代码来源:ArticlesController.php

示例13: index

 /**
  * Display a listing of articles
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::all();
     return View::make('admin.articles.index', compact('articles'));
 }
开发者ID:RubelAhmed57,项目名称:simple-blog-app-with-laravel-4,代码行数:10,代码来源:AdminArticlesController.php

示例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]);
 }
开发者ID:nikolaybyivanov,项目名称:PHP,代码行数:11,代码来源:ArticleController.php

示例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 */
//.........这里部分代码省略.........
开发者ID:ratatoeskr-cms,项目名称:ratatoeskr-cms,代码行数:101,代码来源:backend.php


注:本文中的Article::all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。