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


PHP app\Posts类代码示例

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


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

示例1: run

 public function run()
 {
     $posts_model = new Posts();
     $most = $posts_model->most_view();
     //dd($most);
     return view("widgets.most_view", ['most_view_posts' => $most]);
 }
开发者ID:kooler62,项目名称:liveandlearn,代码行数:7,代码来源:MostView.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $xml = simplexml_load_file('http://www.buzzfeed.com/index.xml', 'SimpleXMLElement', LIBXML_NOCDATA);
     $count = 0;
     foreach ($xml->channel->item as $article) {
         $title = $article->title;
         $url = $article->link;
         $author = $article->author;
         $start = strpos($article->pubDate, ',');
         $date = substr($article->pubDate, $start + 2, -15);
         $date = explode(' ', $date);
         $day = $date[0];
         //day
         $month = $date[1];
         //month
         $month = substr(Carbon::parse($month), 5, 2);
         $year = $date[2];
         //year
         $date = substr(Carbon::createFromFormat("Y-m-d", $year . "-" . $month . "-" . $day), 0, 10);
         $description = $article->description;
         $imgPos = strpos($description, '<img');
         $imgUrl = null;
         if ($imgPos != null) {
             $imgString = substr($description, $imgPos);
             $srcPos = strpos($imgString, 'src=');
             $src = substr($imgString, $srcPos + 5);
             $tok = '"';
             $endQuotePos = strpos($src, $tok);
             $imgUrl = substr($src, 0, $endQuotePos);
         }
         $id = DB::table('email_articles')->where('post_date', $date)->value('article_id');
         if ($count < 5) {
             if (!isset($imgUrl)) {
             } else {
                 if (Posts::where('title', '=', $title)->exists()) {
                     echo $title . " already exists";
                 } else {
                     $post = new Posts();
                     $post->article_id = $id;
                     $post->author = $author;
                     $post->title = $title;
                     $post->description = 'N/A';
                     $post->imgUrl = $imgUrl;
                     $post->url = $url;
                     $post->source = 'BuzzFeed';
                     $post->save();
                     echo "stored " . $title . "!";
                 }
                 $count++;
             }
         }
     }
 }
开发者ID:kcunanan,项目名称:claremontrise,代码行数:58,代码来源:GetBuzzFeed.php

示例3: post_year

 public function post_year($year)
 {
     // возвращаем посты за year
     # обращаемся к моделе Category
     $Categories = new Categories();
     $categories = $Categories->cats_for_header();
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     $Posts_model = new Posts();
     $posts = $Posts_model->post_of_year($year);
     return view('layouts.default', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'posts_content', 'posts' => $posts]);
 }
开发者ID:kooler62,项目名称:liveandlearn,代码行数:13,代码来源:PostController.php

示例4: index

 public function index()
 {
     # обращаемся к моделе Category
     $vrode_model = new Categories();
     $categories = $vrode_model->cats_for_header();
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     //Получение разбитого на страницы запроса из базы данных:
     $postsi = new Posts();
     $per_page = 10;
     $posts = $postsi->post_paginate($per_page);
     return view('layouts.default', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'posts_content', 'posts' => $posts]);
 }
开发者ID:kooler62,项目名称:liveandlearn,代码行数:14,代码来源:PostsController.php

示例5: user_posts_draft

 public function user_posts_draft(Request $request)
 {
     $user = $request->user();
     $posts = Posts::where('author_id', $user->id)->where('active', '0')->orderBy('created_at', 'desc')->paginate(5);
     $title = $user->name;
     return view('home')->withPosts($posts)->withTitle($title);
 }
开发者ID:Kristian95,项目名称:LaravelBlog,代码行数:7,代码来源:UserController.php

示例6: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $slug)
 {
     $category = Categories::where('slug', $slug)->first();
     $posts = Posts::where('category_id', $category->id)->orderBy('created_at', 'desc')->paginate(5);
     $title = 'Posts from category ' . $category->title;
     return view('categories.show')->withPosts($posts)->withCategory($category)->withTitle($title);
 }
开发者ID:calimanleontin,项目名称:bet,代码行数:13,代码来源:CategoryController.php

示例7: userPosts

 public function userPosts()
 {
     $posts = \App\Posts::where('user_id', '=', \Auth::user()->id)->orderBy("created_at", "desc")->get();
     $search_info = "";
     $data = array('posts' => $posts, 'search_info' => \Auth::user()->name . '\'s posts', 'users' => \App\User::get());
     return view('home')->with($data);
 }
开发者ID:steakyfask,项目名称:ShareStuff,代码行数:7,代码来源:HomeController.php

示例8: saveScore

 public function saveScore(Request $request)
 {
     if (!auth() || !auth()->user()) {
         echo 'Kết quả chưa được lưu.';
         return;
     }
     $UserID = auth()->user()->getAuthIdentifier();
     $data = $request->all();
     $token = $data['token'];
     // day by day, no. of record will increase
     // => maybe there are multiple record with the same value of UserID and token
     // => pick the newest record
     $record = Doexams::where('token', 'LIKE', $token)->where('UserID', '=', $UserID)->get()->last();
     if (count($record->toArray()) < 1) {
         echo 'Kết quả chưa được lưu.';
         return;
     }
     $record->Score = $request['Score'] . '/' . $request['MaxScore'];
     $record->update();
     $oldDateTime = $record->created_at->getTimestamp();
     $newDateTime = $record->updated_at->getTimestamp();
     $diff = ($newDateTime - $oldDateTime) / 3600.0;
     $record->Time = $diff;
     $record->update();
     if ($diff > 0) {
         $course = Courses::find(Posts::find($record->PostID)->CourseID);
         $course->TotalHours += $diff;
         $course->update();
     }
     echo 'Kết quả đã được lưu lại.';
     return;
 }
开发者ID:ngocdon0127,项目名称:e-learning,代码行数:32,代码来源:DoexamsController.php

示例9: renderDefault

 public function renderDefault()
 {
     $this->template->anyVariable = 'any value';
     //		$dao = $this->articles;
     $this->template->articles = $this->articles->getArticles()->findAll();
     $posts = $this->EntityManager->getRepository(Posts::getClassName());
     $this->template->posts = $posts->findAll();
     $this->template->myparametr = $this->context->parameters['first_parametr'];
     //		$this->template->test = $this->doSomeRefactoring('Hello world from blog');
     //		$post = new Posts();
     //		$post->title = 'New title';
     //		$post->text = 'New text New textNew text';
     //		$post->created_at = new \Nette\Utils\DateTime;
     //
     //
     //		$this->EntityManager->persist($post);
     //		$this->EntityManager->flush();
     //		$dao = $this->EntityManager->getRepository(Posts::getClassName());
     //		$dao->setTitle('test');
     //		$dao->__call('set', ['title' => 'my title']);
     //		dump($dao->__isset('title'));
     //		$dao->__set('title', 'test');
     try {
         $this->checkNum(2);
         \Tracy\Debugger::barDump('If you see this, the number is 1 or below');
     } catch (Nette\Application\BadRequestException $e) {
         Debugger::log('Message: ' . $e->getMessage());
         var_dump($e->getMessage());
     }
     //		finally {
     //			\Tracy\Debugger::barDump('Got here Finally');
     //		}
 }
开发者ID:regiss,项目名称:doctrine-sand,代码行数:33,代码来源:Blog.php

示例10: index

 public function index()
 {
     $posts = Posts::with('comments')->where('active', 1)->orderBy('created_at', 'desc')->paginate(5);
     if (Auth::check()) {
         return view('pages.velkommen', array('currentUser' => Auth::user()))->with('posts', $posts);
     }
     return view('pages.velkommen')->with('posts', $posts);
 }
开发者ID:nilsma,项目名称:agtp,代码行数:8,代码来源:WelcomeController.php

示例11: run

 public function run()
 {
     //create post sides
     DB::table('posts')->delete();
     for ($i = 0; $i < 5; $i++) {
         \App\Posts::create(['title' => "first post {$i}", 'description' => "this is a {$i} post description", "content" => "this is a {$i} post content"]);
     }
 }
开发者ID:Hovik123,项目名称:laravel-angularjs,代码行数:8,代码来源:PostTableSeeder.php

示例12: idoso

 public function idoso()
 {
     $posts = \App\Posts::where('tipo', '=', 'postagem')->where('categoria_id', '!=', 7)->latest()->take(8)->get();
     $numero = 4;
     $programas = \App\Posts::where('tipo', '=', 'programas')->orderBy('id', 'desc')->take(6)->where('grupo_id', '=', $numero)->get();
     // dd($posts);
     return view('persona4', compact('posts', 'numero', 'programas'));
 }
开发者ID:ronal2do,项目名称:stq001,代码行数:8,代码来源:PagesController.php

示例13: 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

示例14: show

 public function show($slug)
 {
     $post = Posts::where('slug', $slug)->first();
     if (!$post) {
         return redirect('/')->withErrors('Page not found');
     }
     $comments = $post->comments;
     return view('posts.show')->withPost($post)->withComments($comments);
 }
开发者ID:Kristian95,项目名称:LaravelBlog,代码行数:9,代码来源:PostController.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = \Faker\Factory::create();
     //Posts::truncate();
     foreach (range(1, 10) as $index) {
         $user = User::All()->random(1);
         Posts::create(['author_id' => $user->id, 'title' => $faker->sentence(3), 'body' => $faker->text, 'slug' => $faker->slug(), 'active' => 1]);
     }
 }
开发者ID:dikyarga,项目名称:sistem-informasi-organisasi-dengan-laravel,代码行数:14,代码来源:PostTableSeeder.php


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