Total Complexity | 3 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait EntryType |
||
8 | { |
||
9 | /** |
||
10 | * Insert / update entry type for given Contentful entry. |
||
11 | * |
||
12 | * @param array $entry |
||
13 | * @param string $contentfulType |
||
14 | * @return void |
||
15 | */ |
||
16 | protected function upsertEntryType(array $entry, string $contentfulType) |
||
17 | { |
||
18 | $pivot = DB::table('entry_types') |
||
19 | ->where('contentful_id', '=', $entry['sys']['id']) |
||
20 | ->first(); |
||
21 | |||
22 | if (empty($pivot)) { |
||
23 | DB::table('entry_types') |
||
24 | ->insert([ |
||
25 | 'contentful_id' => $entry['sys']['id'], |
||
26 | 'contentful_type' => $contentfulType, |
||
27 | ]); |
||
28 | } else { |
||
29 | DB::table('entry_types') |
||
30 | ->where('contentful_id', '=', $entry['sys']['id']) |
||
31 | ->update([ |
||
32 | 'contentful_type' => $contentfulType, |
||
33 | ]); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Delete entry types for given Contentful entry. |
||
39 | * |
||
40 | * @param string $entryId |
||
41 | * @return void |
||
42 | */ |
||
43 | protected function deleteEntryType(string $entryId) |
||
48 | } |
||
49 | } |
||
50 |