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
+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();
});
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(UsersAdmin::class);
$this->call(ElectionSeeder::class);
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Seeder;
use App\Election;
class ElectionSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$election = new Election();
$election->id = 1;
$election->save();
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Seeder;
use App\User;
class UsersAdmin extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::where('id',1)->delete();//To avoid duplicate user accounts
$user = new User();
$user->id = 1;
$user->name = env('USER_NAME','Lenard Mangay-ayam');
$user->email = env('USER_EMAIL','lenard.mangayayam@voting-system.com');
$user->password = bcrypt(env('USER_PASS','admin'));
$user->save();
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Seeder;
use App\Voter;
class VoterTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($i=0; $i < 30; $i++) {
Voter::create([
'name'=>str_random(10),
'student_id'=>$i*3,
'course'=>'Information Technology',
'election_id'=>5
]);
}
}
}