feat(migration): Add ssl_certificates table and model
				
					
				
			This commit is contained in:
		
							
								
								
									
										32
									
								
								app/Models/SslCertificate.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/Models/SslCertificate.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\Models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Database\Eloquent\Model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SslCertificate extends Model
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected $fillable = [
 | 
				
			||||||
 | 
					        'ssl_certificate',
 | 
				
			||||||
 | 
					        'ssl_private_key',
 | 
				
			||||||
 | 
					        'cert_file_path',
 | 
				
			||||||
 | 
					        'key_file_path',
 | 
				
			||||||
 | 
					        'resource_type',
 | 
				
			||||||
 | 
					        'resource_id',
 | 
				
			||||||
 | 
					        'mount_path',
 | 
				
			||||||
 | 
					        'host_path',
 | 
				
			||||||
 | 
					        'certificate_type',
 | 
				
			||||||
 | 
					        'valid_until',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'ssl_certificate' => 'encrypted',
 | 
				
			||||||
 | 
					        'ssl_private_key' => 'encrypted',
 | 
				
			||||||
 | 
					        'valid_until' => 'datetime',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function resource()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return $this->morphTo();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Database\Migrations\Migration;
 | 
				
			||||||
 | 
					use Illuminate\Database\Schema\Blueprint;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Schema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return new class extends Migration
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public function up()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::create('ssl_certificates', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->id();
 | 
				
			||||||
 | 
					            $table->text('ssl_certificate')->nullable();
 | 
				
			||||||
 | 
					            $table->text('ssl_private_key')->nullable();
 | 
				
			||||||
 | 
					            $table->string('resource_type')->nullable();
 | 
				
			||||||
 | 
					            $table->unsignedBigInteger('resource_id')->nullable();
 | 
				
			||||||
 | 
					            $table->enum('certificate_type', ['internal', 'external'])->default('internal');
 | 
				
			||||||
 | 
					            $table->timestamp('valid_until')->nullable();
 | 
				
			||||||
 | 
					            $table->timestamps();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->index(['resource_type', 'resource_id']);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function down()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::dropIfExists('ssl_certificates');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Reference in New Issue
	
	Block a user