whereNotNull('image_id') ->pluck('image_id') ->values()->all(); if (count($shelfImageIds) > 0) { DB::table('images') ->where('type', '=', 'cover_book') ->whereIn('id', $shelfImageIds) ->update(['type' => 'cover_bookshelf']); } } /** * Reverse the migrations. * * @return void */ public function down() { DB::table('images') ->where('type', '=', 'cover_bookshelf') ->update(['type' => 'cover_book']); } }