initial commit
This commit is contained in:
commit
28301e4312
219 changed files with 23035 additions and 0 deletions
51
app/Book.php
Executable file
51
app/Book.php
Executable file
|
@ -0,0 +1,51 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'category_id',
|
||||
'shelf_id'
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Category');
|
||||
|
||||
}
|
||||
|
||||
public function shelf()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Shelf');
|
||||
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
|
||||
return $this->hasMany('App\Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
|
||||
return $query->where('stock', '>', 0);
|
||||
|
||||
}
|
||||
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
|
||||
return $query->orderBy('title');
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue