app/Http/Controllers/WebsiteUserController.php

line no. 136 –

[php]

if(isset($input[‘roles’]) && in_array(‘driver’,$input[‘roles’])) {

$markets = Market::where(‘zipcode’,$input[‘zipcode’])->pluck(‘id’);

if(count($markets) > 0) {
foreach($markets as $market) {
$driver_markets[] = [‘user_id’ => $user->id,’market_id’ => $market];
}
DriverMarket::insert($driver_markets);
}
}
[/php]

line no. 283 –

[php]

if(isset($input[‘roles’]) && in_array(‘driver’,$input[‘roles’]) && ($oldUser->zipcode != $input[‘zipcode’])) {
DB::transaction(function () use($id,$input) {
DriverMarket::where([‘user_id’ => $id])->delete();

$markets = Market::where(‘zipcode’,$input[‘zipcode’])->pluck(‘id’);

if(count($markets) > 0) {
foreach($markets as $market) {
$driver_markets[] = [‘user_id’ => $id,’market_id’ => $market];
}
DriverMarket::insert($driver_markets);
}
});
}
[/php]

app/Http/Controllers/API/UserAPIController.php

line no. 209 –

[php]
if($user->hasRole(‘driver’) && ($oldUser->zipcode != $input[‘zipcode’])) {
DB::transaction(function () use($id,$input) {
DriverMarket::where([‘user_id’ => $id])->delete();

$markets = Market::where(‘zipcode’,$input[‘zipcode’])->pluck(‘id’);

if(count($markets) > 0) {
foreach($markets as $market) {
$driver_markets[] = [‘user_id’ => $id,’market_id’ => $market];
}
DriverMarket::insert($driver_markets);
}
});
}
[/php]

app/Http/Controllers/MarketController.php

line no. 132 –

[php]
$drivers = Driver::join(‘users’,’users.id’,’drivers.user_id’)->where(‘zipcode’,$input[‘zipcode’])->pluck(‘users.id’);

if(count($drivers) > 0) {
foreach($drivers as $driver) {
$driver_markets[] = [‘user_id’ => $driver,’market_id’ => $market->id];
}
DriverMarket::insert($driver_markets);
}

[/php]

Syntax line: 243

[php]

if($oldMarket->zipcode != $input[‘zipcode’]) {
DB::transaction(function () use($id,$input) {

DriverMarket::where([‘market_id’ => $id])->delete();

$drivers = Driver::join(‘users’,’users.id’,’drivers.user_id’)->where(‘zipcode’,$input[‘zipcode’])->pluck(‘users.id’);

if(count($drivers) > 0) {
foreach($drivers as $driver) {
$driver_markets[] = [‘user_id’ => $driver,’market_id’ => $id];
}
DriverMarket::insert($driver_markets);
}
});
}
[/php]