ronaldkwandy

Untitled

Oct 21st, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Masters\Barang;
  4.  
  5. use Illuminate\Database\Eloquent\Model;
  6. use Auth;
  7.  
  8. /**
  9.  * App\Http\Controllers\Masters\Barang
  10.  *
  11.  * @property integer $id
  12.  */
  13. class Barang extends Model {
  14.  
  15.     public static $singleKey = "barang";
  16.     public static $multiKey = "barangs";
  17.     public static $searchParams = ["tipe", "harga_modal", "harga_sub", "harga_jual", "sell_out", "promo", "stok", "keterangan", "image_type", "image", "m_merk_id", "m_jenis_id", "aktif"];
  18.     protected $table = 'm_barang';
  19.     protected $fillable = ["tipe", "harga_modal", "harga_sub", "harga_jual", "sell_out", "promo", "stok", "keterangan", "image_type", "image", "m_merk_id", "m_jenis_id", "aktif"];
  20.  
  21.     protected static function boot() {
  22.         parent::boot();
  23.  
  24.         static::creating(function ($model) {
  25.             $model->created_by = Auth::check() ? Auth::user()->nama : 'Ryner';
  26.             $model->updated_by = Auth::check() ? Auth::user()->nama : 'Ryner';
  27.         });
  28.  
  29.         static::updating(function ($model) {
  30.             $model->updated_by = Auth::check() ? Auth::user()->nama : 'Ryner';
  31.         });
  32.     }
  33.  
  34.     public function merk() {
  35.         return $this->belongsTo('App\Http\Controllers\Masters\Merk\Merk', 'm_merk_id');
  36.     }
  37.  
  38. }
Add Comment
Please, Sign In to add comment