Filippo Bertilotti
2024-09-10 13f6a9f0f63796e7b9767ccd83f1c3a17d496b0c
app/Vola/Services/FakeSSODatabase/FakeSSODatabaseHandler.php
@@ -1,25 +1,28 @@
<?php
namespace App\Vola\Services\FakeSSODatabase;
use App\Models\Msisdn;
use App\Models\VodafoneUser;
use Exception;
use Illuminate\Support\Facades\DB;
use PDOException;
class FakeSSODatabaseHandler {
    /*public function insertDataIntoTable(array $data) {
        //usare insert() per inserire il valore nella tabella giusta
    }
    private function insert($value ,string $field, string $table) {
    }*/
    public function testInsert() {
    public function insertDataIntoTables(array $data) {
        try{
            DB::insert("insert into fakesso_vodafoneusers (Name, Surname) values (?, ?)", ["CIAO", "CIAONE"]);
        }catch(Exception $e) {
            echo $e;
            $userModel = VodafoneUser::create(['Name' => $data["Name"],
                                               'Surname' => $data["Surname"],
                                               'EmailAddress' => $data["EmailAddress"]]);
            Msisdn::create(['MSISDN' => $data["sim_1"],
                            'IdPiano' => $data['IdPiano'],
                            'LinkedUser' => $userModel->id]);
        }catch(PDOException $e) {
            echo $e->getMessage();
        }
    }