OwnerContract.php 640 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. class OwnerContract extends Model
  6. {
  7. use ModelTimeFormat;
  8. protected $fillable=[
  9. "contract_number", //合同号
  10. "salesman", //销售名称
  11. "remark", //备注
  12. "owner_id", //外键货主
  13. ];
  14. public function files()
  15. { //合同文件
  16. return $this->hasMany(UploadFile::class,"table_id","id")
  17. ->where("table_name","contracts");
  18. }
  19. public function owner()
  20. { //货主
  21. return $this->belongsTo(Owner::class,"owner_id","id");
  22. }
  23. }