update
This commit is contained in:
@@ -71,7 +71,7 @@ class Datastore extends Controller
|
||||
public function edit(int $id = 0)
|
||||
{
|
||||
$datastore = $this->datastoreRepository->findWithRelationships($id, ['host.datacenter']);
|
||||
|
||||
|
||||
if (!$datastore) {
|
||||
return back()->withErrors('Invalid Request');
|
||||
}
|
||||
|
||||
@@ -40,11 +40,16 @@ class DatastoreRepository extends BaseRepository implements DatastoreRepositoryI
|
||||
{
|
||||
$model = $this->model;
|
||||
if (count($relationships) > 0) {
|
||||
$validRelationships = [];
|
||||
foreach ($relationships as $relationship) {
|
||||
if (method_exists($model, $relationship)) {
|
||||
$model = $model->with($relationship);
|
||||
$firstRelation = explode('.', $relationship)[0];
|
||||
if (method_exists($model, $firstRelation)) {
|
||||
$validRelationships[] = $relationship;
|
||||
}
|
||||
}
|
||||
if (count($validRelationships) > 0) {
|
||||
$model = $model->with($validRelationships);
|
||||
}
|
||||
}
|
||||
|
||||
// Xử lý withCount
|
||||
|
||||
Reference in New Issue
Block a user