• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP app\Posts类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: run

 public function run()
 {
     DB::table('posts')->delete();
     Posts::create(array('author_id' => 1, 'slug' => 'post1', 'title' => 'post 1 title ', 'body' => 'post 1 body!', 'active' => true));
     Posts::create(array('author_id' => 1, 'slug' => 'post2', 'title' => 'post 2 title', 'body' => 'post 2 body!', 'active' => true));
     Posts::create(array('author_id' => 1, 'slug' => 'post3', 'title' => 'post 3 title ', 'body' => 'post 3 body!', 'active' => true));
     Posts::create(array('author_id' => 1, 'slug' => 'post4', 'title' => 'post 4 title', 'body' => 'post 4 body!', 'active' => true));
     Posts::create(array('author_id' => 1, 'slug' => 'post5', 'title' => 'post 5 title ', 'body' => 'post 5 body!', 'active' => true));
     Posts::create(array('author_id' => 1, 'slug' => 'post6', 'title' => 'post 6 title', 'body' => 'post 6 body!', 'active' => true));
 }
开发者ID:vahidahmad,项目名称:laravel-api-blog,代码行数:10,代码来源:PostTableSeeder.php


示例17: deletePost

 public function deletePost($deletePostId)
 {
     $deletePost = Posts::find($deletePostId);
     if ($deletePost->photo != 'noImage.jpg') {
         //delete the image associative with the post
         \File::Delete('img/Post/' . $deletePost->photo);
     }
     $deletePost->delete();
     return redirect('admin');
 }
开发者ID:np-patel,项目名称:exploreTasman,代码行数:10,代码来源:AdminController.php


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


示例19: showpdf

 public function showpdf($slug)
 {
     $artikel = \App\Posts::where('slug', $slug)->first();
     if (!empty($artikel)) {
         $data = array('data' => $artikel);
         $pdf = \PDF::loadview('artikel.pdf', $data);
         return $pdf->stream($slug . 'pdf');
     } else {
         return redirect(url());
     }
 }
开发者ID:AsepSanjay,项目名称:blog,代码行数:11,代码来源:WelcomeController.php


示例20: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $rules = array('title' => 'required|max:255|min:5|string', 'body' => 'required|max:2000|min:5|string', 'browser' => 'min:1|max:20');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('create')->withErrors($validator);
     }
     $data = array('title' => Purifier::clean($request->input('title')), 'body' => Purifier::clean($request->input('body')), 'image' => Purifier::clean($request->input('image')), 'ip' => $request->getClientIp(), 'browser' => Purifier::clean($request->input('browser')), 'country' => UserClients::getCountry($request->getClientIp()), 'date' => time());
     Posts::create($data);
     return Redirect::to('/');
 }
开发者ID:sstetsurin,项目名称:testdesk,代码行数:17,代码来源:PostsController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP app\Product类代码示例发布时间:2022-05-23
下一篇:
PHP app\Post类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap