This is an outdated version of PHPasap. Please visit for the latest version.

CRUD Application: Delete

In this section we'll delete a user. Making a GET request to /crud/delete/{user-id} should the delete the user with id {user-id}. Below is the controller method for this.

public method get_delete($user_id) {
    //delete query
    $no_of_deleted_users = DB::table("users")->where("id", "=", $user_id)->delete();
    if( $no_of_deleted_users )
        return Request::redirect_to("crud/index")->with(["success" => "User deleted successfully"]);
        return Request::redirect_to("crud/index")->with(["error" => "Unable to delete user"]);