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


PHP Posts::all方法代码示例

本文整理汇总了PHP中app\Posts::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::all方法的具体用法?PHP Posts::all怎么用?PHP Posts::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Posts的用法示例。


在下文中一共展示了Posts::all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $title = 'Dashboard';
     $posts = Posts::all()->take(3);
     $comments = Comments::all()->take(3);
     return view('dashboard')->withTitle($title)->withPosts($posts)->withComments($comments);
     //return home.blade.php template from resources/views folder
 }
开发者ID:dikyarga,项目名称:sistem-informasi-organisasi-dengan-laravel,代码行数:13,代码来源:DashboardController.php

示例2: managePost

 public function managePost()
 {
     $user_id = Auth::user()->id;
     if ($user_id == 1) {
         $arrPost = Posts::all();
     } else {
         $arrPost = Posts::where('user_id', '=', $user_id)->get();
     }
     return view('pages.managePost', array('arrPost' => $arrPost));
 }
开发者ID:keshavkatwe,项目名称:advsystem,代码行数:10,代码来源:Post.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Info we need to grab. //
     ///////////////////////////
     // New users: Today, this week + month. ---> just queery our database with a where->created == today || month || week
     // Total categories
     // unread admin messages.
     $data = array('new_users' => \App\User::all()->orderBy('created_at', 'DES')->limit(10), 'active_nav' => $this->active_nav, 'total_users' => \App\User::all()->count(), 'logged_in' => \App\User::where('logged_in', '=', 1)->count(), 'total_posts' => \App\Posts::all()->count());
     return view('includes/admin/home')->with($data);
 }
开发者ID:steakyfask,项目名称:ShareStuff,代码行数:15,代码来源:AdminHomeController.php

示例4: getPosts

 public function getPosts()
 {
     try {
         $statusCode = 200;
         $response = ['posts' => []];
         $posts = Posts::all();
     } catch (Exception $e) {
         $statusCode = 400;
     } finally {
         // return Response::json($response, $statusCode);
         return Response::json(array('statuscode' => $statusCode, 'posts' => $posts->toArray()));
     }
 }
开发者ID:anmolarora,项目名称:MyBlog_PHP,代码行数:13,代码来源:PostController.php

示例5: home

 public function home()
 {
     $posts = Posts::all();
     $allTxt = array();
     $i = 0;
     foreach ($posts as $post) {
         if ($post->active == 1 && !$post->expired() && $post->type == 0 && empty($post->image)) {
             $allTxt[$i] = array('title' => $post->title, 'description' => $post->description, 'uname' => $post->user->userName(), 'dateon' => date('d-M-y h:i a', strtotime($post->created_at)), 'deptname' => $post->deptName->name);
             $i++;
         }
     }
     return view('newUI')->with('posts', $posts)->with('allTxt', $allTxt);
 }
开发者ID:keshavkatwe,项目名称:advsystem,代码行数:13,代码来源:Home.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = array('data' => Posts::all());
     return view('artikel.all')->with($data);
 }
开发者ID:ariefsetya,项目名称:blog,代码行数:10,代码来源:ArtikelController.php

示例7: searchPostsByHashtag

 public function searchPostsByHashtag(Request $request)
 {
     $data = $request->all();
     preg_match_all('/\\b([a-zA-Z0-9]+)\\b/', strtoupper($data['HashtagSearch']), $matches, PREG_PATTERN_ORDER);
     $hashtags = $matches[1];
     $posts = Posts::all()->toArray();
     $rank = array();
     foreach ($hashtags as $ht) {
         foreach ($posts as $key => $post) {
             if (!array_key_exists($key, $rank)) {
                 $rank += array($key => 0);
             }
             $postHashtag = Tags::where('PostID', '=', $post['id'])->get()->toArray();
             foreach ($postHashtag as $pht) {
                 if (stripos(Hashtags::find($pht['HashtagID'])->Hashtag, $ht) !== false) {
                     $rank[$key]++;
                 }
             }
         }
     }
     foreach ($rank as $key => $value) {
         if ($value < 1) {
             unset($rank[$key]);
         }
     }
     arsort($rank);
     $result = array();
     $posts = Posts::all();
     foreach ($rank as $key => $value) {
         $result += array($key => $posts[$key]);
     }
     preg_match_all('/\\b([a-zA-Z0-9]+)\\b/', $data['HashtagSearch'], $matches, PREG_PATTERN_ORDER);
     $hashtags = $matches[1];
     $Hashtags = '';
     foreach ($hashtags as $ht) {
         $Hashtags .= $ht . ' ';
     }
     return view('search')->with(['Posts' => $result, 'Hashtags' => $Hashtags]);
 }
开发者ID:ngocdon0127,项目名称:kids,代码行数:39,代码来源:PostsController.php

示例8: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return \App\Posts::all();
 }
开发者ID:reneedudley,项目名称:bitter,代码行数:9,代码来源:PostsController.php

示例9: function

| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('api/artikel/all', function () {
    $data = array('artikel' => array('id' => 1, 'judul' => 'judul artikel', 'isi' => 'isi artikel', 'timestamp' => '2015-01-01 01:01:01'));
    //echo "<pre>".print_r($data,1)."<pre>";
    //echo $data->artikel->id;
    $json = json_encode($data);
    echo $json;
    //$obj = json_decode($json);
    //echo "<pre>".print_r($obj,1)."<pre>";
    //echo $obj['artikel']['id'];
});
Route::get('api/artikel/all', function () {
    $data = \App\Posts::all();
    $arr = array();
    foreach ($data as $key) {
        $arr[] = array('slug' => $key['slug'], 'isi' => $key['isi'], 'created_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])['email'], 'tag' => $key['tag'], 'judul' => $key['judul']);
    }
    echo json_encode($arr);
    // echo "<pre>".json_encode($data)."<pre>";
});
Route::get('api/artikel/detail/{slug}', function ($slug) {
    $key = \App\Posts::where('slug', $slug)->first();
    $arr = array();
    $arr[] = array('slug' => $key['slug'], 'isi' => $key['isi'], 'created_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])['email'], 'tag' => $key['tag'], 'sampul' => url('images/' . $key['sampul']), 'judul' => $key['judul']);
    echo json_encode($arr);
});
Route::get('api/artikel/{type}/{cari}', function ($type, $cari) {
    $data = \App\Posts::where($type, $cari)->get();
开发者ID:rzdannisa,项目名称:bloog,代码行数:31,代码来源:routes.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = array('active_nav' => $this->active_nav, 'posts' => \App\Posts::all());
     return view('includes/admin/manage-posts')->with($data);
 }
开发者ID:steakyfask,项目名称:ShareStuff,代码行数:10,代码来源:AdminPostsController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $admin_messages = \App\AdminMessages::where('read', '=', 0);
     $data = array('active_nav' => $this->active_nav, 'total_users' => \App\User::all()->count(), 'logged_in' => \App\User::where('logged_in', '=', 1)->count(), 'total_categories' => \App\categories::count(), 'total_posts' => \App\Posts::all()->count(), 'latest_users' => \App\User::orderBy('created_at', 'ASC')->limit(10)->get(), 'latest_posts' => \App\Posts::orderBy('created_at', 'ASC')->limit(10)->get(), 'unread_admin_messages' => $admin_messages->count(), 'new_users_month' => \App\User::getFromDate(date('y-m-0'))->count(), 'new_users_week' => \App\User::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_users_day' => \App\User::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'new_posts_month' => \App\Posts::getFromDate(date('y-m-0'))->count(), 'new_posts_week' => \App\Posts::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_posts_day' => \App\Posts::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'admin_messages' => $admin_messages->get());
     return view('includes/admin/home')->with($data);
 }
开发者ID:steakyfask,项目名称:ShareStuff,代码行数:11,代码来源:AdminHomeController.php

示例12: add

 /**
  * @return mixed
  */
 public function add()
 {
     $response = [];
     $message = "Inserted ok";
     $statusCode = 200;
     $data = json_decode(file_get_contents('php://input'));
     if (!empty($data)) {
         try {
             $title = $data->title;
             $description = $data->description;
             $content = $data->content;
             $published = $data->published;
             DB::table('posts')->insert([['title' => $title, 'description' => $description, 'content' => $content, 'published' => $published]]);
             $response['posts'] = Posts::all();
             $statusCode = 200;
         } catch (Exception $e) {
             $message = $e->getMessage();
             $statusCode = 400;
         } finally {
             $response['status'] = $statusCode;
             $response['message'] = $message;
         }
     } else {
         $statusCode = 400;
     }
     return \Response::json($response, $statusCode);
 }
开发者ID:Hovik123,项目名称:laravel-angularjs,代码行数:30,代码来源:PostController.php


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