Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .phpunit.result.cache

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions app/Certificate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App;

use App\Model;

class Certificate extends Model
{
/**
* Get the school record associated with the user.
*/
public function school()
{
return $this->belongsTo('App\School');
}
/**
* Get the student record associated with the user.
*/
public function student()
{
return $this->belongsTo('App\User','given_to', 'student_code');
}
}
93 changes: 93 additions & 0 deletions app/Http/Controllers/CertificateController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace App\Http\Controllers;

use App\Certificate;
use Illuminate\Http\Request;

class CertificateController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$certificates = Certificate::where('given_to', \Auth::user()->student_code)
->bySchool(\Auth::user()->school_id)
->get();
return view('certificates.index',['certificates'=>$certificates]);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$certificates = Certificate::with('student')
->bySchool(\Auth::user()->school_id)
->where('active',1)->get();
return view('certificates.create',['certificates'=>$certificates]);
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param \App\Certificate $certificate
* @return \Illuminate\Http\Response
*/
public function show(Certificate $certificate)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Certificate $certificate
* @return \Illuminate\Http\Response
*/
public function edit(Certificate $certificate)
{
//
}

/**
* Update the specified resource in storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update($id)
{
$tb = Certificate::find($id);
$tb->active = 0;
$tb->save();
return back()->with('status',__('File removed'));
}

/**
* Remove the specified resource from storage.
*
* @param \App\Certificate $certificate
* @return \Illuminate\Http\Response
*/
public function destroy(Certificate $certificate)
{
//
}
}
1 change: 0 additions & 1 deletion app/Http/Controllers/NoticeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function edit($id)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ public function upload(Request $request){
$tb->class_id = $request->class_id;
$tb->user_id = auth()->user()->id;
$tb->save();
} else if($request->upload_type == 'certificate'){
$request->validate([
'title' => 'required|string',
'given_to' => 'required|int',
]);

$tb = new \App\Certificate;
$tb->file_path = 'storage/'.$path;
$tb->title = $request->title;
$tb->given_to = $request->given_to;
$tb->active = 1;
$tb->school_id = auth()->user()->school_id;
$tb->user_id = auth()->user()->id;
$tb->save();
} else if($request->upload_type == 'profile' && $request->user_id > 0){
$tb = \App\User::find($request->user_id);
$tb->pic_path = 'storage/'.$path;
Expand Down
25 changes: 25 additions & 0 deletions database/factories/CertificateFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use App\User;
use App\Certificate;
use App\School;
use Faker\Generator as Faker;

$factory->define(Certificate::class, function (Faker $faker) {
return [
'file_path' => $faker->url,
'title' => $faker->sentences(1, true),
'given_to' => $faker->randomElement(User::where('role', 'student')->pluck('student_code')->toArray()),
'active' => $faker->randomElement([0, 1]),
'school_id' => function() use ($faker) {
if (School::count())
return $faker->randomElement(School::pluck('id')->toArray());
else return factory(School::class)->create()->id;
},
'user_id' => function() use ($faker) {
if (User::count())
return $faker->randomElement(User::pluck('id')->toArray());
else return factory(User::class)->create()->id;
},
];
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCertificatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('certificates', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('file_path');
$table->string('title');
$table->integer('given_to');
$table->tinyInteger('active');
$table->integer('school_id')->unsigned();
$table->integer('user_id')->unsigned();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('certificates');
}
}
16 changes: 16 additions & 0 deletions database/seeds/CertificateTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Database\Seeder;

class CertificateTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Certificate::class, 50)->create();
}
}
1 change: 1 addition & 0 deletions database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ public function run()
$this->call(AccountSectorsTableSeeder::class);
$this->call(StudentinfosTableSeeder::class);
$this->call(StudentboardexamsTableSeeder::class);
$this->call(CertificateTableSeeder::class);
}
}
17 changes: 16 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ See the news [here](https://laravel-news.com/unified-transform-open-source-schoo

## Table of Contents
- [Features](https://github.com/changeweb/Unifiedtransform#features)
- [What's New](https://github.com/changeweb/Unifiedtransform#what-snew)
- [Framework used](https://github.com/changeweb/Unifiedtransform#framework-used)
- [Server Requirements](https://github.com/changeweb/Unifiedtransform#server-requirements)
- [How to Start (Installation)](https://github.com/changeweb/Unifiedtransform#how-to-start)
Expand Down Expand Up @@ -73,6 +74,13 @@ Thus you permit the user of this software to use your contribution under the ter

GNU General Public License v3.0

## Whats New

- Certificate Upload Feature is added.
- Admin can upload certificate to a student using student code.
- Students can see their certificates link from Left Navigation bar.
- Now students can also go to their Notifications(Teacher's Message) from Left Navigation bar.

## Features

This software has following features:
Expand All @@ -81,6 +89,7 @@ This software has following features:
|---------|-------------|
| Roles | Master, Admin, Teacher, Student, Librarian, Accountant.|
|| **(You can Impersonate User Roles in Development environment)** See how [Impersonation](https://github.com/changeweb/Unifiedtransform/pull/118) works. Cool !!|
| Certificate | Now you can upload certificate to a student using student code. |
| Payment |**[Stripe](http://stripe.com/)** is used. See configuration below.|
||Students can pay from their accounts.|
||Student can view payment receipts (history)|
Expand Down Expand Up @@ -164,7 +173,7 @@ git clone https://github.com/changeweb/Unifiedtransform
Barryvdh\Debugbar\ServiceProvider,
Logviewer Service provider,
//Alias
Debugbar' => Barryvdh...
'Debugbar' => Barryvdh...
```
from `config/app.php` before running **`composer install`** in **Production Environment**)

Expand Down Expand Up @@ -314,6 +323,10 @@ DB_PASSWORD=secret
4. To get Grade of students of a course for given marks, Teacher clicks the Get Total Marks button.
(Usually this is done at the end of the semester)

## Give Certificate or Diploma to students

Upon request in issue #258, Certification file upload system has been added.

## Good to know

* Setup your **Mail** configuration in `.env` file if you want to send email. Currently registered users are notified by invitation mail if Mail is configured properly.
Expand Down Expand Up @@ -371,3 +384,5 @@ Auto generated fake data were used.
![Screenshot_2019-03-12 Manage Schools - Arvid Marquardt](https://user-images.githubusercontent.com/9896315/54187740-6c2ca280-44d8-11e9-93b1-a998ac1cd585.png)
![Screenshot_2019-03-12 Promote Section Students - Arvid Marquardt(1)](https://user-images.githubusercontent.com/9896315/54187741-6c2ca280-44d8-11e9-871a-51148b27c2b4.png)
![Screenshot_2019-03-12 Students - Arvid Marquardt](https://user-images.githubusercontent.com/9896315/54187744-6cc53900-44d8-11e9-9ad4-c1acc58fe6a2.png)
![Screenshot_2020-07-24 Give Certificate - Ruthie Gorczany](https://user-images.githubusercontent.com/9896315/88412643-b5467380-cdfb-11ea-88da-45afa2756e64.png)
![Screenshot_2020-07-24 My Certificates - Ruthie Gorczany](https://user-images.githubusercontent.com/9896315/88412655-b677a080-cdfb-11ea-8ca4-62407d39f61f.png)
28 changes: 28 additions & 0 deletions resources/views/certificates/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@extends('layouts.app')

@section('title', 'Give Certificate')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-2" id="side-navbar">
@include('layouts.leftside-menubar')
</div>
<div class="col-md-10" id="main-container">
<div class="panel panel-default">
<div class="page-panel-title">Give Certificate</div>
<div class="panel-body">
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
@component('components.file-uploader',['upload_type'=>'certificate'])
@endcomponent
@component('components.uploaded-files-list',['files'=>$certificates,'upload_type'=>'certificate'])
@endcomponent
</div>
</div>
</div>
</div>
</div>
@endsection
26 changes: 26 additions & 0 deletions resources/views/certificates/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@extends('layouts.app')

@section('title', 'My Certificates')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-2" id="side-navbar">
@include('layouts.leftside-menubar')
</div>
<div class="col-md-10" id="main-container">
<div class="panel panel-default">
<div class="page-panel-title">My Certificates</div>
<div class="panel-body">
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
@component('components.certificate-list',['files'=>$certificates])
@endcomponent
</div>
</div>
</div>
</div>
</div>
@endsection
22 changes: 22 additions & 0 deletions resources/views/components/certificate-list.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="table-responsive">
<table class="table table-bordered table-data-div table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">@lang('File Name')</th>
<th scope="col">Received Date</th>
</tr>
</thead>
<tbody>
@isset($files)
@foreach($files as $file)
<tr>
<td>{{($loop->index + 1)}}</td>
<td><a href="{{url($file->file_path)}}" target="_blank">{{$file->title}}</a></td>
<td>{{$file->created_at->format('M d Y')}}</td>
</tr>
@endforeach
@endisset
</tbody>
</table>
</div>
9 changes: 8 additions & 1 deletion resources/views/components/file-uploader.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<input type="text" class="form-control" name="upload-title" id="upload-title" placeholder="@lang('File title here...')" required>
<br/>
@endif
@if($upload_type == 'certificate')
<label for="sections">Certificate Given to Student Code:</label>
<input type="text" class="form-control" name="to_student_code" id="to_student_code" placeholder="Student Code here..." required>
<br/>
@endif
@if($upload_type == 'routine')
<label for="sections">For</label>
<select id="sections" class="form-control" name="sections" required>
Expand Down Expand Up @@ -87,8 +92,10 @@
data.formData = {upload_type: '{{$upload_type}}',section_id:$('#sections').val(),title: $('#upload-title').val()};
@elseif($upload_type == 'syllabus')
data.formData = {upload_type: '{{$upload_type}}',class_id:$('#classes').val(),title: $('#upload-title').val()};
@else
@elseif($upload_type == 'notice')
data.formData = {upload_type: '{{$upload_type}}',title: $('#upload-title').val()};
@elseif($upload_type == 'certificate')
data.formData = {upload_type: '{{$upload_type}}',title: $('#upload-title').val(), given_to: $('#to_student_code').val()}; //certificate
@endif
@else
data.formData = {upload_type: '{{$upload_type}}',user_id: $('#userIdPic').val()};
Expand Down
Loading