1
0
mirror of https://github.com/robonen/education-project.git synced 2026-03-20 02:44:31 +00:00

исправил конфликты после обновления ветки

This commit is contained in:
ashen-1-dev
2020-12-16 20:57:35 +07:00
24 changed files with 427 additions and 168 deletions

29
app/Models/ChatLink.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ChatLink extends Model
{
use HasFactory;
protected $fillable = [
'name',
'link',
'class_id',
];
public function schoolClass()
{
return $this->belongsTo(SchoolClass::class, 'class_id');
}
public function creator()
{
return $this->hasMany(User::class, 'creator');
}
}

View File

@@ -11,6 +11,11 @@ class HeadTeacher extends Model
protected $guarded = [
'user_id',
'updated_at',
];
protected $hidden = [
'user_id',
];
public function user()

View File

@@ -12,6 +12,11 @@ class Parentt extends Model
protected $guarded = [
'user_id',
'updated_at',
];
protected $hidden = [
'user_id',
];
public function user()

View File

@@ -26,8 +26,17 @@ class SchoolClass extends Model
->withPivot('hours_per_week', 'hours_per_year');
}
public function tasks() {
return $this->hasMany(Task::class, 'class_id');
}
public function chatLinks()
{
return $this->hasMany(ChatLink::class, 'class_id');
}
}

View File

@@ -15,6 +15,10 @@ class Student extends Model
'updated_at',
];
protected $hidden = [
'user_id',
];
public function schoolClass()
{
return $this->belongsTo(SchoolClass::class, 'class_id');

View File

@@ -12,6 +12,11 @@ class Teacher extends Model
protected $guarded = [
'user_id',
'updated_at',
];
protected $hidden = [
'user_id',
];
public function schoolClass()

View File

@@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Carbon\Carbon;
use Laravel\Passport\HasApiTokens;
class User extends Authenticatable
{
use HasFactory, Notifiable;
use HasFactory, Notifiable, HasApiTokens;
/**
* The attributes that are mass assignable.
@@ -41,7 +42,7 @@ class User extends Authenticatable
{
foreach ($roles as $role)
{
if ($this->role->contains('name', $role))
if ($this->role->name == $role)
return true;
}
@@ -58,11 +59,24 @@ class User extends Authenticatable
return $this->hasOne(HeadTeacher::class);
}
public function makeToken(bool $remember)
public function teacher()
{
$token = $this->createToken(config('app.name'));
$token->token->expires_at = $remember ? Carbon::now()->addMonth() : Carbon::now()->addDay();
$token->token->save();
return $token;
return $this->hasOne(Teacher::class);
}
public function student()
{
return $this->hasOne(Student::class);
}
public function parent()
{
return $this->hasOne(Parentt::class);
}
public function chatLinks()
{
return $this->hasMany(ChatLink::class, 'creator');
}
}