Example #1
1
 public function onPost()
 {
     $question = Html::clean(post('question'));
     $reply_email = post('email');
     $validator = Validator::make(['question' => $question, 'reply_email' => $reply_email], ['question' => 'required', 'reply_email' => 'email']);
     if ($validator->fails()) {
         Flash::error('Please enter the question');
     } else {
         $ask = new Question();
         $ask->question = $question;
         /**
          * Saving question in DB
          **/
         $ask->is_approved = '0';
         $ask->category_id = '0';
         $ask->reply_email = $reply_email;
         $ask->save();
         /**
          * Sending email to admin
          **/
         $params = compact('question');
         Mail::send('redmarlin.faq::mail.asked', $params, function ($message) {
             $message->to(MailSettings::get('sender_email'));
             $email = post('email');
         });
         Flash::success('Your question was received correctly.');
     }
 }
Example #2
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $postId) {
             if (!($post = Question::find($postId))) {
                 continue;
             }
             $post->delete();
         }
         Flash::success('Question Deleted', ['name' => 'Question']);
     }
     return $this->listRefresh();
 }
Example #3
0
 public function onRun()
 {
     $query = Question::whereIsApproved('1')->where('category_id', $this->property('categoryId'));
     switch ($this->property('sortOrder')) {
         case "desc":
             $query = $query->orderBy('id', 'desc');
             break;
         case "asc":
             $query = $query->orderBy('id', 'asc');
             break;
         case "order":
             $query = $query->orderBy('sort_order');
             break;
     }
     $query = $query->orderBy('id', 'desc');
     $this->faqs = $query->with('category')->get();
     $this->page['category'] = Category::where('id', $this->property('categoryId'))->pluck('title');
 }
Example #4
0
 public function onRun()
 {
     $this->faqsfeatured = Question::whereIsApproved('1')->whereIsFeatured('1')->orderBy('id', 'desc')->take($this->property['featuredNumber'])->get();
 }
Example #5
0
 public function onRun()
 {
     $this->faqs = Question::whereIsApproved('1')->orderBy('id', 'desc')->with('category')->take($this->property['questionNumber'])->get();
 }