| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- class Student extends Model
- {
- use HasFactory;
- protected $table = 'students';
- protected $primaryKey = 'student_id';
- public $incrementing = false;
- protected $keyType = 'int';
- protected $fillable = [
- 'student_id',
- 'name',
- 'grade',
- 'class_name',
- 'teacher_id',
- 'remark',
- ];
- protected $casts = [
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
- ];
- public function teacher(): BelongsTo
- {
- return $this->belongsTo(Teacher::class, 'teacher_id', 'teacher_id');
- }
- public function user(): BelongsTo
- {
- return $this->belongsTo(User::class, 'student_id', 'user_id');
- }
- }
|