Remove SQL column in LARAVEL

  laravel, php

Hello I made this code to delete a column in laravel but the delete () command; Throw me
"Call to a member function delete () on string"

This is the code that results in this string from the sql

    //se elimina correctamente restaurant_user
    $restid = json_encode(DB::table('restaurant_user')->where('restaurant_id', $id)->first());
    //$restid = json_encode($restid);
    //echo "<script>console.log('Con Foreach transactions: " . $restid . "' );</script>";
    if ($restid) {
    $items = $restid;
    //echo "<script>console.log('Tienen que salir todas las variaciones: " . $items . "' );</script>";  
    foreach ((array) $items as $item) {
    echo "<script>console.log('Con Foreach transactions: " . $item . "' );</script>";           
    } else {
    return redirect()->route('admin.restaurants')->with(['message' => 'Algo salio mal en Restaurant_User']);

The $restid varaible throws me this result:


For some reason I can’t delete it

Source: Laravel

Leave a Reply