Created
August 31, 2018 10:24
-
-
Save ferdhika31/5844e41945331157f3362192d887a8e5 to your computer and use it in GitHub Desktop.
Produk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
use App\Traits\BinarySchemaTrait as BinarySchema; | |
class CreateProdukHukumTable extends Migration | |
{ | |
use BinarySchema; | |
/** | |
* Run the migrations. | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create('produk_hukum', function (Blueprint $table) { | |
// $table->increments('id'); | |
$table->uuid('id')->unique(); | |
$table->integer('nomor'); | |
$table->string('tahun', 4); | |
$table->string('subjek', 100); | |
$table->date('tanggal_penetapan'); | |
$table->uuid('kategori_id'); | |
$table->uuid('status_produk_hukum_id'); | |
$table->uuid('pengajuan_produk_hukum_id'); | |
$table->integer('user_id')->unsigned(); | |
$table->foreign('user_id') | |
->references('id')->on('users') | |
->onDelete('cascade'); | |
$table->timestamps(); | |
$table->softDeletes(); | |
}); | |
$this->setForeignKey('produk_hukum', 'kategori_id', 'kategori', 'id'); | |
$this->setForeignKey('produk_hukum', 'status_produk_hukum_id', 'status_produk_hukum', 'id'); | |
$this->setForeignKey('produk_hukum', 'pengajuan_produk_hukum_id', 'pengajuan_produk_hukum', 'id'); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::dropIfExists('produk_hukum'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* @Author: Ferdhika Yudira | |
* @Website: http://dika.web.id | |
* @Date: 2018-08-29 09:24:10 | |
* @Email: fer@dika.web.id | |
*/ | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
use App\Traits\Uuid; | |
use Illuminate\Database\Eloquent\SoftDeletes; | |
class ProdukHukum extends Model | |
{ | |
use Uuid; | |
use SoftDeletes; | |
/** | |
* The table associated with the model. | |
* | |
* @var string | |
*/ | |
protected $table = 'produk_hukum'; | |
/** | |
* The attributes that should be mutated to dates. | |
* | |
* @var array | |
*/ | |
protected $dates = ['deleted_at']; | |
/** | |
* Indicates if the IDs are auto-incrementing. | |
* | |
* @var bool | |
*/ | |
public $incrementing = false; | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
protected $fillable = [ | |
'nomor', | |
'tahun', | |
'subjek', | |
'tanggal_penetapan' | |
]; | |
/** | |
* Get the pengajuanProdukHukum that owns the produk hukum. | |
*/ | |
public function pengajuanProdukHukum(){ | |
return $this->belongsTo('App\PengajuanProdukHukum'); | |
} | |
/** | |
* Get the statusProdukHukum that owns the produk hukum. | |
*/ | |
public function statusProdukHukum(){ | |
return $this->belongsTo('App\StatusProdukHukum'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment