From be8af67c6181d3f45cfcca05dd817dc8af360773 Mon Sep 17 00:00:00 2001 From: Robonen Andrew Date: Wed, 16 Dec 2020 05:22:28 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20=D0=B6?= =?UTF-8?q?=D1=83=D1=80=D0=BD=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Filters/JournalFilter.php | 38 ++ app/Http/Controllers/Auth/LoginController.php | 9 +- .../Controllers/Auth/RegisterController.php | 2 +- app/Http/Controllers/JournalController.php | 111 ++++ .../Controllers/SchoolClassController.php | 19 +- app/Http/Requests/Auth/LoginRequest.php | 4 +- app/Http/Requests/JournalRequest.php | 25 + app/Models/HeadTeacher.php | 2 +- app/Models/Journal.php | 22 + app/Models/Parentt.php | 2 +- app/Models/SchoolClass.php | 1 - app/Models/Student.php | 12 +- app/Models/Teacher.php | 2 +- app/Models/User.php | 15 +- app/Providers/AuthServiceProvider.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- composer.json | 1 + composer.lock | 569 +++++++++++++++++- ...020_12_13_200032_create_journals_table.php | 47 ++ routes/api.php | 3 + routes/web.php | 2 + 21 files changed, 868 insertions(+), 22 deletions(-) create mode 100644 app/Filters/JournalFilter.php create mode 100644 app/Http/Controllers/JournalController.php create mode 100644 app/Http/Requests/JournalRequest.php create mode 100644 app/Models/Journal.php create mode 100644 database/migrations/2020_12_13_200032_create_journals_table.php diff --git a/app/Filters/JournalFilter.php b/app/Filters/JournalFilter.php new file mode 100644 index 0000000..07413e7 --- /dev/null +++ b/app/Filters/JournalFilter.php @@ -0,0 +1,38 @@ +builder = $this->builder->where('student_id', $value); + } + + protected function teacher($value) + { + $this->builder = $this->builder->where('teacher_id', $value); + } + + protected function subject($value) + { + $this->builder = $this->builder->where('subject_id', $value); + } + + protected function date($value) + { + $value = Carbon::createFromTimestamp($value/1000)->floorDays(); + $this->builder = $this->builder->where('updated_at', $value); + } + + protected function last($value) + { + $date = Carbon::now()->subDays($value); + $this->builder = $this->builder->where('updated_at', '>=', $date); + } + +} diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 4567da3..f74163e 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Http\Requests\Auth\LoginRequest; +use Carbon\Carbon; class LoginController extends Controller { @@ -11,10 +12,14 @@ class LoginController extends Controller { $credentials = $request->only('login', 'password'); - if (auth()->attempt($credentials)) + if (!auth()->attempt($credentials)) return response()->json('You cannot sign with those credentials!', 401); - $token = auth()->user()->makeToken($request->get('remember_me')); + $remember = (bool)$request->get('remember_me'); + $token = auth()->user()->createToken(config('app.name')); + + $token->token->expires_at = $remember ? Carbon::now()->addMonth() : Carbon::now()->addDay(); + $token->token->save(); return response()->json([ 'token_type' => 'Bearer', diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 732a46c..3db652c 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -18,7 +18,7 @@ class RegisterController extends Controller { $role = Role::where('name', $request->get('role')); - if ($role->isEmpty()) + if ($role->get()->isEmpty()) return response()->json('Role not found', 404); $user = User::create(array_merge( diff --git a/app/Http/Controllers/JournalController.php b/app/Http/Controllers/JournalController.php new file mode 100644 index 0000000..25f9bc4 --- /dev/null +++ b/app/Http/Controllers/JournalController.php @@ -0,0 +1,111 @@ +apply()->values(); + return response()->json($journal, 200); + } + + /** + * Show the form for creating a new resource. + * + * @return Response + */ +// public function create() +// { +// // +// } + + /** + * Store a newly created resource in storage. + * + * @param JournalRequest $request + * @return JsonResponse + */ + public function store(JournalRequest $request) + { + if ($request->has('date')) + $date = Carbon::createFromTimestamp($request->get('date')/1000)->floorDays(); + else + $date = Carbon::now()->floorDays(); + + + $exist = Journal::where('updated_at', $date) + ->where('student_id', $request->get('student_id')) + ->where('subject_id', $request->get('subject_id')) + ->get(); + + if ($exist->isNotEmpty()) + return response()->json('Оценка на эту дату уже выставлена', 200); + + $data = array_merge(['updated_at' => $date], $request->all()); + + $journal = Journal::create($data); + return response()->json(['id' => $journal->id], 200); + } + + /** + * Display the specified resource. + * + * @param int $journal + * @return JsonResponse + */ + public function show(int $journal) + { + return response()->json(Journal::find($journal), 200); + } + + /** + * Show the form for editing the specified resource. + * + * @param Journal $journal + * @return Response + */ +// public function edit(Journal $journal) +// { +// // +// } + + /** + * Update the specified resource in storage. + * + * @param JournalRequest $request + * @param Journal $journal + * @return JsonResponse + */ + public function update(JournalRequest $request, Journal $journal) + { + $journal->update($request->all()); + return response()->json(['id' => $journal->id], 200); + } + + /** + * Remove the specified resource from storage. + * + * @param Journal $journal + * @return JsonResponse + */ + public function destroy(Journal $journal) + { + $journal->delete(); + return response()->json(null, 200); + } +} diff --git a/app/Http/Controllers/SchoolClassController.php b/app/Http/Controllers/SchoolClassController.php index 574eadc..5940e90 100644 --- a/app/Http/Controllers/SchoolClassController.php +++ b/app/Http/Controllers/SchoolClassController.php @@ -2,9 +2,11 @@ namespace App\Http\Controllers; +use App\Filters\JournalFilter; use App\Http\Requests\SchoolClassRequest; use App\Models\SchoolClass; use App\Models\Teacher; +use Carbon\Carbon; use Illuminate\Database\QueryException; use Illuminate\Http\Request; @@ -65,11 +67,26 @@ class SchoolClassController extends Controller $students = $class->students; $studentsOnlyFIO = []; foreach ($students as $student) { - array_push($studentsOnlyFIO, $student->only('id', 'name', 'surname', 'patronymic')); + array_push($studentsOnlyFIO, $student->only('id', 'name', 'surname', 'patronymic')); } return response()->json($studentsOnlyFIO, 200); } + public function getStudentsJournal(SchoolClass $class, Request $request) + { + $students = $class->students; + $allStudents = []; + + foreach ($students as $student) + { + $cpys = clone $student; + $cpys->scores = (new JournalFilter($student->scores, $request))->apply()->values(); + $allStudents[] = $cpys; + } + + return response()->json($allStudents, 200); + } + //получение всех предметов для класса public function getSubjects(SchoolClass $class) { diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php index 5103286..78aa16e 100644 --- a/app/Http/Requests/Auth/LoginRequest.php +++ b/app/Http/Requests/Auth/LoginRequest.php @@ -14,6 +14,8 @@ class LoginRequest extends UserRequest */ public function specific() { - return []; + return [ + 'remember_me' => 'integer' + ]; } } diff --git a/app/Http/Requests/JournalRequest.php b/app/Http/Requests/JournalRequest.php new file mode 100644 index 0000000..bfc95f3 --- /dev/null +++ b/app/Http/Requests/JournalRequest.php @@ -0,0 +1,25 @@ + 'required|integer', + 'teacher_id' => 'required|integer', + 'subject_id' => 'required|integer', + 'score' => 'required|integer', + 'comment' => 'string', + 'date' => 'integer', + ]; + } +} diff --git a/app/Models/HeadTeacher.php b/app/Models/HeadTeacher.php index 013c51b..67d09ba 100644 --- a/app/Models/HeadTeacher.php +++ b/app/Models/HeadTeacher.php @@ -9,7 +9,7 @@ class HeadTeacher extends Model { use HasFactory; - protected $guarded = [ + protected $fillable = [ 'user_id', ]; diff --git a/app/Models/Journal.php b/app/Models/Journal.php new file mode 100644 index 0000000..66258c0 --- /dev/null +++ b/app/Models/Journal.php @@ -0,0 +1,22 @@ +belongsToMany(Subject::class, 'academic_plans', 'class_id') ->withPivot('hours_per_week', 'hours_per_year'); } - } diff --git a/app/Models/Student.php b/app/Models/Student.php index c17be35..e774c79 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -2,6 +2,7 @@ namespace App\Models; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Validator; @@ -10,14 +11,21 @@ class Student extends Model { use HasFactory; - protected $guarded = [ + protected $fillable = [ 'user_id', + ]; + + protected $guarded = [ 'updated_at', ]; public function schoolClass() { - return $this->belongsTo(SchoolClass::class, 'class_id'); + return $this->belongsTo(SchoolClass::class, 'class_id')->where(''); + } + public function scores() + { + return $this->hasMany(Journal::class, 'student_id'); } } diff --git a/app/Models/Teacher.php b/app/Models/Teacher.php index e04358f..adf2c42 100644 --- a/app/Models/Teacher.php +++ b/app/Models/Teacher.php @@ -10,7 +10,7 @@ class Teacher extends Model { use HasFactory; - protected $guarded = [ + protected $fillable = [ 'user_id', ]; diff --git a/app/Models/User.php b/app/Models/User.php index cb3c6d9..62d5606 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,7 +5,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; -use Carbon\Carbon; class User extends Authenticatable { @@ -58,11 +57,11 @@ class User extends Authenticatable return $this->hasOne(HeadTeacher::class); } - public function makeToken(bool $remember) - { - $token = $this->createToken(config('app.name')); - $token->token->expires_at = $remember ? Carbon::now()->addMonth() : Carbon::now()->addDay(); - $token->token->save(); - return $token; - } +// public function makeToken(bool $remember) +// { +// $token = $this->createToken(config('app.name')); +// $token->token->expires_at = $remember ? Carbon::now()->addMonth() : Carbon::now()->addDay(); +// $token->token->save(); +// return $token; +// } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index f31a7fb..8952634 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -26,6 +26,6 @@ class AuthServiceProvider extends ServiceProvider { $this->registerPolicies(); - Passport::routes(); +// Passport::routes(); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 4283423..927be5d 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -38,7 +38,7 @@ class RouteServiceProvider extends ServiceProvider $this->configureRateLimiting(); $this->routes(function () { - Route::prefix('/api') + Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); diff --git a/composer.json b/composer.json index 9e62841..b25eb7a 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "license": "MIT", "require": { "php": "^7.3|^8.0", + "cboden/ratchet": "^0.4.3", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", diff --git a/composer.lock b/composer.lock index f88e116..5f6811a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d29a824fe1ba5e1a371425931ce19f0b", + "content-hash": "b864dde6a95522044afee456c400fb07", "packages": [ { "name": "asm89/stack-cors", @@ -110,6 +110,63 @@ ], "time": "2020-08-18T23:57:15+00:00" }, + { + "name": "cboden/ratchet", + "version": "v0.4.3", + "source": { + "type": "git", + "url": "https://github.com/ratchetphp/Ratchet.git", + "reference": "466a0ecc83209c75b76645eb823401b5c52e5f21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ratchetphp/Ratchet/zipball/466a0ecc83209c75b76645eb823401b5c52e5f21", + "reference": "466a0ecc83209c75b76645eb823401b5c52e5f21", + "shasum": "" + }, + "require": { + "guzzlehttp/psr7": "^1.0", + "php": ">=5.4.2", + "ratchet/rfc6455": "^0.3", + "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5", + "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0", + "symfony/routing": "^2.6|^3.0|^4.0|^5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ratchet\\": "src/Ratchet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "role": "Developer" + }, + { + "name": "Matt Bonneau", + "role": "Developer" + } + ], + "description": "PHP WebSocket library", + "homepage": "http://socketo.me", + "keywords": [ + "Ratchet", + "WebSockets", + "server", + "sockets", + "websocket" + ], + "time": "2020-07-07T15:50:14+00:00" + }, { "name": "defuse/php-encryption", "version": "v2.2.1", @@ -491,6 +548,49 @@ ], "time": "2020-11-14T15:56:27+00:00" }, + { + "name": "evenement/evenement", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Evenement": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "time": "2017-07-23T21:35:13+00:00" + }, { "name": "fideloper/proxy", "version": "4.4.1", @@ -2932,6 +3032,473 @@ ], "time": "2020-08-18T17:17:46+00:00" }, + { + "name": "ratchet/rfc6455", + "version": "v0.3", + "source": { + "type": "git", + "url": "https://github.com/ratchetphp/RFC6455.git", + "reference": "c8651c7938651c2d55f5d8c2422ac5e57a183341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ratchetphp/RFC6455/zipball/c8651c7938651c2d55f5d8c2422ac5e57a183341", + "reference": "c8651c7938651c2d55f5d8c2422ac5e57a183341", + "shasum": "" + }, + "require": { + "guzzlehttp/psr7": "^1.0", + "php": ">=5.4.2" + }, + "require-dev": { + "phpunit/phpunit": "5.7.*", + "react/socket": "^1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ratchet\\RFC6455\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "role": "Developer" + }, + { + "name": "Matt Bonneau", + "role": "Developer" + } + ], + "description": "RFC6455 WebSocket protocol handler", + "homepage": "http://socketo.me", + "keywords": [ + "WebSockets", + "rfc6455", + "websocket" + ], + "time": "2020-05-15T18:31:24+00:00" + }, + { + "name": "react/cache", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "44a568925556b0bd8cacc7b49fb0f1cf0d706a0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/44a568925556b0bd8cacc7b49fb0f1cf0d706a0c", + "reference": "44a568925556b0bd8cacc7b49fb0f1cf0d706a0c", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2020-09-18T12:12:35+00:00" + }, + { + "name": "react/dns", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "665260757171e2ab17485b44e7ffffa7acb6ca1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/665260757171e2ab17485b44e7ffffa7acb6ca1f", + "reference": "665260757171e2ab17485b44e7ffffa7acb6ca1f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.0 || ^0.5", + "react/promise": "^3.0 || ^2.7 || ^1.2.1", + "react/promise-timer": "^1.2" + }, + "require-dev": { + "clue/block-react": "^1.2", + "phpunit/phpunit": "^9.3 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2020-09-18T12:12:55+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "6d24de090cd59cfc830263cfba965be77b563c13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/6d24de090cd59cfc830263cfba965be77b563c13", + "reference": "6d24de090cd59cfc830263cfba965be77b563c13", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" + }, + "suggest": { + "ext-event": "~1.0 for ExtEventLoop", + "ext-pcntl": "For signal handling support when using the StreamSelectLoop", + "ext-uv": "* for ExtUvLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "time": "2020-01-01T18:39:52+00:00" + }, + { + "name": "react/promise", + "version": "v2.8.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/f3cff96a19736714524ca0dd1d4130de73dbbbc4", + "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "time": "2020-05-12T15:16:56+00:00" + }, + { + "name": "react/promise-timer", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise-timer.git", + "reference": "daee9baf6ef30c43ea4c86399f828bb5f558f6e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/daee9baf6ef30c43ea4c86399f828bb5f558f6e6", + "reference": "daee9baf6ef30c43ea4c86399f828bb5f558f6e6", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", + "react/promise": "^3.0 || ^2.7.0 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Promise\\Timer\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.", + "homepage": "https://github.com/reactphp/promise-timer", + "keywords": [ + "async", + "event-loop", + "promise", + "reactphp", + "timeout", + "timer" + ], + "time": "2020-07-10T12:18:06+00:00" + }, + { + "name": "react/socket", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "e2b96b23a13ca9b41ab343268dbce3f8ef4d524a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/e2b96b23a13ca9b41ab343268dbce3f8ef4d524a", + "reference": "e2b96b23a13ca9b41ab343268dbce3f8ef4d524a", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.1", + "react/event-loop": "^1.0 || ^0.5", + "react/promise": "^2.6.0 || ^1.2.1", + "react/promise-timer": "^1.4.0", + "react/stream": "^1.1" + }, + "require-dev": { + "clue/block-react": "^1.2", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/promise-stream": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2020-08-28T12:49:05+00:00" + }, + { + "name": "react/stream", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "7c02b510ee3f582c810aeccd3a197b9c2f52ff1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/7c02b510ee3f582c810aeccd3a197b9c2f52ff1a", + "reference": "7c02b510ee3f582c810aeccd3a197b9c2f52ff1a", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "time": "2020-05-04T10:17:57+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.2.3", diff --git a/database/migrations/2020_12_13_200032_create_journals_table.php b/database/migrations/2020_12_13_200032_create_journals_table.php new file mode 100644 index 0000000..93f215c --- /dev/null +++ b/database/migrations/2020_12_13_200032_create_journals_table.php @@ -0,0 +1,47 @@ +id(); + $table->unsignedBigInteger('teacher_id'); + $table->unsignedBigInteger('student_id'); + $table->unsignedBigInteger('subject_id'); + $table->unsignedBigInteger('score'); + $table->string('comment')->nullable(); + $table->timestamps(); + + $table->foreign('subject_id') + ->references('id')->on('subjects'); + + $table->foreign('teacher_id') + ->references('id')->on('teachers') + ->onDelete('cascade'); + + $table->foreign('student_id') + ->references('id')->on('students') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('journals'); + } +} diff --git a/routes/api.php b/routes/api.php index 94e2235..aaea0a2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,8 +23,11 @@ Route::apiResource('subjects', 'SubjectController'); Route::apiResource('classes', 'SchoolClassController'); Route::post('classes/{class}/teacher', 'SchoolClassController@addTeacher'); Route::get('classes/{class}/students', 'SchoolClassController@getStudents'); //все ученики класса +Route::get('classes/{class}/journal', 'SchoolClassController@getStudentsJournal'); //все ученики класса с оценками Route::get('classes/{class}/subjects', 'SchoolClassController@getSubjects'); //все предметы класса +Route::apiResource('journal', 'JournalController'); + Route::apiResource('themes', 'ThemeController'); Route::apiResource('timetables', 'TimetableController'); diff --git a/routes/web.php b/routes/web.php index 84fc59a..60b14a6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,3 +12,5 @@ | contains the "web" middleware group. Now create something great! | */ + +Route::view('/', 'auth');