I
I
ismailov1122016-08-04 12:08:57
ORM
ismailov112, 2016-08-04 12:08:57

Laravel. need to make a request for a selection of vacancies with periods?

DB::table('vacancies')
                ->leftJoin('periods', 'vacancies.id', '=', 'periods.id_vacancy')
                ->select('vacancies.title_u', 'periods.date_start', 'periods.date_end')
                ->take(1)->get();

Result:
array:1 [▼
  0 => {#389 ▼
    +"title_u": "Водитель"
    +"date_start": 1469680740
    +"date_end": 1469939940
  }
]

You need to make a request so that the vacancies have several periods in the array (the one below), How can this be done?
array:1 [▼
  0 => array:2 [▼
    "title_u" => "Водитель"
    "periods" => array:2 [▼
      "date_start" => 1469680740
      "date_end" => 1469939940
    ]
  ]
]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2016-08-04
@AmdY

So use ORM and your colleagues will not suit you at the same time.
There will be a simple code $vacancies->with('periods')->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question