Skip to content

Commit 33058a1

Browse files
authored
Merge pull request #30 from Xatta-Trone/main
add pg student
2 parents bef9dbe + 90b1874 commit 33058a1

File tree

5 files changed

+75
-4
lines changed

5 files changed

+75
-4
lines changed

app/Http/Controllers/Api/Admin/UserDataController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ public function index()
2929
$u = UserData::query();
3030
$t = new VueTable2Service();
3131
return $t->get($u, [
32-
'id', 'student_name', 'merit', 'student_id', 'hall_name', 'status'
32+
'id',
33+
'student_name',
34+
'merit',
35+
'student_id',
36+
'hall_name',
37+
'status',
38+
'grad_level'
3339
]);
3440
}
3541

@@ -70,7 +76,7 @@ public function update(UserDataAddRequest $request, $id)
7076
}
7177

7278
$user = UserData::find($id);
73-
$userdata = ['name' => $user->student_name, 'student_id' => $user->student_id, 'email' => $request->input('email')];
79+
$userdata = ['name' => $user->student_name, 'student_id' => $user->student_id, 'email' => $request->input('email'), 'grad_level' => $user->grad_level];
7480

7581

7682
return $this->createNewAccount($userdata, $id, true);
@@ -86,4 +92,4 @@ public function destroy($id)
8692
{
8793
//
8894
}
89-
}
95+
}

app/Imports/DummyUserDataImport.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function model(array $row)
2020
'student_id' => $row['student_id'] ?? $row['student_no'] ?? $row['Student_Id'] ?? null,
2121
'student_name' => $row['student_name'] ?? $row['name_english'] ?? $row['name'] ?? null,
2222
'hall_name' => $row['hall_name'] ?? $row['hall'] ?? null,
23+
'grad_level' => $row['grad_level'] ?? "UG",
2324
]);
2425
}
2526

app/Traits/UserTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function createNewAccount($userData, $updateUserData = null, $isAddedByA
6868

6969
$userPassword = $this->randomPassword();
7070
$userData['password'] = bcrypt($userPassword);
71-
$userData['student_id'] = $this->studentIdWithoutPrefix($userData['student_id']);
71+
$userData['student_id'] = $userData['grad_level'] == 'UG' ? $this->studentIdWithoutPrefix($userData['student_id']) : $userData['student_id'];
7272
$userData['user_letter'] = $this->userLetter($userData['name']);
7373
$user = User::create($userData);
7474
$user->password = $userPassword;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddGradLevelToUserDataTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('user_data', function (Blueprint $table) {
17+
$table->string('grad_level')->nullable()->default("UG");
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('user_data', function (Blueprint $table) {
29+
$table->dropColumn('grad_level');
30+
});
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddGradLevelToDummyUserDataTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('dummy_user_data', function (Blueprint $table) {
17+
$table->string('grad_level')->nullable()->default("UG");
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('dummy_user_data', function (Blueprint $table) {
29+
$table->dropColumn('grad_level');
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)