refactor items table

This commit is contained in:
j3d1 2020-01-18 21:37:02 +01:00
parent 836fb96f42
commit 8ab469e017
4 changed files with 56 additions and 22 deletions

View file

@ -15,7 +15,7 @@ class Item extends Model
* @var array
*/
protected $fillable = [
'iid', 'item_uid', 'description', 'wann', 'wo', 'eid', 'cid', 'returned_at'
'iid', 'uid', 'description', 'eid', 'cid', 'returned_at'
];
@ -26,7 +26,7 @@ class Item extends Model
*
* @var array
*/
protected $hidden = ['created_at','updated_at', 'deleted_at', 'returned_at', 'eid', 'iid', 'wann', 'wo'];
protected $hidden = ['created_at','updated_at', 'deleted_at', 'returned_at', 'eid', 'iid'];
public static function restored($callback)
{
@ -34,8 +34,8 @@ class Item extends Model
public static function create(array $attributes = [])
{
$uid = static::query()->where('eid',$attributes['eid'])->max('item_uid') + 1;
$attributes['item_uid'] = $uid;
$uid = static::query()->where('eid',$attributes['eid'])->max('uid') + 1;
$attributes['uid'] = $uid;
static::query()->create($attributes);
return Item::find($uid);
}