12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- class BoxBinding extends Model
- {
- use ModelHelpers;
- //
- protected $table = "box_binding";
- protected $guarded = [];
- const BINDING_YES = 1;
- const BINDING_NO = 0;
- public static $bindingMaps = [
- self::BINDING_NO => '未绑定',
- self::BINDING_YES => '已绑定',
- ];
- const TBT = 1;
- const WKM = 2;
- public static $manufacturerMaps = [
- self::TBT => '泰比特',
- self::WKM => '威科姆',
- ];
- public function getBlekgAttribute($value)
- {
- if ($value == 1) {
- return true;
- } else {
- return false;
- }
- }
- public function setBlekgAttribute($value)
- {
- $this->attributes['blekg'] = $value ? 1 : 0;
- }
- public function bikes()
- {
- return $this->belongsTo(Bike::class, 'box_no', 'box_no');
- }
- public function updateBox($box_no, $data)
- {
- return $this->query()->where('box_no', $box_no)->update($data);
- }
- }
|