master
cody 8 months ago
parent a29080a377
commit fda36cf5a4

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

@ -57,6 +57,11 @@ class Orders extends SoftDeletesModel
return $this->hasMany(OrderAgreement::class, "order_id","id"); 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() public function isOngoing()
{ {
return $this->status == self::STATUS_ONGOING; return $this->status == self::STATUS_ONGOING;

@ -88,7 +88,7 @@
<td> <td>
{{ $row->serial }} {{ $row->serial }}
</td> </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->project->name }}</td>
<td>{{ $row->bed->building->name }}</td> <td>{{ $row->bed->building->name }}</td>

Loading…
Cancel
Save