my changes
This commit is contained in:
parent
28301e4312
commit
8dc1f1b048
263 changed files with 36882 additions and 4453 deletions
75
app/Book.php
75
app/Book.php
|
@ -1,51 +1,50 @@
|
|||
<?php namespace App;
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model {
|
||||
class Book extends Model
|
||||
{
|
||||
protected $table = 'books';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'category_id',
|
||||
'shelf_id'
|
||||
];
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'project_id'
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Category');
|
||||
|
||||
}
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo('App\Project', 'project_id', 'id');
|
||||
}
|
||||
|
||||
public function shelf()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Shelf');
|
||||
|
||||
}
|
||||
// public function shelf()
|
||||
// {
|
||||
// return $this->belongsTo('App\Shelf');
|
||||
// }
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
public function transactions()
|
||||
{
|
||||
//model, foreign key on the Transaction model is book_id, local id
|
||||
return $this->hasMany('App\Transaction', 'book_id', 'id');
|
||||
}
|
||||
|
||||
return $this->hasMany('App\Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
|
||||
return $query->where('stock', '>', 0);
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
return $query->where('stock', '>', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
|
||||
return $query->orderBy('title');
|
||||
|
||||
}
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
return $query->orderBy('title');
|
||||
}
|
||||
|
||||
public function hasProject()
|
||||
{
|
||||
return $this->project()->exists();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue