public function postTestimonials() { $txt = Input::get('txt'); $getTestimonials = new Testimonials(); $getTestimonials['user_id'] = Auth::User()['id']; $getTestimonials['testimonials'] = $txt; if (!$getTestimonials->save()) { return View::make('testimonials.index')->with('mt', "TESTIMONIALS")->with('alert', 'fail')->with('msg', 'You have failed to created testimonials'); } return View::make('testimonials.index')->with('mt', "TESTIMONIALS")->with('alert', 'success')->with('msg', 'Successfully created testimonials'); }
<?php require_once "{$path_prefix}/api/Testimonials/Testimonials.php"; global $page_uid, $login_uid; if ($_form) { $testi = new Testimonials(); $testi->sender_id = $login_uid; $testi->recipient_id = $page_uid; $testi->body = $_form['body']; try { $id = $testi->save(); } catch (PAException $e) { $msg = $e->message; $code = $e->code; } } // Here we call the function $msg_array = array(); $msg_array['failure_msg'] = $msg; $msg_array['success_msg'] = 9013; $login = User::get_login_name_from_id($page_uid); $current_url = PA::$url . '/' . FILE_USER_BLOG . '?uid=' . $page_uid; $url_perms = array('current_url' => $current_url, 'login' => $login); $url = get_url(FILE_USER_BLOG, $url_perms); $redirect_url = $url; set_web_variables($msg_array, $redirect_url);
public function testSaveWithInvalidRecipientId() { $testi = new Testimonials(); $testi->sender_id = 3; $testi->recipient_id = 'xyz'; $testi->body = 'testimonial with empty Sender id'; try { $id = $testi->save(); } catch (PAException $e) { $error = $e->message; $code = $e->code; } $this->assertEquals($code, USER_NOT_FOUND); }