Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Backpack\CRUD\CrudTrait;
- class Agent_kerjasama extends Model
- {
- use CrudTrait;
- /*
- |--------------------------------------------------------------------------
- | GLOBAL VARIABLES
- |--------------------------------------------------------------------------
- */
- protected $table = 'perusahaans';
- // protected $primaryKey = 'id';
- // public $timestamps = false;
- // protected $guarded = ['id'];
- protected $fillable = [
- 'id',
- 'agen_type',
- 'parent_id',
- 'nama_perusahaan',
- 'jenis_izin',
- 'nomor_izin_usaha',
- 'no_telp',
- 'npwp',
- 'negara_id',
- 'province_id',
- 'regency_id',
- 'district_id',
- 'village_id',
- 'alamat',
- 'latitude',
- 'longitude',
- 'nama_pimpinan',
- 'no_ktp_pimpinan',
- 'file_surat_izin',
- 'file_npwp',
- 'file_ktp_pimpinan',
- 'status_perusahaan',
- 'token'
- ];
- // protected $hidden = [];
- // protected $dates = [];
- /*
- |--------------------------------------------------------------------------
- | FUNCTIONS
- |--------------------------------------------------------------------------
- */
- /*
- |--------------------------------------------------------------------------
- | RELATIONS
- |--------------------------------------------------------------------------
- */
- public function perusahaan()
- {
- return $this->belongsTo('App\Models\Perusahaan', 'parent_id', 'id');
- }
- public function province()
- {
- return $this->belongsTo('App\Models\Province');
- }
- public function regency()
- {
- return $this->belongsTo('App\Models\Regency');
- }
- public function district()
- {
- return $this->belongsTo('App\Models\District');
- }
- /*
- |--------------------------------------------------------------------------
- | SCOPES
- |--------------------------------------------------------------------------
- */
- /*
- |--------------------------------------------------------------------------
- | ACCESORS
- |--------------------------------------------------------------------------
- */
- /*
- |--------------------------------------------------------------------------
- | MUTATORS
- |--------------------------------------------------------------------------
- */
- public function setFileSuratIzinAttribute($value)
- {
- $attribute_name = "file_surat_izin";
- $disk = "public";
- $destination_path = "file-surat-izin/" . date('Y') . '/' . date('m');
- $this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
- }
- public function setFileNpwpAttribute($value)
- {
- $attribute_name = "file_npwp";
- $disk = "public";
- $destination_path = "file-npwp/" . date('Y') . '/' . date('m');
- $this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
- }
- public function setFileKtpPimpinanAttribute($value)
- {
- $attribute_name = "file_ktp_pimpinan";
- $disk = "public";
- $destination_path = "file-ktp-pimpinan/" . date('Y') . '/' . date('m');
- $this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
- }
- public function showAgentDetail($crud = false)
- {
- return '<a class="btn btn-xs btn-default" target="_blank" href="'.route('crud.register/agen-berizin.show', $this->id).'" data-toggle="tooltip" title="Just a demo custom button."><i class="fa fa-search"></i> Lihat Detil</a>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement