本文整理汇总了PHP中app\Article::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::insert方法的具体用法?PHP Article::insert怎么用?PHP Article::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
$user_id = User::lists('id');
$limit = 139;
for ($i = 0; $i < $limit; $i++) {
Article::insert(['title' => $faker->sentence(7), 'body' => $faker->paragraph(3), 'created_by' => $faker->numberBetween($min = 1, $max = 15)]);
}
}
示例2: addArticleAjax
public function addArticleAjax()
{
$title = isset($_POST["title"]) ? $_POST["title"] : "";
$summary = isset($_POST["summary"]) ? $_POST["summary"] : "";
$content = isset($_POST["content"]) ? $_POST["content"] : "";
$category = isset($_POST["category"]) ? $_POST["category"] : "";
$author = isset($_POST["author"]) ? $_POST["author"] : "";
if (empty($title) || empty($summary) || empty($content) || empty($category) || empty($author)) {
return false;
}
$data = array("title" => $title, "alias" => $this->remove_utf8($title), "summary" => $summary, "content" => $content, "category_id" => $category, "author" => $author, "status" => 1, "creator_id" => Auth::user()["id"], "created_date" => date("Y-m-d H:i:s"));
Article::insert($data);
return view('admin.article.new');
}