Created
June 19, 2020 17:57
-
-
Save FelixINX/d62a06a204f40b3a1d90a6647bd58260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$years = [ | |
(object)[ | |
'prefix' => '22%', | |
'sync_1' => 3, | |
'sync_2' => 22 | |
], | |
(object)[ | |
'prefix' => '23%', | |
'sync_1' => 4, | |
'sync_2' => 23 | |
], | |
(object)[ | |
'prefix' => '24%', | |
'sync_1' => 5, | |
'sync_2' => 24 | |
], | |
(object)[ | |
'prefix' => '25%', | |
'sync_1' => 6, | |
'sync_2' => 25 | |
], | |
(object)[ | |
'prefix' => '26%', | |
'sync_1' => 7, | |
'sync_2' => 26 | |
], | |
(object)[ | |
'prefix' => '27%', | |
'sync_1' => 8 | |
], | |
(object)[ | |
'prefix' => '28%', | |
'sync_1' => 9, | |
'sync_2' => 29 | |
], | |
(object)[ | |
'prefix' => '29%', | |
'sync_1' => 10 | |
], | |
(object)[ | |
'prefix' => '30%', | |
'sync_1' => 11, | |
], | |
(object)[ | |
'prefix' => '31%', | |
'sync_1' => 12, | |
], | |
(object)[ | |
'prefix' => '32%', | |
'sync_1' => 13, | |
], | |
(object)[ | |
'prefix' => '33%', | |
'sync_1' => 14, | |
'sync_2' => 42, | |
], | |
(object)[ | |
'prefix' => '36%', | |
'sync_1' => 17, | |
], | |
(object)[ | |
'prefix' => '37%', | |
'sync_1' => 18, | |
'sync_2' => 46 | |
], | |
(object)[ | |
'prefix' => '38%', | |
'sync_1' => 19, | |
'sync_2' => 47 | |
], | |
(object)[ | |
'prefix' => '39%', | |
'sync_1' => 20, | |
], | |
(object)[ | |
'prefix' => '40%', | |
'sync_1' => 21, | |
] | |
]; | |
foreach ($years as $year) { | |
$vehicles = Vehicle::where('agency_id', 1)->where('vehicle', 'like', $year->prefix)->select('id')->get(); | |
echo count($vehicles) . ' vehicles for ' . $year->prefix; | |
foreach ($vehicles as $vehicle) { | |
$vehicle->links()->attach($year->sync_1); | |
if ($year->sync_2) { | |
$vehicle->links()->attach($year->sync_2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment