tethys/app/Transaction.php

39 lines
732 B
PHP
Raw Normal View History

2018-08-06 12:30:51 +00:00
<?php
namespace App;
2015-07-19 06:49:24 +00:00
use Illuminate\Database\Eloquent\Model;
2018-08-06 12:30:51 +00:00
class Transaction extends Model
{
protected $fillable = [
'student_id',
'book_id',
'borrowed_at',
'returned_at',
'fines',
'status'
];
public function student()
{
return $this->belongsTo('App\Person', 'student_id');
}
public function book()
{
//model, foreign key in tsis model, primary key of relation
return $this->belongsTo('App\Book', 'book_id', 'id');
}
public function scopeNotReturnedYet($query)
{
return $query->where('status', 0);
}
public function scopeReturned($query)
{
return $query->where('status', 1);
}
2015-07-19 06:49:24 +00:00
}