initialize project

This commit is contained in:
Afrina Alimi
2024-02-08 09:30:14 +08:00
commit 25d85dac75
206 changed files with 50977 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"plugins": ["syntax-dynamic-import"]
}
+45
View File
@@ -0,0 +1,45 @@
CLOUDINARY_ENABLED=
CLOUDINARY_FOLDER=""
CLOUDINARY_IMAGE_ERROR=
CLOUDINARY_IMAGE_DEFAULT=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
USER_NAME="Lenard Mangay-ayam"
USER_EMAIL="lenard.mangayayam@voting-system.com"
USER_PASS="admin"
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
+5
View File
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
+13
View File
@@ -0,0 +1,13 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
*sublime*
BIN
View File
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public/
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Election extends Model
{
protected $table = 'election';
protected $fillable = ['status', 'start', 'end', 'name'];
public $timestamps = false;
}
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(route('login'));
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
class AddController extends Controller
{
public function __invoke (Request $request)
{
$this->validateRequest($request);
$this->insertAdmin($request);
return response()->json([
'status' => 'success',
'message' => 'Admin added successfully'
]);
}
private function insertAdmin($request)
{
$admin = $request->all();
$admin['password'] = bcrypt($request->password);
User::create($admin);
}
private function validateRequest($request)
{
$this->validate($request, [
'name' => 'required|unique:users',
'email' => 'required|email|unique:users',
'password' => 'required',
'confirm_password' => 'same:password'
]);
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
class DeleteController extends Controller
{
public function __invoke($id)
{
if ($id == 1)
return response()->json([
'status' => 'failed',
'message' => 'You can\'t delete the main admin.'
]);
User::destroy($id);
return response()->json([
'status' => 'success',
'message' => 'Admin deleted successfully.'
]);
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
class GetController extends Controller
{
public function __invoke()
{
return User::all();
}
public function show(Request $request, $id)
{
$id = $request->user()->id;
return User::find($id);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
class InformationController extends Controller
{
public function __invoke(Request $request)
{
return response()->json([
'election' => \App\Election::find(Util::getCurrentElection()),
'user' => $request->user(),
'partylist' => \App\Partylist::where('election_id', Util::getCurrentElection())->get(),
'position' => \App\Position::where('election_id', Util::getCurrentElection())->get()
]);
}
}
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\User;
class LoginController extends Controller
{
/**
* Admin Login
* @param {Request} $request
* @return {Response} result
*/
public function __invoke(Request $request)
{
$this->validateRequest($request);
if ($this->checkLogin($request)) {
$user = Auth::user();
$result['status'] = 'success';
$result['message'] = 'Login Successfully';
$result['user'] = $user;
$result['election_status'] = Util::getElectionStatus();
$result['token'] = $user->createToken('My app', ['admin'])->accessToken;
} else {
$result['status'] = 'failed';
$result['message'] = 'Wrong email or password';
}
return response()->json($result);
}
/**
* Validate Request
* @param {Request} $request
* @return {Boolean} isValid
*/
private function validateRequest($request)
{
$this->validate($request, [
'email' => 'required|email',
'password'=> 'required'
]);
}
/**
* Check Credential
* @param {Request} $request
* @return {Boolean} isLogin
*/
private function checkLogin($request)
{
return Auth::attempt([
'email' => $request->email,
'password' => $request->password
]);
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
class LogoutController extends Controller
{
public function __invoke()
{
Auth::guard('web')->logout();
Auth::guard('voter')->logout();
return response()->json([
'status' => 'success',
'message' => 'Logout successfully',
'user' => Auth::user()
]);
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Http\Controllers\API\v1\Admin;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Hash;
use App\Http\Controllers\Controller;
use App\User;
class UpdateController extends Controller
{
public function __invoke(Request $request, $id)
{
$id = $request->user()->id;
$this->validateRequest($request, $id);
$this->updateAdmin($request, $id);
return response()->json([
'status' => 'success',
'message' => 'Admin updated successfully'
]);
}
public function updatePassword(Request $request, $id)
{
$id = $request->user()->id;
$this->validatePassword($request, $id);
$password = Hash::make($request->password);
User::find($id)->update(['password'=>$password]);
return response()->json([
'status' => 'success',
'message' => 'Password updated successfully'
]);
}
private function validatePassword($request, $id)
{
$this->validate($request, [
'old_password' => "required|password:users,password,$id",
'password' => 'required',
'confirm_password' => 'required|same:password'
]);
}
private function updateAdmin($request, $id)
{
User::find($id)->update($request->all());
}
private function validateRequest($request, $id)
{
$this->validate($request, [
'name' => ['required', Rule::unique('users')->ignore($id)],
'email' => ['required', Rule::unique('users')->ignore($id), 'email']
]);
}
}
@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers\API\v1\Election;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class GetController extends Controller
{
public function __invoke(){
return \App\Election::where('status', 3)->orderBy('id', 'desc')->get();
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\API\v1\Election;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use Illuminate\Support\Facades\Auth;
class InformationController extends Controller
{
public function __invoke()
{
$id = Util::getCurrentElection();
$information['election'] = \App\Election::find($id);
$information['position'] = \App\Position::where('election_id', $id)->get();
$information['partylist'] = \App\Partylist::where('election_id', $id)->get();
$information['nominee'] = \App\Nominee::where('election_id', $id)->get();
$information['result'] = \App\Result::where('voter_id', Auth::id())->get();
$information['voter'] = Auth::user();
return response()->json($information);
}
}
@@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers\API\v1\Election;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use DB;
class ResultController extends Controller
{
public function __invoke(Request $request)
{
$result = $this->getResult(Util::getCurrentElection());
return response()->json(
$result
);
}
public function finalResult($id)
{
$result = $this->getResult($id);
$position = \App\Position::where('election_id', $id)->get();
$nominee = \App\Nominee::where('election_id', $id)->get();
$partylist = \App\Partylist::where('election_id', $id)->get();
return response()->json([
'result'=>$result,
'position'=>$position,
'nominee'=>$nominee
]);
}
private function getResult($id)
{
return \App\Result::select(DB::raw('position_id,nominee_id,count(*) as votes'))
->groupBy('position_id', 'nominee_id')
->where('election_id', $id)
->orderBy('votes', 'DESC')
->get();
}
}
@@ -0,0 +1,61 @@
<?php
namespace App\Http\Controllers\API\v1\Election;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Election;
class StartController extends Controller
{
public function __invoke(Request $request)
{
$this->validateRequest($request);
if ($this->hasNoNominee())
return response()->json([
'status' => 'failed',
'message' => 'There is no nominees'
]);
if ($this->isElectionStarted())
return response()->json([
'status' => 'failed',
'message' => 'Election has already started'
]);
$election = Election::find(Util::getCurrentElection())
->update([
'status'=>2,
'start'=>date('Y-m-d H:i:s'),
'name'=>$request->name
]);
return response()->json([
'status' => 'success',
'message' => 'Election has started.',
'election' => Election::find(Util::getCurrentElection())
]);
}
private function hasNoNominee()
{
return \App\Nominee::where('election_id', Util::getCurrentElection())->count() < 1;
}
private function isElectionStarted()
{
return Util::getElectionStatus() == 2;
}
private function validateRequest($request)
{
$id = Auth::id();
$this->validate($request, [
'password' => "required|password:users,password,$id"
]);
}
}
@@ -0,0 +1,56 @@
<?php
namespace App\Http\Controllers\API\v1\Election;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Election;
class StopController extends Controller
{
public function __invoke(Request $request)
{
if (!$this->isElectionStarted())
return response()->json([
'status' => 'failed',
'message' => 'Election hasn\'t started yet.'
]);
$this->validateRequest($request);
$this->stopElection($request);
return response()->json([
'status' => 'success',
'message' => 'Election has finished.',
'election' => Election::find(Util::getCurrentElection())
]);
}
private function stopElection($request)
{
$election = Election::find(Util::getCurrentElection())
->update([
'status'=>3,
'name'=>$request->name,
'end'=>date('Y-m-d H:i:s')
]);
Election::create();
}
private function validateRequest($request)
{
$id = $request->user()->id;
$this->validate($request, [
'password' => "required|password:users,password,$id"
]);
}
private function isElectionStarted()
{
return Util::getElectionStatus() == 2;
}
}
@@ -0,0 +1,108 @@
<?php
namespace App\Http\Controllers\API\v1\Election;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Util;
use App\Position;
use App\Nominee;
use App\Result;
class VoteController extends Controller
{
public function __invoke(Request $request)
{
if ($this->validateRequest($request)['status'] == 'failed') {
return response()->json($this->validateRequest($request));
}
$this->insertVote($request);
return response()->json([
'status' => 'success',
'message' => 'Voted successfully',
'result' => Result::where('voter_id', Auth::id())->get()
]);
}
private function insertVote($request)
{
foreach ($request->vote as $key => $value) {
Result::updateOrCreate([
'voter_id' => Auth::id(),
'election_id' => Util::getCurrentElection(),
'position_id' => $value['position_id'],
], ['nominee_id' => $value['nominee_id']]);
}
}
private function validNominee($id, $position_id)
{
return Nominee::where([
['id', '=', $id],
['position_id', '=', $position_id]
])->count();
}
private function isPositionExist($id)
{
return Position::where('id', $id)->count();
}
private function voteAllPosition($request)
{
$total_position = Position::where('election_id', Util::getCurrentElection())->count();
$total_vote = count($request->vote);
return $total_vote >= $total_position;
}
private function validateRequest($request)
{
$result['status'] = 'failed';
$vote = $request->vote;
/**
* Check if the user vote on all position
*/
if (!$this->voteAllPosition($request)) {
$result['message'] = 'You must vote on all position.';
return $result;
}
foreach ($vote as $key => $value) {
/**
* Check if position_id and nominee_id has a value
*/
if (empty($value['position_id']) || empty($value['nominee_id'])) {
$result['message'] = 'You must vote on all position.';
return $result;
}
/**
* Check if the Position you vote exists
*/
if (!$this->isPositionExist($value['position_id'])) {
$result['message'] = 'Invalid Position.';
return $result;
}
/**
* Check if the Nominee you vote on certain position exists
*/
elseif (!$this->validNominee($value['nominee_id'], $value['position_id'])) {
$result['message'] = 'Invalid Nominee for '.Position::find($value['position_id'])->name.' position.';
return $result;
}
}
return ['status'=>'success'];
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\API\v1\Nominee;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Nominee;
class AddController extends Controller
{
public function __invoke (Request $request)
{
$this->validateRequest($request);
$this->insertNominee($request);
return response()->json([
'status' => 'success',
'message'=> 'Nominee added successfully'
]);
}
public function validateRequest ($request)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('nominee')->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'student_id' => [
'required',
Rule::unique('nominee')->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'course' => 'required',
'position_id' => 'required|exists:position,id',
'partylist_id' => 'nullable|exists:partylist,id',
'image' => 'nullable|image'
]);
}
public function insertNominee ($request)
{
$nominee = $request->all();
$default_image = config('app.cloudinary_enabled') ? config('app.cloudinary_image_default') : config('app.nominee_image');
$nominee['image'] = Util::getImagePath($request, config('app.nominee_directory'), $default_image);
$nominee['election_id'] = Util::getCurrentElection();
Nominee::create($nominee);
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\API\v1\Nominee;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Nominee;
class DeleteController extends Controller
{
public function __invoke ($id)
{
$nominee = Nominee::find($id);
Util::deleteImage($nominee->image);
$nominee->delete();
return response()->json([
'status' => 'success',
'message'=> 'Nominee deleted successfully'
]);
}
}
@@ -0,0 +1,18 @@
<?php
namespace App\Http\Controllers\API\v1\Nominee;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
class GetController extends Controller
{
public function __invoke()
{
$nominee = \App\Nominee::where('election_id', Util::getCurrentElection())
->orderBy('position_id')
->get();
return $nominee;
}
}
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\API\v1\Nominee;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Nominee;
class UpdateController extends Controller
{
public function __invoke (Request $request, $id)
{
$this->validateRequest($request, $id);
$this->updateNominee($request, $id);
return response()->json([
'status' => 'success',
'message' => 'Nominee updated successfully'
]);
}
private function validateRequest($request, $id)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('nominee')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'student_id' => [
'required',
Rule::unique('nominee')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'course' => 'required',
'position_id' => 'required|exists:nominee,position_id',
'partylist_id' => 'nullable|exists:nominee,partylist_id'
]);
}
private function updateNominee ($request, $id)
{
$nominee = Nominee::find($id);
$default_image = $nominee->image;
$nominee->name = $request->name;
$nominee->course = $request->course;
$nominee->student_id = $request->student_id;
$nominee->position_id = $request->position_id;
$nominee->partylist_id = $request->partylist_id;
$nominee->motto = $request->motto;
$nominee->description = $request->description;
$nominee->image = Util::getImagePath($request, config('app.nominee_directory'), $default_image);
$nominee->save();
if (!empty($request->image))
Util::deleteImage($default_image);
}
}
@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\API\v1\Partylist;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Partylist;
class AddController extends Controller
{
public function __invoke(Request $request)
{
$this->validateRequest($request);
$this->insertPartylist($request);
return response()->json([
'status' => 'success',
'message'=> 'Partylist added successfully'
]);
}
private function validateRequest($request)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('partylist')->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
]
]);
}
private function insertPartylist($request)
{
$partylist = $request->all();
$partylist['election_id'] = Util::getCurrentElection();
Partylist::create($partylist);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers\API\v1\Partylist;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Partylist;
class DeleteController extends Controller
{
public function __invoke($id)
{
Partylist::find($id)->delete();
return response()->json([
'status' => 'success',
'message' => 'Partylist deleted successfully'
]);
}
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\API\v1\Partylist;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Partylist;
class GetController extends Controller
{
public function __invoke()
{
$election_id = Util::getCurrentElection();
return Partylist::where('election_id', $election_id)->get();
}
}
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers\API\v1\Partylist;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Partylist;
class UpdateController extends Controller
{
public function __invoke(Request $request, $id)
{
$this->validateRequest($request, $id);
$this->updatePartylist($request, $id);
return response()->json([
'status' => 'success',
'message' => 'Partylist updated successfully'
]);
}
public function validateRequest($request, $id)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('partylist')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
]
]);
}
public function updatePartylist($request, $id)
{
$partylist = Partylist::find($id);
$partylist->name = $request->name;
$partylist->save();
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\API\v1\Position;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Election;
use App\Position;
class AddPositionController extends Controller
{
public function __invoke(Request $request)
{
$this->validateRequest($request);
$this->insertPosition($request);
$result = [
'status' => 'success',
'message'=> 'Position added successfully'
];
return response()->json($result);
}
private function validateRequest($request)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('position')->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
]
]);
}
private function insertPosition($request)
{
$position = $request->all();
$position['election_id'] = Util::getCurrentElection();
Position::create($position);
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers\API\v1\Position;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Position;
class DeletePositionController extends Controller
{
public function __invoke($id)
{
$position = Position::find($id);
$position->delete();
$result = [
'status' => 'success',
'message'=> 'Position deleted successfully'
];
return response()->json($result);
}
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\API\v1\Position;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Position;
class GetPositionController extends Controller
{
public function __invoke()
{
$election_id = Util::getCurrentElection();
return Position::where('election_id', $election_id)->get();
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\API\v1\Position;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Position;
class UpdatePositionController extends Controller
{
public function __invoke(Request $request, $id)
{
$this->validateRequest($request, $id);
$this->updatePosition($request, $id);
$result = [
'status' => 'success',
'message'=> 'Position updated successfully'
];
return response()->json($result);
}
private function updatePosition($request, $id)
{
$position = Position::find($id);
$position->name = $request->name;
$position->save();
}
private function validateRequest($request, $id)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('position')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
]
]);
}
}
@@ -0,0 +1,48 @@
<?php
namespace App\Http\Controllers\API\v1\Voter;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Voter;
class AddController extends Controller
{
public function __invoke(Request $request)
{
$this->validateRequest($request);
$this->insertVoter($request);
return response()->json([
'status' => 'success',
'message' => 'Voter added successfully'
]);
}
private function insertVoter($request)
{
$voter = $request->all();
$voter['election_id'] = Util::getCurrentElection();
Voter::create($voter);
}
private function validateRequest($request)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('voter')->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'student_id' => [
'required',
Rule::unique('voter')->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'course' => 'required'
]);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers\API\v1\Voter;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Voter;
class DeleteController extends Controller
{
public function __invoke($id)
{
Voter::destroy($id);
return response()->json([
'status' => 'success',
'message' => 'Voter deleted successgully.'
]);
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Http\Controllers\API\v1\Voter;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Voter;
class GetController extends Controller
{
public function __invoke()
{
return Voter::where('election_id', Util::getCurrentElection())->paginate(10);
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\API\v1\Voter;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller
{
public function __invoke(Request $request)
{
//return response()->json(Auth::guard('user'));
if (Auth::guard('voter')->attempt(['student_id' => $request->student_id, 'password' => 'admin', 'election_id' => Util::getCurrentElection()])) {
return response()->json([
'status' => 'success',
'message' => 'Login successfully.',
'user' => Auth::guard('voter')->user(),
'election_status' => Util::getElectionStatus(),
'token' => Auth::guard('voter')->user()->createToken('My Token', ['vote'])->accessToken
]);
} else {
return response()->json([
'status' => 'failed',
'message' => 'Invalid ID.'
]);
}
}
}
@@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\API\v1\Voter;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Voter;
class UpdateController extends Controller
{
public function __invoke(Request $request, $id)
{
$this->validateRequest($request, $id);
$this->updateVoter($request, $id);
return response()->json([
'status' => 'success',
'message' => 'Voter updated successfully.'
]);
}
private function validateRequest($request, $id)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('voter')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'student_id' => [
'required',
Rule::unique('voter')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'course' => 'required'
]);
}
private function updateVoter($request, $id)
{
$voter = $request->all();
Voter::find($id)->update($voter);
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
@@ -0,0 +1,71 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
@@ -0,0 +1,14 @@
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
public function index(Request $request)
{
return $request->user();
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class Util extends Controller
{
/**
* Delete an Image
* @param {String} $image
*
*/
public static function deleteImage ($image) {
if (Util::isDefaultImage($image)) return;
Storage::delete($image);
}
/**
* Get the id of current election
*
* @return {Int} $id
*/
public static function getCurrentElection ()
{
return \App\Election::where('id', '>', 0)->orderBy('id', 'desc')->first()->id;
}
/**
* Get the status of current Election
*
* @return {Int} $electio_status
*/
public static function getElectionStatus ()
{
return \App\Election::find(Util::getCurrentElection())->status;
}
/**
* Upload image and return it's path
* @param {Request} $request
* @param {String} $directory
* @param {String} $default_image
* @return {String} $image_path
*/
public static function getImagePath(Request $request, $directory, $default_image, $filename=null)
{
if (empty($request->image)){
return $default_image;
}else if (config('app.cloudinary_enabled')) {
return Util::uploadFileToCloudinary($request);
} else {
$filename = $filename ?: time().' .jpg';
return $request->file('image')->storeAs($directory, $filename);
}
}
/**
* Check if image is default
* @param {String} $image
* @return {Boolean} $isDefault
*/
public static function isDefaultImage ($image)
{
return ($image == config('app.nominee_image'));
}
public static function getCloudinaryConfig()
{
$config = new \Cloudinary\Configuration\Configuration();
$config->cloud->cloudName = config('app.cloudinary_cloud_name');
$config->cloud->apiKey = config('app.cloudinary_api_key');
$config->cloud->apiSecret = config('app.cloudinary_api_secret');
$config->url->secure = true;
return $config;
}
public static function uploadFileToCloudinary($request)
{
try{
$config = Util::getCloudinaryConfig();
$cloudinary = new \Cloudinary\Cloudinary($config);
$uploadApi = $cloudinary->uploadApi();
$image = base64_encode(file_get_contents($request->file('image')));
$result = $uploadApi->upload('data:image/gif;base64,'.$image, ['folder' => config('app.cloudinary_folder')]);
return $result["url"];
} catch (\Throwable $exception) {
return config('app.cloudinary_image_error');
}
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'election' => \App\Http\Middleware\ElectionMiddleware::class,
'admin' => \App\Http\Middleware\AdminMiddleware::class,
'voter' => \App\Http\Middleware\VoterMiddleware::class,
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
'isvoted' => \App\Http\Middleware\IsVotedMiddleware::class,
'main_admin' => \App\Http\Middleware\MainAdminMiddleware::class,
'has_voted' => \App\Http\Middleware\HasVotedMiddleware::class,
];
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->user()->tokenCan('admin')) {
return response()->json([
'error' => 'Unauthenticated.'
], 401);
}
return $next($request);
}
}
@@ -0,0 +1,34 @@
<?php
namespace App\Http\Middleware;
use Closure;
use \App\Http\Controllers\Util;
class ElectionMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->isElection($request)) {
return response()->json([
'status' => 'failed',
'message' => 'You can not add, update, or delete during the election.'
]);
}
return $next($request);
}
private function isElection($request)
{
return !$request->isMethod('get') && Util::getElectionStatus() == 2 && !$request->is('api/v1/election/*');
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
class EncryptCookies extends BaseEncrypter
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use Closure;
class HasVotedMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->hasVoted($request)) {
return response()->json([
'status'=>'failed',
'message'=> 'You must vote first.'
], 500);
}
return $next($request);
}
private function hasVoted($request)
{
$x = \App\Result::where('voter_id', $request->user()->id)->count();
return $x > 0;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Closure;
use App\Result;
use Illuminate\Support\Facades\Auth;
class IsVotedMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Result::where('voter_id', Auth::id())->count() > 0)
return response()->json([
'status' => 'failed',
'message' => 'You can only vote once.'
]);
return $next($request);
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
class MainAdminMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->user()->id != 1) {
return response()->json([
'status' => 'failed',
'message' => 'This can only be accessed by the main admin'
]);
}
return $next($request);
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
}
return $next($request);
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;
class TrimStrings extends BaseTrimmer
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Middleware;
use Closure;
class VoterMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->user()->tokenCan('vote')) {
return response()->json([
'error' => 'Unauthenticated.'
], 401);
}
return $next($request);
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Nominee extends Model
{
protected $table = 'nominee';
protected $fillable = [
'name',
'course',
'student_id',
'position_id',
'partylist_id',
'election_id',
'image',
'description',
'motto'
];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Partylist extends Model
{
protected $table = 'partylist';
protected $fillable = ['name', 'election_id'];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Position extends Model
{
protected $table = 'position';
protected $fillable = ['name', 'election_id'];
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use DB;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Validator::extend('password', function ($attribute, $value, $parameters, $validator) {
$password = DB::table($parameters[0])->where('id', $parameters[2])->value($parameters[1]);
return Hash::check($value, $password);
});
if(config('app.env') === 'production') {
\URL::forceScheme('https');
}
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravel\Passport\Passport;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Passport::tokensCan([
'vote' => 'The user can access voter\'s panel.',
'admin' => 'The user can access admin panel.',
]);
Passport::routes();
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\Event' => [
'App\Listeners\EventListener',
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Result extends Model
{
protected $table = 'result';
protected $fillable = ['voter_id', 'nominee_id', 'position_id', 'election_id'];
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
class Voter extends Authenticatable
{
use HasApiTokens;
protected $table = 'voter';
protected $fillable = ['name', 'student_id', 'course', 'election_id'];
}
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env php
<?php
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);
+55
View File
@@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
+17
View File
@@ -0,0 +1,17 @@
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so we do not have to manually load any of
| our application's PHP classes. It just feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+55
View File
@@ -0,0 +1,55 @@
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"cloudinary/cloudinary_php": "^2.3",
"doctrine/dbal": "^2.5",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.8.*",
"laravel/passport": "^4.0",
"laravel/tinker": "~1.0",
"lcobucci/jwt": "3.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan passport:keys"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Generated
+6955
View File
File diff suppressed because it is too large Load Diff
+250
View File
@@ -0,0 +1,250 @@
<?php
return [
/*
|-------------------------------------------------------------------------
| My Configuration
|-------------------------------------------------------------------------
|
|
*/
'nominee_image' => 'images/nominee/default.jpg',
'nominee_directory' => 'images/nominee',
'cloudinary_enabled' => env('CLOUDINARY_ENABLED', false),
'cloudinary_folder' => env('CLOUDINARY_FOLDER'),
'cloudinary_image_error' => env('CLOUDINARY_IMAGE_ERROR'),
'cloudinary_image_default' => env('CLOUDINARY_IMAGE_DEFAULT'),
'cloudinary_cloud_name' => env('CLOUDINARY_CLOUD_NAME'),
'cloudinary_api_key' => env('CLOUDINARY_API_KEY'),
'cloudinary_api_secret' => env('CLOUDINARY_API_SECRET'),
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Asia/Manila',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class,
Laravel\Passport\PassportServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],
];
+117
View File
@@ -0,0 +1,117 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
'voter' => [
'driver' => 'session',
'provider' => 'voters',
],
'voterAPI' => [
'driver' => 'passport',
'provider' => 'voters',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'voters' => [
'driver' => 'eloquent',
'model' => App\Voter::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
];
+58
View File
@@ -0,0 +1,58 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
//
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];
+91
View File
@@ -0,0 +1,91 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'laravel',
];
+128
View File
@@ -0,0 +1,128 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'modes' => [
'ONLY_FULL_GROUP_BY',
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ENGINE_SUBSTITUTION',
],
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];
+68
View File
@@ -0,0 +1,68 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'public'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "s3", "rackspace"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
];
+123
View File
@@ -0,0 +1,123 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
| "sparkpost", "log", "array"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
+85
View File
@@ -0,0 +1,85 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Driver
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for each one. Here you may set the default queue driver.
|
| Supported: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'default' => env('QUEUE_DRIVER', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
'queue' => 'your-queue-name',
'region' => 'us-east-1',
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'retry_after' => 90,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];
+38
View File
@@ -0,0 +1,38 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];
+179
View File
@@ -0,0 +1,179 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120,
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => null,
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using the "apc" or "memcached" session drivers, you may specify a
| cache store that should be used for these sessions. This value must
| correspond with one of the application's configured cache stores.
|
*/
'store' => null,
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => 'laravel_session',
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you if it can not be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE', false),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
];
+33
View File
@@ -0,0 +1,33 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => realpath(storage_path('framework/views')),
];
+1
View File
@@ -0,0 +1 @@
*.sqlite
+24
View File
@@ -0,0 +1,24 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker\Generator $faker) {
static $password;
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
];
});
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 60);
$table->string('email', 60)->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email', 60)->index();
$table->string('token', 60);
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateElectionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('election'))
Schema::create('election', function (Blueprint $table) {
$table->increments('id');
$table->integer('status')->default(1);
$table->dateTime('start');
$table->dateTime('end');
$table->string('name', 60)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('election');
}
}
@@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePositionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('position'))
Schema::create('position', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 60);
$table->timestamps();
$table->integer('election_id')->unsigned();
$table->foreign('election_id')
->references('id')
->on('election')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('position');
}
}
@@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePartylistTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('partylist'))
Schema::create('partylist', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 60);
$table->timestamps();
$table->integer('election_id')->unsigned();
$table->foreign('election_id')
->references('id')
->on('election')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('partylist');
}
}
@@ -0,0 +1,52 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTableNominee extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('nominee'))
Schema::create('nominee', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('name', 60);
$table->string('course', 60);
$table->string('student_id', 60);
$table->integer('position_id')->unsigned();
$table->integer('partylist_id')->nullable()->unsigned();
$table->integer('election_id')->unsigned();
$table->foreign('election_id')
->references('id')
->on('election')
->onDelete('cascade');
$table->foreign('position_id')
->references('id')
->on('position')
->onDelete('cascade');
$table->foreign('partylist_id')
->references('id')
->on('partylist');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nominee');
}
}
@@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTableVoter extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('voter'))
Schema::create('voter', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 60);
$table->string('student_id', 60);
$table->string('course', 60);
$table->timestamps();
$table->integer('election_id')->unsigned();
$table->foreign('election_id')
->references('id')
->on('election')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('voter');
}
}
@@ -0,0 +1,57 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTableResult extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('result'))
Schema::create('result', function (Blueprint $table) {
$table->increments('id');
$table->integer('voter_id')->unsigned();
$table->integer('position_id')->unsigned();
$table->integer('nominee_id')->unsigned();
$table->timestamps();
$table->integer('election_id')->unsigned();
$table->foreign('election_id')
->references('id')
->on('election')
->onDelete('cascade');
$table->foreign('position_id')
->references('id')
->on('position')
->onDelete('cascade');
$table->foreign('voter_id')
->references('id')
->on('voter')
->onDelete('cascade');
$table->foreign('nominee_id')
->references('id')
->on('nominee')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('result');
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AlterStartAndAndColumnFromElectionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('election', function (Blueprint $table) {
$table->dateTime('start')->nullable()->change();
$table->dateTime('end')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('election', function (Blueprint $table) {
$table->dateTime('start')->change();
$table->dateTime('end')->change();
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNewColumnForNomineeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('nominee', function (Blueprint $table) {
$table->string('image', 60)->default('images/nominee/default.jpg');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nominee', function (Blueprint $table) {
$table->dropColumn('image');
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddPasswordColumnFromVoterTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('voter', function (Blueprint $table) {
$table->string('password', 60)->default(bcrypt('admin'));
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('voter', function (Blueprint $table) {
$table->dropColumn('password');
});
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddColumnsOnNomineeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('nominee', function (Blueprint $table) {
$table->string('motto', 60)->nullable();
$table->string('description', 600)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nominee', function (Blueprint $table) {
$table->dropColumn('motto');
$table->dropColumn('description');
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class FixNomineeImageColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('nominee', function ($table) {
$table->string('image', 255)->default('images/nominee/default.jpg')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nominee', function ($table) {
$table->string('image', 60)->default('images/nominee/default.jpg')->change();
});
}
}

Some files were not shown because too many files have changed in this diff Show More