diff --git a/app/Http/Controllers/TranscriptController.php b/app/Http/Controllers/TranscriptController.php new file mode 100644 index 0000000..783ea53 --- /dev/null +++ b/app/Http/Controllers/TranscriptController.php @@ -0,0 +1,26 @@ +authorize('faculty-action'); + $keyword = $request->input('search'); + + return Inertia::render('TranscriptView', [ + 'user' => User::searchQuery($keyword)?->with(['participants', 'participants.project', 'participants.project.department'])->first(), + 'keyword' => $keyword, + ]); + } + + public function print(User $user) { + $this->authorize('faculty-action'); + + return response()->view('base64-pdf-viewer', ['encoded' => base64_encode(Pdf::loadView('my-projects', ['user' => $user])->output())]); + } +} diff --git a/app/Models/ProjectParticipant.php b/app/Models/ProjectParticipant.php index 38bf21a..087ae93 100644 --- a/app/Models/ProjectParticipant.php +++ b/app/Models/ProjectParticipant.php @@ -19,7 +19,7 @@ class ProjectParticipant extends Model { use HasFactory; protected $fillable = ['user_id', 'type', 'title']; - protected $visible = ['id', 'type', 'title', 'user', 'project']; + protected $visible = ['id', 'type', 'title', 'user', 'project', 'approve_status']; protected $casts = [ 'reject_participants' => AsArrayObject::class, ]; diff --git a/app/Models/User.php b/app/Models/User.php index e283b24..2ea0512 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,7 @@ namespace App\Models; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; @@ -100,8 +101,23 @@ public function participantAndProjects(): Collection return $this->participants->whereNotNull('project.approvalDocument')->sortByDesc('id')->values(); } - public function projects(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(Project::class); } + + public static function searchQuery(string $keyword = null): ?Builder { + $query = self::query(); + if (empty($keyword) or strlen($keyword) < 3) { + return null; + } + if (is_numeric($keyword)) { + $query->where('student_id', $keyword); + } elseif (str_contains($keyword, '@')) { + $query->where('email', $keyword); + } else { + $query->where('name', 'like', "%$keyword%"); + } + + return $query; + } } diff --git a/resources/js/Pages/ProjectApprovalIndex.vue b/resources/js/Pages/ProjectApprovalIndex.vue index 83fe9ff..24bc231 100644 --- a/resources/js/Pages/ProjectApprovalIndex.vue +++ b/resources/js/Pages/ProjectApprovalIndex.vue @@ -1,18 +1,30 @@