Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit bdc7a3e

Browse files
committed
Tidying up the UI and UX
1 parent 27cc523 commit bdc7a3e

File tree

14 files changed

+161
-124
lines changed

14 files changed

+161
-124
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Requests\LogInMainRequest;
6+
use App\Participant;
7+
use App\Motion;
8+
9+
class MainController extends Controller
10+
{
11+
public function index() {
12+
return view('layouts.home');
13+
}
14+
15+
public function login(LogInMainRequest $request) {
16+
$participants = Participant::registered()->verify($request->user_id, $request->verification_code)->get();
17+
if(count($participants) <= 0) {
18+
session()->flash('error_message', "Please go to the registration table and verify your user id and verification code.");
19+
return redirect('/');
20+
}
21+
22+
session()->put("user_id", $request->user_id);
23+
$participant = $participants[0];
24+
session()->put('hide_log_in', 1);
25+
return redirect('/main');
26+
}
27+
28+
public function main() {
29+
$motion = Motion::active()->first();
30+
31+
return view('main.index', [
32+
'motion' => $motion,
33+
]);
34+
}
35+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class LogInMainRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return true;
17+
}
18+
19+
/**
20+
* Get the validation rules that apply to the request.
21+
*
22+
* @return array
23+
*/
24+
public function rules()
25+
{
26+
return [
27+
//
28+
];
29+
}
30+
}

app/Http/Requests/VerifyMotionRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function authorize()
2424
public function rules()
2525
{
2626
return [
27-
//
27+
'proposal' => 'required',
2828
];
2929
}
3030
}

app/Http/Requests/VerifyParticipantRequest.php

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Requests;
44

55
use Illuminate\Foundation\Http\FormRequest;
6+
use App\Participant;
67

78
class VerifyParticipantRequest extends FormRequest
89
{

app/Motion.php

+4
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ class Motion extends Model
1919
public function scopeActive($query) {
2020
return $query->where('available_until', ">", Carbon::now());
2121
}
22+
23+
public function votes() {
24+
return $this->hasMany(SubmittedVote::class);
25+
}
2226
}

app/Participant.php

+4
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ class Participant extends Model {
2020
public function scopeRegistered($query) {
2121
return $query->whereNotNull('registered_on');
2222
}
23+
24+
public function scopeVerify($query, $user_id, $verification_code){
25+
return $query->where('user_id', '=', $user_id)->where('verification_code', '=', $verification_code);
26+
}
2327
}

config/session.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
|
1717
*/
1818

19-
'driver' => env('SESSION_DRIVER', 'file'),
19+
'driver' => env('SESSION_DRIVER', 'database'),
2020

2121
/*
2222
|--------------------------------------------------------------------------

resources/views/layouts/home.blade.php

+17-10
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@
33
@include( 'partials.head' )
44
<body>
55
@include( 'partials.nav' )
6-
@include( 'partials.jumbotron' )
7-
<br>
8-
<div class="container">
9-
<!-- Example row of columns -->
10-
<div class="row">
11-
<div class="col-md-12">
12-
<div class="panel panel-primary">
13-
@yield('content')
14-
</div>
15-
</div>
6+
<div class="jumbotron">
7+
<div class="container">
8+
<h1>Welcome to your assembly</h1>
9+
<p>Be sure to register at the nearest registration desk. They will give you a verification code that, in
10+
combination of the ID number used to verify your identity, you can vote for the assembly motions.</p>
1611
</div>
12+
</div>
13+
@if( session()->has('error_message') )
14+
<div class="container">
15+
<div class="row">
16+
<div class="col-md-12">
17+
<div class="alert alert-danger">
18+
<strong>Oops!</strong> {{ session('error_message') }}
19+
</div>
20+
</div>
21+
</div>
22+
</div>
23+
@endif
1724

1825
@include( 'partials.footer' )
1926
</div> <!-- /container -->

resources/views/main/index.blade.php

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@extends('layouts.twocol')
2+
3+
@section('left')
4+
Hello World!!
5+
@endsection
6+
7+
@section('content')
8+
<div class="panel-heading">Motion for Assembly Consideration</div>
9+
<div class="panel-body">
10+
<div class="panel-body">
11+
<!-- Display Validation Errors -->
12+
@include('common.errors')
13+
<form action="{{ url('vote/store') }}" method="POST" class="form-horizontal">
14+
{{ csrf_field() }}
15+
<fieldset>
16+
<div class="form-group">
17+
<label for="proposal" class="col-sm-3 control-label">Motion</label>
18+
19+
<div class="col-sm-9">
20+
<p class="form-control-static">
21+
{{ $motion->proposal }}
22+
</p>
23+
</div>
24+
</div>
25+
<div class="form-group">
26+
<div class="col-sm-offset-3 col-sm-9 btn-group colors" data-toggle="buttons">
27+
<label class="btn btn-success col-sm-2">
28+
<input type="radio" name="answer" value="0" autocomplete="off"
29+
required onchange="$('#thumbs_up').show(); $('#thumbs_down').hide();"> Yes
30+
<i id='thumbs_up' class='fa fa-thumbs-o-up' style="display: none"></i>
31+
</label>
32+
<label class="btn btn-danger col-sm-2">
33+
<input type="radio" name="answer" value="1" autocomplete="off"
34+
required onchange="$('#thumbs_up').hide(); $('#thumbs_down').show();"> No
35+
<i id='thumbs_down' class='fa fa-thumbs-o-down' style="display: none"></i>
36+
</label>
37+
</div>
38+
</div>
39+
<div class="form-group">
40+
<div class="col-sm-offset-3 col-sm-9">
41+
<button type="submit" class="btn btn-default">
42+
Vote
43+
</button>
44+
</div>
45+
</fieldset>
46+
</form>
47+
</div>
48+
</div>
49+
</div>
50+
@endsection

resources/views/motion/create.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<label for="proposal" class="col-sm-3 control-label">Motion</label>
1414

1515
<div class="col-sm-9">
16-
<textarea rows='5' id='proposal' name='proposal' class="form-control" required></textarea>
16+
<textarea rows='5' id='proposal' name='proposal' class="form-control" required>{{ old('proposal') }}</textarea>
1717
</div>
1818
</div>
1919
<div class="form-group">

resources/views/partials/nav.blade.php

+13-12
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@
1212
</button>
1313
<a class="navbar-brand" href="#">Opinions Assemble</a>
1414
</div>
15-
<!--
16-
<div id="navbar" class="navbar-collapse collapse">
17-
<form class="navbar-form navbar-right" role="form">
18-
<div class="form-group">
19-
<input type="text" placeholder="Email" class="form-control">
15+
@if ( !session()->has('hide_log_in') )
16+
<div id="navbar" class="navbar-collapse collapse">
17+
<form action="{{ url('main/login') }}" class="navbar-form navbar-right" role="form" method="POST">
18+
{{ csrf_field() }}
19+
<div class="form-group">
20+
<input name='user_id' type="text" placeholder="User ID" class="form-control">
21+
</div>
22+
<div class="form-group">
23+
<input name='verification_code' type="password" placeholder="Code" class="form-control">
24+
</div>
25+
<button type="submit" class="btn btn-success">Sign in</button>
26+
</form>
2027
</div>
21-
<div class="form-group">
22-
<input type="password" placeholder="Password" class="form-control">
23-
</div>
24-
<button type="submit" class="btn btn-success">Sign in</button>
25-
</form>
26-
</div>
27-
--><!--/.navbar-collapse -->
28+
@endif
2829
</div>
2930
</nav>

resources/views/participant/verify.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<label for="user_id" class="col-sm-3 control-label">User ID</label>
1515

1616
<div class="col-sm-9">
17-
<input type="text" name="user_id" id="participant-userid" class="form-control">
17+
<input type="text" name="user_id" id="participant-userid" class="form-control" value="{{ old('user_id') }}">
1818
</div>
1919
</div>
2020

resources/views/welcome.blade.php

-95
This file was deleted.

routes/web.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use App\Participant;
1515
use Illuminate\Http\Request;
1616

17-
Route::get('/', function () {
18-
return view('welcome');
19-
});
17+
Route::get('/', 'MainController@index');
18+
Route::get('/main', 'MainController@main');
19+
Route::post('/main/login', 'MainController@login');
2020

2121
Route::get('/participant', 'ParticipantController@index');
2222

0 commit comments

Comments
 (0)