master
cody 8 months ago
parent a29080a377
commit fda36cf5a4

@ -99,8 +99,8 @@ class OrdersController extends CommonController
"bed" => function ($query) {
$query->with(["room", "building", "area"]);
},
"orderAgreements" => function ($query) {
$query->with('file')->orderBy("id", "desc");
"orderAgreementByLast" => function ($query) {
$query->with('file');
}
])->where('status', $status)
->where(function ($query) use ($building_id, $area_id) {

@ -57,6 +57,11 @@ class Orders extends SoftDeletesModel
return $this->hasMany(OrderAgreement::class, "order_id","id");
}
public function orderAgreementByLast()
{
return $this->hasOne(OrderAgreement::class, "order_id","id")->orderBy("id", "desc");
}
public function isOngoing()
{
return $this->status == self::STATUS_ONGOING;

@ -88,7 +88,7 @@
<td>
{{ $row->serial }}
</td>
<td>{{isset($row->orderAgreements)?"/storage/" .$row->orderAgreements[0]:""}}</td>
<td>{{isset($row->orderAgreementByLast)?"/storage/" .$row->orderAgreementByLast->file->name:""}}</td>
<td>{{ $row->project->name }}</td>
<td>{{ $row->bed->building->name }}</td>

Loading…
Cancel
Save