mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 02:44:31 +00:00
auth
This commit is contained in:
29
app/Models/ChatLink.php
Normal file
29
app/Models/ChatLink.php
Normal 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');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class HeadTeacher extends Model
|
||||
|
||||
protected $guarded = [
|
||||
'user_id',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -12,6 +12,7 @@ class Parentt extends Model
|
||||
|
||||
protected $guarded = [
|
||||
'user_id',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -26,4 +26,10 @@ class SchoolClass extends Model
|
||||
->withPivot('hours_per_week', 'hours_per_year');
|
||||
}
|
||||
|
||||
public function chatLinks()
|
||||
{
|
||||
return $this->hasMany(ChatLink::class, 'class_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ class Teacher extends Model
|
||||
|
||||
protected $guarded = [
|
||||
'user_id',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function schoolClass()
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user