diff --git a/app/Http/Controllers/MembersController.php b/app/Http/Controllers/MembersController.php index 23a7a72fb1dfb078e95de2d8477a1e3021ad9267..93708f5bbe59e7afef8500212fdc8228bb7d50f0 100644 --- a/app/Http/Controllers/MembersController.php +++ b/app/Http/Controllers/MembersController.php @@ -16,7 +16,7 @@ class MembersController extends Controller { public function __construct() { - $this->middleware('admin', ['except' => ['show', 'edit', 'update']]); + //$this->middleware('admin', ['except' => ['show', 'edit', 'update']]); } /** @@ -26,8 +26,19 @@ class MembersController extends Controller */ public function index() { + $isMember = Auth::guard('member')->user() != null; + $isAdmin = Auth::user() != null && Auth::user()->IsAdmin == 1; + + if(!($isMember || $isAdmin)) + return redirect('/'); + $members = Member::orderBy('nim','asc')->paginate(20); - return view('members.list')->with('members', $members); + if ($isAdmin) { + return view('members.list')->with('members', $members); + } else { + return view('showmember')->with('members', $members); + } + } /** @@ -191,6 +202,11 @@ class MembersController extends Controller */ public function destroy($id) { + $isAdmin = Auth::user() != null && Auth::user()->IsAdmin == 1; + + if(!$isAdmin) + return redirect('/'); + $user = Member::find($id); if($user !== null) { $user->delete(); diff --git a/database/factories/AnswerFactory.php b/database/factories/AnswerFactory.php index 0ee1d2da5bae67bc456e2626324a94671327e14a..db109023d5b11168f90453f4b7407758e362363f 100644 --- a/database/factories/AnswerFactory.php +++ b/database/factories/AnswerFactory.php @@ -8,6 +8,7 @@ $factory->define(App\Answer::class, function (Faker $faker) { 'body' => 'Answer for Testing', 'is_admin' => 1, 'member_id' => -1, + 'user_id' => -1, 'is_pinned' => 0 ]; }); diff --git a/database/factories/QuestionFactory.php b/database/factories/QuestionFactory.php index b0142f9cbbdc6f8a76019d4756eac7e2b9858ade..d8a59315a81bfc94545a6f04d37e18f16676c1f4 100644 --- a/database/factories/QuestionFactory.php +++ b/database/factories/QuestionFactory.php @@ -7,6 +7,7 @@ $factory->define(App\Question::class, function (Faker $faker) { 'topic' => 'Question for Testing', 'body' => 'Is This Question One?', 'is_admin' => 1, - 'member_id' => -1 + 'member_id' => -1, + 'user_id' => -1 ]; }); diff --git a/public/storage/cover_images/default_1523239675.png b/public/storage/cover_images/default_1523239675.png deleted file mode 100644 index c1c215cc6e9ab2cfd70254373103c3c9cb055bce..0000000000000000000000000000000000000000 Binary files a/public/storage/cover_images/default_1523239675.png and /dev/null differ diff --git a/public/storage/cover_images/default_1523320168.png b/public/storage/cover_images/default_1523320168.png deleted file mode 100644 index c1c215cc6e9ab2cfd70254373103c3c9cb055bce..0000000000000000000000000000000000000000 Binary files a/public/storage/cover_images/default_1523320168.png and /dev/null differ diff --git a/public/storage/cover_images/default_1523968595.png b/public/storage/cover_images/default_1523968595.png deleted file mode 100644 index c1c215cc6e9ab2cfd70254373103c3c9cb055bce..0000000000000000000000000000000000000000 Binary files a/public/storage/cover_images/default_1523968595.png and /dev/null differ diff --git a/public/storage/cover_images/handshake_1524196826.png b/public/storage/cover_images/handshake_1524196826.png deleted file mode 100644 index 1e61e42382cf4ddeb885e5b1b740d77f44a67c1a..0000000000000000000000000000000000000000 Binary files a/public/storage/cover_images/handshake_1524196826.png and /dev/null differ diff --git a/public/storage/cover_images/logo_1523371958.png b/public/storage/cover_images/logo_1523371958.png deleted file mode 100644 index 3e314147a8c70088fc7dcbee14eedd0926fa7a4a..0000000000000000000000000000000000000000 Binary files a/public/storage/cover_images/logo_1523371958.png and /dev/null differ diff --git a/public/storage/cover_images/logo_itb_1523312786.png b/public/storage/cover_images/logo_itb_1524570709.png similarity index 100% rename from public/storage/cover_images/logo_itb_1523312786.png rename to public/storage/cover_images/logo_itb_1524570709.png diff --git a/public/storage/cover_images/logo_itb_1523312787.png b/public/storage/cover_images/logo_itb_1524570710.png similarity index 100% rename from public/storage/cover_images/logo_itb_1523312787.png rename to public/storage/cover_images/logo_itb_1524570710.png diff --git a/public/storage/cover_images/logo_itb_1523322507.png b/public/storage/cover_images/logo_itb_1524570784.png similarity index 100% rename from public/storage/cover_images/logo_itb_1523322507.png rename to public/storage/cover_images/logo_itb_1524570784.png diff --git a/public/storage/cover_images/logo_itb_1524378311.png b/public/storage/cover_images/logo_itb_1524570785.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524378311.png rename to public/storage/cover_images/logo_itb_1524570785.png diff --git a/public/storage/cover_images/logo_itb_1524378312.png b/public/storage/cover_images/logo_itb_1524573686.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524378312.png rename to public/storage/cover_images/logo_itb_1524573686.png diff --git a/public/storage/cover_images/logo_itb_1524380362.png b/public/storage/cover_images/logo_itb_1524573687.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380362.png rename to public/storage/cover_images/logo_itb_1524573687.png diff --git a/public/storage/cover_images/logo_itb_1524380363.png b/public/storage/cover_images/logo_itb_1524577271.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380363.png rename to public/storage/cover_images/logo_itb_1524577271.png diff --git a/public/storage/cover_images/logo_itb_1524380495.png b/public/storage/cover_images/logo_itb_1524577585.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380495.png rename to public/storage/cover_images/logo_itb_1524577585.png diff --git a/public/storage/cover_images/logo_itb_1524380496.png b/public/storage/cover_images/logo_itb_1524577586.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380496.png rename to public/storage/cover_images/logo_itb_1524577586.png diff --git a/public/storage/cover_images/logo_itb_1524380765.png b/public/storage/cover_images/logo_itb_1524578516.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380765.png rename to public/storage/cover_images/logo_itb_1524578516.png diff --git a/public/storage/cover_images/logo_itb_1524380766.png b/public/storage/cover_images/logo_itb_1524578517.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380766.png rename to public/storage/cover_images/logo_itb_1524578517.png diff --git a/public/storage/cover_images/logo_itb_1524380911.png b/public/storage/cover_images/logo_itb_1524578607.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524380911.png rename to public/storage/cover_images/logo_itb_1524578607.png diff --git a/public/storage/cover_images/logo_itb_1524564379.png b/public/storage/cover_images/logo_itb_1524578608.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524564379.png rename to public/storage/cover_images/logo_itb_1524578608.png diff --git a/public/storage/cover_images/logo_itb_1524564381.png b/public/storage/cover_images/logo_itb_1524578692.png similarity index 100% rename from public/storage/cover_images/logo_itb_1524564381.png rename to public/storage/cover_images/logo_itb_1524578692.png diff --git a/public/storage/profile_image/logo_itb_1524564388.png b/public/storage/cover_images/logo_itb_1524578693.png similarity index 100% rename from public/storage/profile_image/logo_itb_1524564388.png rename to public/storage/cover_images/logo_itb_1524578693.png diff --git a/public/storage/cover_images/logo_itb_1524579442.png b/public/storage/cover_images/logo_itb_1524579442.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579442.png differ diff --git a/public/storage/cover_images/logo_itb_1524579443.png b/public/storage/cover_images/logo_itb_1524579443.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579443.png differ diff --git a/public/storage/cover_images/logo_itb_1524579652.png b/public/storage/cover_images/logo_itb_1524579652.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579652.png differ diff --git a/public/storage/cover_images/logo_itb_1524579653.png b/public/storage/cover_images/logo_itb_1524579653.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579653.png differ diff --git a/public/storage/cover_images/logo_itb_1524579723.png b/public/storage/cover_images/logo_itb_1524579723.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579723.png differ diff --git a/public/storage/cover_images/logo_itb_1524579724.png b/public/storage/cover_images/logo_itb_1524579724.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579724.png differ diff --git a/public/storage/cover_images/logo_itb_1524579757.png b/public/storage/cover_images/logo_itb_1524579757.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579757.png differ diff --git a/public/storage/cover_images/logo_itb_1524579758.png b/public/storage/cover_images/logo_itb_1524579758.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579758.png differ diff --git a/public/storage/cover_images/logo_itb_1524579834.png b/public/storage/cover_images/logo_itb_1524579834.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579834.png differ diff --git a/public/storage/cover_images/logo_itb_1524579835.png b/public/storage/cover_images/logo_itb_1524579835.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579835.png differ diff --git a/public/storage/cover_images/logo_itb_1524581618.png b/public/storage/cover_images/logo_itb_1524581618.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524581618.png differ diff --git a/public/storage/cover_images/logo_itb_1524581619.png b/public/storage/cover_images/logo_itb_1524581619.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524581619.png differ diff --git a/public/storage/cover_images/logo_itb_1524586499.png b/public/storage/cover_images/logo_itb_1524586499.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524586499.png differ diff --git a/public/storage/cover_images/logo_itb_1524586502.png b/public/storage/cover_images/logo_itb_1524586502.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524586502.png differ diff --git a/public/storage/cover_images/profile_1523679579.png b/public/storage/cover_images/profile_1523679579.png deleted file mode 100644 index 9799a6a4c02740c260531a2c1959661c653b4afc..0000000000000000000000000000000000000000 Binary files a/public/storage/cover_images/profile_1523679579.png and /dev/null differ diff --git a/public/storage/profile_image/New Doc 2018-04-23_4_1524567943.jpg b/public/storage/profile_image/New Doc 2018-04-23_4_1524567943.jpg deleted file mode 100644 index 5dd93a2f5d101cb781e6886026129a9cdb8698ea..0000000000000000000000000000000000000000 Binary files a/public/storage/profile_image/New Doc 2018-04-23_4_1524567943.jpg and /dev/null differ diff --git a/public/storage/cover_images/default_1523005766.png b/public/storage/profile_image/default_1524576646.png similarity index 100% rename from public/storage/cover_images/default_1523005766.png rename to public/storage/profile_image/default_1524576646.png diff --git a/public/storage/profile_image/logo_itb_1524570715.png b/public/storage/profile_image/logo_itb_1524570715.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524570715.png differ diff --git a/public/storage/profile_image/logo_itb_1524570788.png b/public/storage/profile_image/logo_itb_1524570788.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524570788.png differ diff --git a/public/storage/profile_image/logo_itb_1524573691.png b/public/storage/profile_image/logo_itb_1524573691.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524573691.png differ diff --git a/public/storage/profile_image/logo_itb_1524577275.png b/public/storage/profile_image/logo_itb_1524577275.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524577275.png differ diff --git a/public/storage/profile_image/logo_itb_1524577590.png b/public/storage/profile_image/logo_itb_1524577590.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524577590.png differ diff --git a/public/storage/profile_image/logo_itb_1524578521.png b/public/storage/profile_image/logo_itb_1524578521.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524578521.png differ diff --git a/public/storage/profile_image/logo_itb_1524578612.png b/public/storage/profile_image/logo_itb_1524578612.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524578612.png differ diff --git a/public/storage/profile_image/logo_itb_1524578697.png b/public/storage/profile_image/logo_itb_1524578697.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524578697.png differ diff --git a/public/storage/profile_image/logo_itb_1524579447.png b/public/storage/profile_image/logo_itb_1524579447.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579447.png differ diff --git a/public/storage/profile_image/logo_itb_1524579658.png b/public/storage/profile_image/logo_itb_1524579658.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579658.png differ diff --git a/public/storage/profile_image/logo_itb_1524579729.png b/public/storage/profile_image/logo_itb_1524579729.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579729.png differ diff --git a/public/storage/profile_image/logo_itb_1524579762.png b/public/storage/profile_image/logo_itb_1524579762.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579762.png differ diff --git a/public/storage/profile_image/logo_itb_1524579840.png b/public/storage/profile_image/logo_itb_1524579840.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579840.png differ diff --git a/public/storage/profile_image/logo_itb_1524581097.png b/public/storage/profile_image/logo_itb_1524581097.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581097.png differ diff --git a/public/storage/profile_image/logo_itb_1524581119.png b/public/storage/profile_image/logo_itb_1524581119.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581119.png differ diff --git a/public/storage/profile_image/logo_itb_1524581277.png b/public/storage/profile_image/logo_itb_1524581277.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581277.png differ diff --git a/public/storage/profile_image/logo_itb_1524581544.png b/public/storage/profile_image/logo_itb_1524581544.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581544.png differ diff --git a/public/storage/profile_image/logo_itb_1524581575.png b/public/storage/profile_image/logo_itb_1524581575.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581575.png differ diff --git a/public/storage/profile_image/logo_itb_1524581603.png b/public/storage/profile_image/logo_itb_1524581603.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581603.png differ diff --git a/public/storage/profile_image/logo_itb_1524581623.png b/public/storage/profile_image/logo_itb_1524581623.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581623.png differ diff --git a/public/storage/profile_image/logo_itb_1524581685.png b/public/storage/profile_image/logo_itb_1524581685.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581685.png differ diff --git a/public/storage/profile_image/logo_itb_1524581784.png b/public/storage/profile_image/logo_itb_1524581784.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581784.png differ diff --git a/public/storage/profile_image/logo_itb_1524581944.png b/public/storage/profile_image/logo_itb_1524581944.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581944.png differ diff --git a/public/storage/profile_image/logo_itb_1524581981.png b/public/storage/profile_image/logo_itb_1524581981.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581981.png differ diff --git a/public/storage/profile_image/logo_itb_1524582185.png b/public/storage/profile_image/logo_itb_1524582185.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582185.png differ diff --git a/public/storage/profile_image/logo_itb_1524582187.png b/public/storage/profile_image/logo_itb_1524582187.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582187.png differ diff --git a/public/storage/profile_image/logo_itb_1524582584.png b/public/storage/profile_image/logo_itb_1524582584.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582584.png differ diff --git a/public/storage/profile_image/logo_itb_1524582586.png b/public/storage/profile_image/logo_itb_1524582586.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582586.png differ diff --git a/public/storage/profile_image/logo_itb_1524582587.png b/public/storage/profile_image/logo_itb_1524582587.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582587.png differ diff --git a/public/storage/profile_image/logo_itb_1524582629.png b/public/storage/profile_image/logo_itb_1524582629.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582629.png differ diff --git a/public/storage/profile_image/logo_itb_1524582632.png b/public/storage/profile_image/logo_itb_1524582632.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582632.png differ diff --git a/public/storage/profile_image/logo_itb_1524583323.png b/public/storage/profile_image/logo_itb_1524583323.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583323.png differ diff --git a/public/storage/profile_image/logo_itb_1524583326.png b/public/storage/profile_image/logo_itb_1524583326.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583326.png differ diff --git a/public/storage/profile_image/logo_itb_1524583414.png b/public/storage/profile_image/logo_itb_1524583414.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583414.png differ diff --git a/public/storage/profile_image/logo_itb_1524583417.png b/public/storage/profile_image/logo_itb_1524583417.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583417.png differ diff --git a/public/storage/profile_image/logo_itb_1524584069.png b/public/storage/profile_image/logo_itb_1524584069.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584069.png differ diff --git a/public/storage/profile_image/logo_itb_1524584072.png b/public/storage/profile_image/logo_itb_1524584072.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584072.png differ diff --git a/public/storage/profile_image/logo_itb_1524584598.png b/public/storage/profile_image/logo_itb_1524584598.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584598.png differ diff --git a/public/storage/profile_image/logo_itb_1524584601.png b/public/storage/profile_image/logo_itb_1524584601.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584601.png differ diff --git a/public/storage/profile_image/logo_itb_1524585056.png b/public/storage/profile_image/logo_itb_1524585056.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524585056.png differ diff --git a/public/storage/profile_image/logo_itb_1524585058.png b/public/storage/profile_image/logo_itb_1524585058.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524585058.png differ diff --git a/public/storage/profile_image/logo_itb_1524586506.png b/public/storage/profile_image/logo_itb_1524586506.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524586506.png differ diff --git a/public/storage/profile_image/logo_itb_1524586509.png b/public/storage/profile_image/logo_itb_1524586509.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524586509.png differ diff --git a/resources/views/admin/profile.blade.php b/resources/views/admin/profile.blade.php index 7c3179ba1ea2825b4635b777f350982b585e5f3d..e1422d2088bdea62e05df2a1751c9dfd61080b38 100644 --- a/resources/views/admin/profile.blade.php +++ b/resources/views/admin/profile.blade.php @@ -142,19 +142,31 @@ <td class="user-info-left">Phone Number</td> <td>{{$userdata[3]->phone_number}}</td> </tr> + @if(Auth::guard('member')->user() != null && Auth::guard('member')->user()->id == $userdata[3]->id) <tr> <td class="user-info-left">Company</td> - <td>{{$userdata[3]->company}}</td> + <td> + @if(Auth::guard('member')->user()->company == 'none') + + @else + {{$userdata[3]->company}} + @endif + </td> </tr> <tr> <td class="user-info-left">Interest</td> - <td>{{$userdata[3]->interest}}</td> + <td> + @if(Auth::guard('member')->user()->interest == 'none') + + @else + {{$userdata[3]->interest}} + @endif + </td> </tr> <tr> <td class="user-info-left">Address</td> <td>{{$userdata[3]->address}}</td> </tr> - @if(Auth::guard('member')->user() != null && Auth::guard('member')->user()->id == $userdata[3]->id) @if(Auth::guard('member')->user()->email != null) <tr> <td class="user-info-left"> diff --git a/resources/views/admin/showeachanswer.blade.php b/resources/views/admin/showeachanswer.blade.php index 26a0b9ad620bdbef53f109aa9b429ec4676f3ee3..498e02db758532d6cbdb8582222e41d39efc1689 100644 --- a/resources/views/admin/showeachanswer.blade.php +++ b/resources/views/admin/showeachanswer.blade.php @@ -42,7 +42,7 @@ <tr> <td>Written By</td> @if ($answer->is_admin == 1) - <td>: {{$answer->user->name}} as <span style="color:blue;">admin</span></td> + <td>: {{$answer->user->name}} as <span style="color:red;">admin</span></td> @else <td>: {{$answer->member->name}}</td> @endif @@ -59,8 +59,6 @@ {{Form::submit('Delete', ['class' => 'btn btn-danger', 'onclick' => "return confirm('Are you sure you want to delete?')"])}} {!!Form::close() !!} @endif - <!--<br><br><br> - <a href="/admin/questions" class="btn btn-info pull-down">← Back</a>--> </div> </div> @endsection \ No newline at end of file diff --git a/resources/views/admin/showeachquestion.blade.php b/resources/views/admin/showeachquestion.blade.php index 90c6088d50ab35fb76e28f924293fa4b0e35e92b..b44e23c6e32a869d1b936166393a6f27fc896986 100644 --- a/resources/views/admin/showeachquestion.blade.php +++ b/resources/views/admin/showeachquestion.blade.php @@ -13,16 +13,16 @@ <small class="text-footer">Written on {{$question->created_at->format('d M Y')}}</small><br> <small class="text-footer">Last Editted on {{$question->updated_at->format('d M Y')}}</small><br> @if ($question->is_admin == 1) - <small class="text-footer">by {{$question->user->name}} as <span style="color:lightblue;">admin</span></small> + <small class="text-footer">by {{$question->user->name}} as <span style="color:red;">admin</span></small> @else - <small class="text-footer">by {{$question->member->name}}</small> + <small class="text-footer">by <a href="/admin/members/{{$question->member_id}}">{{$question->member->name}}</a></small> @endif @if ($question->is_anon == 1) - (anon) + anonymously @endif <hr> </div> - @if((!Auth::guest() && Auth::user()->IsAdmin == 1) || (Auth::guard('member')->user() != null && $question->member->id == Auth::guard('member')->user()->id && $question->is_admin == 0)) + @if((!Auth::guest() && Auth::user()->IsAdmin == 1) || (Auth::guard('member')->user() != null && $question->member_id == Auth::guard('member')->user()->id && $question->is_admin == 0)) <a href="/admin/questions/{{$question->id}}/edit" class="btn btn-warning edit-button"> Edit </a> @@ -68,15 +68,13 @@ <div class="col-9 pull-right"> <p style="word-wrap: break-word;">{{$answer->body}}</p> - <a href="/admin/answers/{{$answer->id}}"> - <small class="text-footer"> - @if ($answer->is_admin == 1) - Written on {{$answer->created_at->format('d M Y')}} by {{$answer->user->name}} as <span style="color:blue;">admin</span> - @else - Written on {{$answer->created_at->format('d M Y')}} by {{$answer->member->name}} - @endif - </small> - </a> + <small class="text-footer"> + @if ($answer->is_admin == 1) + <a href="/admin/answers/{{$answer->id}}">Written on {{$answer->created_at->format('d M Y')}}</a><br>by {{$answer->user->name}} as <span style="color:red;">admin</span> + @else + <a href="/admin/answers/{{$answer->id}}">Written on {{$answer->created_at->format('d M Y')}}</a><br>by <a href="/admin/members/{{$answer->member_id}}">{{$answer->member->name}}</a> + @endif + </small> <br> @if ($answer->created_at != $answer->updated_at) <small style="color:green;" class="text-footer">(edited)</small> @@ -142,20 +140,18 @@ '<span class="sum-rating">' + '0' + '</span>' + - '<form method="POST" action="/admin/answers/pin/' + data.id + '/' + data.question_id + '/1">' + + '<form method="POST" action="/admin/answers/pin/' + data.id + '/' + data.question_id + '/0">' + '<input type="hidden" name="_token" value="{{ csrf_token() }}">' + - '{{Form::button("<div class=\"btn-pinned\" <i class=\"fa fa-thumb-tack\"></i> PIN</div>", ["type" => "submit", "class" => "btn btn-warning", "data-toggle" => "tooltip"])}}' + + '{{Form::button("<div class=\"btn-pinned\"><i class=\"fa fa-thumb-tack\"></i> PIN</div>", ["type" => "submit", "class" => "btn btn-warning", "data-toggle" => "tooltip"])}}' + '</form>' + '</center>' + '</div>' + '<div class="col-9 pull-right">' + '<p>' + data.body + '</p>' + - '<a href="/admin/answers/' + data.id + '">' + '<small class="text-footer">' + - 'Written on ' + data.created + ' by ' + data.user.name + ' as <span style="color:blue;">admin</span>' + + '<a href="/admin/answers/' + data.id + '">Written on ' + data.created + '</a><br>by ' + data.user.name + ' as <span style="color:red;">admin</span>' + '</small>' + - '</a>' + '<br>' + '</div>' + '</div>' diff --git a/resources/views/admin/showquestion.blade.php b/resources/views/admin/showquestion.blade.php index 5ee33590a72ee0120c779eeb7b3d2dc29de807e0..897bac53ba2ef4e047f333f73b3e5e94cf685328 100644 --- a/resources/views/admin/showquestion.blade.php +++ b/resources/views/admin/showquestion.blade.php @@ -19,17 +19,17 @@ <div class="well col-12"> <div class="row"> <div class="col-12 post-card"> - <h3 class="title-question"><a href="/admin/questions/{{$question->id}}">{{$question->topic}}</a></h3> + <h3 class="title-question">{{$question->topic}}</h3> <p style="word-wrap: break-word;">{{$question->body}}</p> <small class="text-footer"> <i> @if ($question->is_admin == 1) - Written on {{$question->created_at->format('d M Y')}}<br>by {{$question->user->name}} as <span style="color:blue;">admin</span> + <a href="questions/{{$question->id}}">Written on {{$question->created_at->format('d M Y')}}</a><br>by {{$question->user->name}} as <span style="color:red;">admin</span> @else - Written on {{$question->created_at->format('d M Y')}}<br>by {{$question->member->name}} + <a href="questions/{{$question->id}}">Written on {{$question->created_at->format('d M Y')}}</a><br>by <a href="members/{{$question->member_id}}">{{$question->member->name}}</a> @endif @if ($question->is_anon == 1) - Anonymous + anonymously @endif </i> </small> @@ -73,15 +73,13 @@ <div class="col-8 pull-right"> <p style="word-wrap: break-word;">{{$answer->body}}</p> - <a href="/admin/answers/{{$answer->id}}"> <small class="text-footer"> @if ($answer->is_admin == 1) - Written on {{$answer->created_at->format('d M Y')}} by {{$answer->user->name}} as <span style="color:blue;">admin</span> + <a href="answers/{{$answer->id}}">Written on {{$answer->created_at->format('d M Y')}}</a><br>by {{$answer->user->name}} as <span style="color:red;">admin</span> @else - Written on {{$answer->created_at->format('d M Y')}} by {{$answer->member->name}} + <a href="answers/{{$answer->id}}">Written on {{$answer->created_at->format('d M Y')}}</a><br>by <a href="members/{{$answer->member_id}}">{{$answer->member->name}}</a> @endif </small> - </a> <br> @if ($answer->created_at != $answer->updated_at) <small style="color:green;" class="text-footer">(edited)</small> @@ -191,11 +189,9 @@ '<div class="col-8 pull-right">' + '<p>' + data.body + '</p>' + - '<a href="/admin/answers/' + data.id + '">' + '<small class="text-footer">' + - 'Written on ' + data.created + ' by ' + data.user.name + ' as <span style="color:blue;">admin</span>' + + '<a href="/admin/answers/' + data.id + '">Written on ' + data.created + '</a><br>by ' + data.user.name + ' as <span style="color:red;">admin</span>' + '</small>' + - '</a>' + '<br>' + '</div>' + '</div>' diff --git a/resources/views/article.blade.php b/resources/views/article.blade.php index a87826e6ff88071b81c31f86adc61c7bd8e63a20..3187a73d9fae378818a5b8a8ca0ec247ad943f68 100644 --- a/resources/views/article.blade.php +++ b/resources/views/article.blade.php @@ -9,8 +9,8 @@ <div class="row"> <div class="col-md-12"> <div class="section-title text-center"> - <h3>Welcome to Alumni STEI Forum</h3> - <p>Question & Answer</p> + <h3>Welcome to Alumni STEI Article</h3> + <p>Get most updated news about Alumni STEI here</p> </div> </div> </div> diff --git a/resources/views/showmember.blade.php b/resources/views/showmember.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..4399d661dac9ab5db2d56ad3a36ce8a4e5eb2c65 --- /dev/null +++ b/resources/views/showmember.blade.php @@ -0,0 +1,7 @@ +@extends('layouts.apphome') + +@section('title', 'Show Members') + +@section('content') +Menampilkan member2 semua yeyyyy +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4829d60fca392ddd653d9071517786c5a3de81a7..a259a63983fc1f9b68002f769a96fda106d4f304 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,8 +21,6 @@ Route::get('/about', function () { return view('about'); }); -Route::resource('members', 'MembersController'); - Route::post('/importcsv','AddMemberController@importCSV'); Route::post('/importmember','AddMemberController@importMember'); diff --git a/tests/Feature/ArticleTest.php b/tests/Feature/ArticleTest.php index 8f23c5b1a9f11f194f05465ac30fa930cad78d68..7e2c5f56b4221fce324d8f9808dad8bea4ec7d92 100644 --- a/tests/Feature/ArticleTest.php +++ b/tests/Feature/ArticleTest.php @@ -5,7 +5,7 @@ namespace Tests\Feature; use App\Post; use App\Member; use App\User; - +use \Auth; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -273,4 +273,64 @@ class ArticleTest extends TestCase $user->delete(); } + + /** + * test edit article + * + * @return void + */ + public function testShowArticleforMember() + { + $member = factory(Member::class)->create(); + $user = factory(User::class)->create(); + + $post_first = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 1', + 'public' => 1, + 'draft' => 1 + ]); + + $post_second = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 2', + 'public' => 1, + 'draft' => 0 + ]); + + $post_third = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 3', + 'public' => 0, + 'draft' => 1 + ]); + + $post_fourth = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 4', + 'public' => 0, + 'draft' => 0 + ]); + + $response = $this->visit('article') + ->see('Post for Testing 2') + ->dontSee('Post for Testing 1') + ->dontSee('Post for Testing 3') + ->dontSee('Post for Testing 4'); + + Auth::guard('member')->login($member); + $response = $this->visit('/article') + ->dontSee('Post for Testing 1') + ->see('Post for Testing 2') + ->dontSee('Post for Testing 3') + ->see('Post for Testing 4'); + + $post_first->delete(); + $post_second->delete(); + $post_third->delete(); + $post_fourth->delete(); + + $user->delete(); + $member->delete(); + } } diff --git a/tests/Feature/ProfileTest.php b/tests/Feature/ProfileTest.php index 76f772ba48f4918d224770b6285ebd2bed540feb..f39502d1c612da547194ce1669eb939de385703d 100644 --- a/tests/Feature/ProfileTest.php +++ b/tests/Feature/ProfileTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature; use App\Member; use App\User; +use \Auth; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; @@ -108,4 +109,183 @@ class ProfileTest extends TestCase $user->delete(); $member->delete(); } + + /** + * test see other member + * + * @return void + */ + public function testSeeOtherMember() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member_dummy->id) + ->dontSee('Edit Profile') + ->see($member_dummy->name) + ->see($member_dummy->phone_number) + ->see($member_dummy->company) + ->see($member_dummy->interest) + ->see($member_dummy->address); + + $member->delete(); + $member_dummy->delete(); + } + + /** + * test see other member + * + * @return void + */ + public function testSeeHimselfAsMember() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id) + ->see('Edit Profile') + ->see($member->name) + ->see($member->phone_number) + ->see($member->company) + ->see($member->interest) + ->see($member->address); + + $member->delete(); + } + + /** + * test see other member + * + * @return void + */ + public function testShowMemberAsGuest() + { + $member = factory(Member::class)->create(); + + $response = $this->visit('members/' . $member->id) + ->seePageIs('/'); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditProfileAsOtherMember() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member_dummy->id . '/edit') + ->seePageIs('/'); + + $member->delete(); + $member_dummy->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditProfileAsGuest() + { + $member_dummy = factory(Member::class)->create(); + + $response = $this->visit('members/' . $member_dummy->id . '/edit') + ->seePageIs('/'); + + $member_dummy->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfile() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('ITB', 'company') + ->type('Programming', 'interest') + ->type('Address', 'address') + ->attach('storage/app/public/logo_itb.png', 'profile_image') + ->press('Submit') + ->seePageIs('members/' . $member->id); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfileWithoutAddress() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('ITB', 'company') + ->type('Programming', 'interest') + ->type('', 'address') + ->attach('storage/app/public/logo_itb.png', 'profile_image') + ->press('Submit') + ->seePageIs('members/' . $member->id); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfileWithoutCompanyInterest() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('', 'company') + ->type('', 'interest') + ->type('Bandung', 'address') + ->attach('storage/app/public/logo_itb.png', 'profile_image') + ->press('Submit') + ->seePageIs('members/' . $member->id . '/edit'); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfileWithoutPhoto() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('ITB', 'company') + ->type('Programming', 'interest') + ->type('Bandung', 'address') + ->press('Submit') + ->seePageIs('members/' . $member->id); + + $member->delete(); + } } diff --git a/tests/Feature/QuestionAnswerTest.php b/tests/Feature/QuestionAnswerTest.php index ef1c706afef42ad414b68e2da6a48f01021ba80d..44034069164be38a375eeec44843008e3043b852 100644 --- a/tests/Feature/QuestionAnswerTest.php +++ b/tests/Feature/QuestionAnswerTest.php @@ -10,6 +10,7 @@ use App\Question; use App\User; use App\Member; use App\Answer; +use \Auth; class QuestionAnswerTest extends TestCase { @@ -115,15 +116,18 @@ class QuestionAnswerTest extends TestCase ->type('Question for Testing', 'topic') ->type('Is This Question One?', 'body') ->press('Add') - ->see('Question Added') - ->click('Question for Testing') + ->see('Question Added'); + + $dummy = Question::where('topic', 'Question for Testing')->first(); + $written_on = 'Written on ' . $dummy->created_at->format('d M Y'); + $response = $this->actingAs($user) + ->visit('admin/questions') + ->click($written_on) ->see('Written on') ->see('Last Editted on') ->see('by'); - $dummy = Question::where('topic', 'Question for Testing')->first(); $dummy->delete(); - $user->delete(); } @@ -373,4 +377,262 @@ class QuestionAnswerTest extends TestCase $question->delete(); $user->delete(); } + + /** + * test show question + * + * @return void + */ + public function testShowEditQuestion() + { + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('/questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->click('Edit') + ->seePageIs('questions/' . $question->id . '/edit') + ->type($question->topic . ' Editted', 'topic') + ->type($question->body . ' Editted', 'body') + ->check('anon') + ->press('Submit') + ->seePageIs('questions/' . $question->id) + ->see($question->topic . ' Editted') + ->see($question->body . ' Editted'); + + $question->delete(); + $member->delete(); + } + + public function testAddQuestionAnon() + { + $member = factory(Member::class)->create(); + $question = factory(question::class)->make(); + + Auth::guard('member')->login($member); + $response = $this->visit('/questions/create') + ->type($question->body, 'body') + ->type($question->topic, 'topic') + ->check('anon') + ->press('Submit') + ->seePageIs('/questions') + ->see('by Anonymous'); + + $dummy = Question::where('body', $question->body)->first(); + $dummy->delete(); + $member->delete(); + } + + /** + * test show question + * + * @return void + */ + public function testShowEditQuestionOthers() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'is_admin' => 0, + 'member_id' => $member_dummy->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->dontSee('Delete'); + + $response = $this->visit('questions/' . $question->id . '/edit') + ->seePageIs('/'); + + $question->delete(); + $member->delete(); + $member_dummy->delete(); + } + + /** + * test show question edit + * + * @return void + */ + public function testShowQuestionVoteAnswer() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->see($answer->body) + ->press('VOTE') + ->seePageIs('questions/' . $question->id) + ->see('VOTED') + ->see('1'); + + $answer->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show question vote + * + * @return void + */ + public function testShowQuestionVoteUnvote() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->see($answer->body) + ->press('VOTE') + ->seePageIs('questions/' . $question->id) + ->see('VOTED') + ->see('1') + ->press('VOTED') + ->seePageIs('questions/' . $question->id) + ->see('VOTE') + ->see('0'); + + $answer->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show question add answer + * + * @return void + */ + public function testShowQuestionAddAnswer() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + + $answer = factory(answer::class)->make(); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->type($answer->body, 'body') + ->press('Submit') + ->seePageIs('questions/' . $question->id) + ->see($answer->body); + + $dummy = Answer::where('body', $answer->body)->first(); + $dummy->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show answer + * + * @return void + */ + public function testShowEditAnswer() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('answers/' . $answer->id) + ->click('Edit') + ->seePageIs('answers/' . $answer->id . '/edit') + ->see($question->body) + ->type($answer->body . ' Editted', 'body') + ->press('Submit') + ->seePageIs('answers/' . $answer->id) + ->see($question->topic) + ->see($question->body) + ->see($answer->body . ' Editted'); + + $answer->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show question + * + * @return void + */ + public function testShowEditAnswerOthers() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'member_id' => $member->id, + 'is_admin' => 0 + ]); + + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member_dummy->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('answers/' . $answer->id) + ->dontSee('Delete'); + + $response = $this->visit('answers/' . $answer->id . '/edit') + ->seePageIs('/'); + + $answer->delete(); + $question->delete(); + $member->delete(); + $member_dummy->delete(); + } + }