/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $topics = Topic::all();
     $markdown = new Markdown();
     $transfer_count = 0;
     $convert_count = 0;
     foreach ($topics as $topic) {
         if (empty($topic->body_original)) {
             // store the original data
             $topic->body_original = $topic->body;
             // convert to markdown
             $topic->body = $markdown->convertMarkdownToHtml($topic->body);
             $topic->save();
             $transfer_count++;
         } else {
             // convert to markdown
             $topic->body = $markdown->convertMarkdownToHtml($topic->body_original);
             $topic->save();
             $convert_count++;
         }
     }
     $this->info("Transfer old data count: " . $transfer_count);
     $this->info("Convert original to body count: " . $convert_count);
     $this->info("It's Done, have a good day.");
 }
Exemple #2
0
 public function update($id)
 {
     $topic = Topic::findOrFail($id);
     $data = Input::only('title', 'body', 'node_id');
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     $markdown = new Markdown();
     $data['body_original'] = $data['body'];
     $data['body'] = $markdown->convertMarkdownToHtml($data['body']);
     $data['excerpt'] = Topic::makeExcerpt($data['body']);
     // Validation
     App::make('Phphub\\Forms\\TopicCreationForm')->validate($data);
     $topic->update($data);
     Flash::success(lang('Operation succeeded.'));
     return Redirect::route('topics.show', $topic->id);
 }