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


PHP News::create方法代码示例

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


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

示例1: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         News::create([]);
     }
 }
开发者ID:jairoserrano,项目名称:SimpleBlogClase,代码行数:7,代码来源:NewsTableSeeder.php

示例2: postAction

 public function postAction()
 {
     // Create the new news
     $this->getConnectedUser()->assertRight('news_create');
     $_POST['news_title_url'] = urlencode($_POST['news_title']);
     if (!array_key_exists("news_date", $_POST)) {
         $_POST["news_date"] = time();
     } else {
         list($day, $month, $year) = split('[/.-]', $_POST["news_date"]);
         $_POST["news_date"] = mktime("0", "0", "0", $month, $day, $year);
     }
     if (!array_key_exists("news_publish", $_POST)) {
         $_POST["news_publish"] = 0;
     } else {
         if ($_POST["news_publish"] == "on") {
             $_POST["news_publish"] = 1;
         } else {
             $_POST["news_publish"] = 0;
         }
     }
     if (News::exists($_POST)) {
         throw new Knb_Error("An news with the name {${$_POST['news_title']}} already exists for date this date");
     }
     News::create($_POST);
     $this->setParameter("date", date("Y/m/d", $_POST["news_date"]));
     $this->setParameter("news_title_url", $_POST['news_title_url']);
 }
开发者ID:Riges,项目名称:KawaiViewModel,代码行数:27,代码来源:news_Controller.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 100) as $index) {
         News::create(['title' => $faker->text(20 + $faker->numberBetween(10, 100)), 'content' => $faker->text(400 + $faker->numberBetween(10, 250)), 'image' => 'http://www.bumultimedia.com/trabajos/marcaDiferenciada/mansionMascotas/images/news_' . $faker->numberBetween(1, 5) . '.png', 'publish' => $faker->randomElement([1, 2])]);
     }
 }
开发者ID:jairom0704,项目名称:dental_office,代码行数:7,代码来源:NewsTableSeeder.php

示例4: create

 function create($params){
     $params['author_id'] = User::$current->id;
     if(News::create($params, $obj)){
         //Event::trigger(Event::TYPE_ACCOUNT_BAN, User::$current->account, $obj->account);
         $this->render_ajax('success', 'Successfully added');
     } else {
         $this->render_ajax('error', 'Error! ' . $obj->errors[0]);
     }
 }
开发者ID:reddragon010,项目名称:RG-ServerPanel,代码行数:9,代码来源:NewsController.php

示例5: store

 /**
  * Store a newly created news in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), News::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     News::create($data);
     return Redirect::route('news.index');
 }
开发者ID:jairoserrano,项目名称:SimpleBlogClase,代码行数:14,代码来源:NewsController.php

示例6: create

 public function create($request)
 {
     $params = $request->getParameters();
     $data = ['success' => false];
     $user = Session::get();
     if ($params['title'] != '' && $params['content'] != '') {
         $new = News::create(['user_id' => $user->id, 'title' => $params['title'], 'content' => $params['content'], 'icon' => $params['icon'], 'level' => $params['level'], 'timestamp' => Utils::tps()]);
         $data['success'] = is_object($new);
     }
     return new JsonResponse($data);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:11,代码来源:news_controller.php

示例7: postAdd

 public function postAdd()
 {
     $validator = Validator::make(Input::all(), News::$rules);
     if ($validator->fails()) {
         return Redirect::route('news-add')->withErrors($validator)->withInput();
     }
     $user_id = Auth::user()->id;
     $new = News::create(array('title' => Input::get('title'), 'url' => Input::get('url'), 'description' => Input::get('description'), 'user_id' => $user_id, 'permalink' => Tools::permalink(Input::get('title'))));
     if (Input::hasFile('cover_image')) {
         $media = new Media();
         $cover_image = $media->addMedia('cover_image', $new, $user_id, 'news-add');
         $new->update(array('cover_image' => $cover_image));
     }
     $new->save();
     return Redirect::route('news')->with('status', 'alert-success')->with('global', 'You have successfully added a new artist/partner.');
 }
开发者ID:mlauren,项目名称:midway-gallery,代码行数:16,代码来源:NewsController.php

示例8: run

 public function run()
 {
     $faker = Faker::create();
     $title = $faker->sentence();
     News::create(['created_at' => $faker->date($format = 'Y-m-d', $max = 'now'), 'title' => $title, 'alias' => Slug::make($title, '-'), 'body' => $faker->text($maxNbChars = 800), 'image' => '/public/files/Фото для сайта/Фото на новости/thumb-up.jpeg']);
     foreach (range(1, 22) as $index) {
         $title = $faker->sentence();
         News::create(['created_at' => $faker->date($format = 'Y-m-d', $max = 'now'), 'title' => $title, 'alias' => Slug::make($title, '-'), 'body' => $faker->text($maxNbChars = 800), 'image' => $faker->imageUrl($width = 640, $height = 480)]);
         // foreach(range(1, 10) as $cindex)
         // {
         //     Comment::create([
         //         'created_at' => $faker->date($format = 'Y-m-d', $max = 'now'),
         //         'author' => $faker->name,
         //         'body' => $faker->text($maxNbChars = 200),
         //         'news_id' => $index,
         //     ]);
         // }
     }
 }
开发者ID:VerticalHorizon,项目名称:Bumagi,代码行数:19,代码来源:NewsTableSeeder.php

示例9: httpResponse

     httpResponse($watchSubtitles->delete((int) $params[1]));
     break;
 case validateRoute('GET', 'users/\\d+/forum-posts'):
     $forum = new Forum($db, $user);
     list($result, $totalCount) = $forum->getUserPosts((int) $params[1], (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'news'):
     $news = new News($db, $user);
     $arr = $news->query((int) $_GET["limit"] ?: 2, $_GET["markAsRead"] ?: "false");
     httpResponse($arr);
     break;
 case validateRoute('POST', 'news'):
     $forum = new Forum($db, $user);
     $news = new News($db, $user, $forum);
     httpResponse($news->create($postdata));
     break;
 case validateRoute('PATCH', 'news/\\d+'):
     $news = new News($db, $user);
     httpResponse($news->update($params[1], $postdata));
     break;
 case validateRoute('DELETE', 'news/\\d+'):
     $news = new News($db, $user);
     httpResponse($news->delete($params[1]));
     break;
 case validateRoute('GET', 'suggestions'):
     $suggestions = new Suggestions($db, $user);
     $arr = $suggestions->get($_GET["view"] ?: 'top', (int) $_GET["limit"] ?: 10);
     httpResponse($arr);
     break;
 case validateRoute('POST', 'suggestions/\\d+/votes'):
开发者ID:lordgabber,项目名称:rartracker,代码行数:31,代码来源:api-v1.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $news = News::create(array("contents" => Input::get('contents'), "date" => Input::get('date')));
     return View::make('news.manage');
 }
开发者ID:AmaniYunge,项目名称:SYoDeO,代码行数:10,代码来源:NewsController.php

示例11: function

<?php

require 'lib/Slim/Slim.php';
require_once 'lib/jwt_helper.php';
require_once 'lib/password.php';
require_once 'Helper.php';
require_once 'routes/news.php';
require_once 'routes/tags.php';
require_once 'routes/resource.php';
require_once 'routes/category.php';
require_once 'routes/photo.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->group('/news', function () use($app) {
    News::create($app);
});
$app->group('/tags', function () use($app) {
    Tags::create($app);
});
$app->group('/resources', function () use($app) {
    Resource::create($app);
});
$app->group('/category', function () use($app) {
    Category::create($app);
});
$app->group('/album', function () use($app) {
    Photo::create($app);
});
$app->get('/ninja', function () use($app) {
    chdir('../ninja');
    $ninja = glob('*');
开发者ID:PisaCoderDojo,项目名称:dojo-wp-site,代码行数:31,代码来源:index.php

示例12: create

 static function create()
 {
     parent::create(self::$category_id, self::$acf_id);
 }
开发者ID:gato-gordo,项目名称:association-print-scholars,代码行数:4,代码来源:NewsSubclasses.php

示例13: header

<?php

echo "<div id='news_add' class='container-fluid bg-grey text-center'>";
if (isset($_POST['news_title']) && isset($_POST['news_text'])) {
    $error = "";
    $flag = true;
    if (trim($_POST['news_title']) == "") {
        $error = $error . "Заголовок новини не може бути порожнім" . "<br>";
        $flag = false;
    }
    if (trim($_POST['news_text']) == "") {
        $error = $error . "Текст новини не може бути порожнім" . "<br>";
        $flag = false;
    }
    if (!$flag) {
        echo "<div class='panel panel-danger col-sm-10 col-sm-offset-1'>\n\t\t\t\t\t<div class='panel-heading'><strong>Увага!</strong> Поверніться та заповніть необхідні поля.</div><div class='panel-body'>" . $error . "</div></div>";
    } else {
        $record = [];
        $record['title'] = $_POST['news_title'];
        $record['text'] = $_POST['news_text'];
        $record['author_id'] = $_SESSION['id'];
        //$record['date'] = date("");
        $record['published'] = false;
        News::create($record);
        echo "<div class='alert alert-success col-sm-10 col-sm-offset-1'><strong>Успіх!</strong> Новина була успішно додана. Очікуйте перевірки модератором.</div>";
    }
} else {
    header("Location: ./index.php?action=add_news");
}
echo "</div>";
开发者ID:alexsoft23,项目名称:fun-porsche,代码行数:30,代码来源:news_add.php


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