public function run() { DB::table('Posts')->delete(); Post::insert(['title' => 'First Post', 'slug' => 'first-post', 'excerpt' => 'First Post body', 'content' => 'Content First Post body', 'published' => true, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]); Post::insert(['title' => 'Second Post', 'slug' => 'second-post', 'excerpt' => 'Second Post body', 'content' => 'Content Second Post body', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]); Post::insert(['title' => 'Third Post', 'slug' => 'third-post', 'excerpt' => 'Third Post body', 'content' => 'Content Third Post body', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]); }
public function add_post() { $validator = models\Post::validator('add'); if (!empty($_POST)) { if ($validator->validate($_POST)) { $insert = $validator->output; $insert['author_id'] = $this->user->UserID(); $insert['created_on'] = time(); if ($pid = models\Post::insert($insert)) { $post = models\Post::get($pid); Session::success('Post Created. Look:'); // Send e-mail to $this->user's followers /* foreach ( $this->user->user->followers AS $user ) { Email::make($user->email, 'New post by '.$user, $user.' posted a new message on the blog. Read it at '.$post->url(array('absolute' => true)))->send(); }*/ $this->_redirect($post->url()); } Session::error('Couldn\'t save... =( Try again!?'); } } $categories = $validator->options->categories; $messages = Session::messages(); return $this->tpl->display('blog/post_form', get_defined_vars()); }