Adjusted missing down on migration and code smells

This commit is contained in:
arne-kroeger 2024-07-29 19:04:10 +02:00
parent 3a0b03348e
commit e8d0147075
2 changed files with 6 additions and 2 deletions

View file

@ -314,7 +314,7 @@ class AccessoriesController extends Controller
*/
public function checkin(Request $request, $accessoryUserId = null)
{
if (is_null($accessory_checkout = DB::table('accessories_checkout')->find($accessoryUserId))) {
if (is_null($accessory_checkout = AccessoryCheckout::find($accessoryUserId))) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist')));
}
@ -324,7 +324,7 @@ class AccessoriesController extends Controller
$logaction = $accessory->logCheckin(User::find($accessory_checkout->assigned_to), $request->input('note'));
// Was the accessory updated?
if (DB::table('accessories_checkout')->where('id', '=', $accessory_checkout->id)->delete()) {
if ($accessory_checkout->delete()) {
if (! is_null($accessory_checkout->assigned_to)) {
$user = User::find($accessory_checkout->assigned_to);
}

View file

@ -33,6 +33,10 @@ return new class extends Migration
public function down(): void
{
if (Schema::hasTable('accessories_checkout')) {
Schema::table('accessories_checkout', function (Blueprint $table) {
$table->dropColumn('assigned_type');
});
Schema::rename('accessories_checkout', 'accessories_users');
}
}