relazione fra 2 record (vodafoneuser e msisdn)
| | |
| | | class Msisdn extends Model |
| | | { |
| | | |
| | | protected $table = "fakesso_msisdn"; |
| | | |
| | | /** |
| | | * The attributes that are mass assignable. |
| | | * |
| | | * @var array<int, string> |
| | | */ |
| | | protected $fillable = [ |
| | | 'VodafoneUser', |
| | | 'MSISDN', |
| | | 'CardType', |
| | | 'IdPiano', |
| | | 'VodafoneOne', |
| | | 'TopClub', |
| | | 'SeniorityCluster', |
| | | 'LinkedUser' |
| | | ]; |
| | | |
| | | public function user() |
| | | { |
| | | return $this->belongsTo('App\Models\VodafoneUser', 'VodafoneUser', 'id'); |
| | | return $this->belongsTo(VodafoneUser::class, 'LinkedUser'); |
| | | } |
| | | |
| | | public function products() |
| | | { |
| | | return $this->belongsToMany('App\Models\Products', 'pivot_msisdn_products', 'idProducts', 'idMsisdn'); |
| | | return $this->belongsToMany(Products::class, 'pivot_msisdn_products', 'idProducts', 'idMsisdn'); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | public function sims() |
| | | { |
| | | return $this->hasMany('App\Models\Msisdn','VodafoneUser', 'id'); |
| | | return $this->hasMany(Msisdn::class,'LinkedUser', 'id'); |
| | | } |
| | | |
| | | } |
| | |
| | | <?php |
| | | namespace App\Vola\Services\FakeSSODatabase; |
| | | |
| | | use App\Models\Msisdn; |
| | | use App\Models\VodafoneUser; |
| | | use Exception; |
| | | use Illuminate\Support\Facades\DB; |
| | |
| | | |
| | | class FakeSSODatabaseHandler { |
| | | |
| | | public function __construct() { |
| | | } |
| | | |
| | | public function insertDataIntoTables(array $data) { |
| | | |
| | | $user = |
| | | $userArray = |
| | | [ |
| | | 'Name' => $data["Name"], |
| | | 'Surname' => $data["Surname"], |
| | | 'EmailAddress' => $data["EmailAddress"] |
| | | ]; |
| | | |
| | | $msisdnArray = |
| | | [ |
| | | 'MSISDN' => $data["sim_1"], |
| | | 'IdPiano' => $data["IdPiano"] |
| | | ]; |
| | | |
| | | try{ |
| | | VodafoneUser::insert($user); |
| | | $userModel = VodafoneUser::create($userArray); |
| | | Msisdn::create(['MSISDN' => $data["sim_1"], |
| | | 'IdPiano' => $data['IdPiano'], |
| | | 'LinkedUser' => $userModel->id]); |
| | | |
| | | }catch(PDOException $e) { |
| | | echo $e->getMessage(); |
| | | } |
| | |
| | | $table->string('Name', 255)->nullable(); |
| | | $table->string('Description', 255)->nullable(); |
| | | $table->string('activationDateTime', 255)->nullable(); |
| | | $table->timestamps(); |
| | | }); |
| | | } |
| | | |
| | |
| | | $table->string('MicroBusiness', 255)->nullable(); |
| | | $table->string('HomePhone', 255)->nullable(); |
| | | $table->string('Address', 255)->nullable(); |
| | | $table->timestamps(); |
| | | }); |
| | | } |
| | | |
| | |
| | | $table->string('IdPiano', 255)->nullable(); |
| | | $table->string('VodafoneOne', 255)->nullable(); |
| | | $table->string('TopClub', 255)->nullable(); |
| | | $table->string('SenioriryCluster', 255)->nullable(); |
| | | $table->string('SenioriryCluster', 255)->nullable(); |
| | | $table->timestamps(); |
| | | }); |
| | | } |
| | | |