本文整理汇总了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([]);
}
}
示例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']);
}
示例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])]);
}
}
示例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]);
}
}
示例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');
}
示例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);
}
示例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.');
}
示例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,
// ]);
// }
}
}
示例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'):
示例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');
}
示例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('*');
示例12: create
static function create()
{
parent::create(self::$category_id, self::$acf_id);
}
示例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>";