public function scopeSubgudang($query, $req = []) { $me = \Me::subgudang(); $user = \Auth::user()->permission; $access = $me->access == false && $user > 2 ? 'admin' : 'user'; $item = $query->join('data_karyawan', 'data_karyawan.id_karyawan', '=', 'data_penyesuaian_stok.id_karyawan')->where('status', 1); if ($access == 'admin') { $item->whereNotIn('data_penyesuaian_stok.id_gudang', [0]); } else { $item->where('data_penyesuaian_stok.id_gudang', $me->id_gudang); } if (count($req) > 0) { if (!empty($req['kode'])) { $item->where('data_penyesuaian_stok.no_penyesuaian_stok', $req['kode']); } if (!empty($req['tanggal'])) { $item->where('data_penyesuaian_stok.tanggal', $req['tanggal']); } if (!empty($req['id_gudang'])) { $item->where('data_penyesuaian_stok.id_gudang', $req['id_gudang']); } } $akses = \Me::statusGudang(); if (in_array($akses, [1, 2])) { $item->where('tipe', $akses); } $item->orderby('data_penyesuaian_stok.id_penyesuaian_stok', 'desc')->select('data_penyesuaian_stok.*', 'data_karyawan.nm_depan', 'data_karyawan.nm_belakang'); }
public function hasLiked() { if (!\Auth::check()) { return false; } return app('App\\Repositories\\LikeRepository')->hasLiked('comment', $this->id, \Auth::user()->id); }
/** * gets the user id of the current user * @return mixed */ public static function userId() { if (Auth::check()) { return Auth::user()->user_id; } else { return 0; } }
public function isOwner() { if (!\Auth::check()) { return false; } if (\Auth::user()->id == $this->user_id) { return true; } return false; }
/** * Регистрирует посещение * @param $target_id * @param $target_type */ public static function enrol($target_id, $target_type) { $user_id = 0; $user_model = \Auth::user(); if ($user_model) { $user_id = $user_model->id; } $request = \Request::instance(); self::create(['user_id' => $user_id, 'user_ip' => $request->getClientIp(), 'target_id' => $target_id, 'target_type' => $target_type]); }
public static function isSuperAdmin() { if (\Auth::check()) { if (\Auth::user()->role_id == 1) { return true; } return false; } return false; }
/** * Check if a logged in user has a specific rol or one of the given roles * * @param array $roles * @return boolean */ public static function hasRoles(array $roles) { $user = \Auth::user(); foreach ($roles as $role) { if (in_array($role, $user->roles()->lists('name')->toArray())) { return true; } } return false; }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); SlittingLogEntry::creating(function ($slittingLogEntry) { $slittingLogEntry->created_by = \Auth::user()->id; $slittingLogEntry->updated_by = \Auth::user()->id; }); SlittingLogEntry::updating(function ($slittingLogEntry) { $slittingLogEntry->updated_by = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); JobCosting::creating(function ($jobCosting) { $jobCosting->jc_user_added_id_fk = \Auth::user()->id; $jobCosting->jc_user_modified_id_fk = \Auth::user()->id; }); JobCosting::updating(function ($jobCosting) { $jobCosting->jc_user_modified_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); Material::creating(function ($material) { $material->material_added_user_id_fk = \Auth::user()->id; $material->material_modified_user_id_fk = \Auth::user()->id; }); Material::updating(function ($material) { $material->material_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); LaminatingLogSheet::creating(function ($laminatingLogSheet) { $laminatingLogSheet->created_by = \Auth::user()->id; $laminatingLogSheet->updated_by = \Auth::user()->id; }); LaminatingLogSheet::updating(function ($laminatingLogSheet) { $laminatingLogSheet->updated_by = \Auth::user()->id; }); }
protected static function boot() { static::creating(function (Content $model) { $model->user_id = \Auth::user()->id; $model->introduction === '' && ($model->introduction = str_limit($model->text_html, 200)); }); static::saving(function (Content $model) { $model->text_html = \Parsedown::instance()->parse($model->text); }); parent::boot(); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); ConsumablesMinimumLevel::creating(function ($consumablesMinimumLevel) { $consumablesMinimumLevel->created_by = \Auth::user()->id; $consumablesMinimumLevel->updated_by = \Auth::user()->id; }); ConsumablesMinimumLevel::updating(function ($consumablesMinimumLevel) { $consumablesMinimumLevel->updated_by = \Auth::user()->id; }); }
public function isOwner($userid = null) { if (!\Auth::check()) { return false; } $userid = empty($userid) ? \Auth::user()->id : $userid; if ($this->user_id == $userid) { return true; } return false; }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); DespatchLogEntry::creating(function ($despatchLogEntry) { $despatchLogEntry->created_by = \Auth::user()->id; $despatchLogEntry->updated_by = \Auth::user()->id; }); DespatchLogEntry::updating(function ($despatchLogEntry) { $despatchLogEntry->updated_by = \Auth::user()->id; }); }
/** * Воозвращает true, если продукт Отложен для данного пользователя * @return bool */ public function isDeferred() { /** * @var $user \App\User */ $user = \Auth::user(); if (!$user) { return false; } return (bool) $user->deferredProducts()->where('product_id', '=', $this->id)->count(); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); AdhesiveCostLog::creating(function ($adhesiveCostLog) { $adhesiveCostLog->adhesive_cost_added_user_id_fk = \Auth::user()->id; $adhesiveCostLog->adhesive_cost_modified_user_id_fk = \Auth::user()->id; }); AdhesiveCostLog::updating(function ($adhesiveCostLog) { $adhesiveCostLog->adhesive_cost_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); Ink::creating(function ($ink) { $ink->ink_added_user_id_fk = \Auth::user()->id; $ink->ink_modified_user_id_fk = \Auth::user()->id; }); Material::updating(function ($ink) { $ink->ink_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); LogisticsCostLog::creating(function ($logisticsCostLog) { $logisticsCostLog->logistic_cost_log_added_user_id_fk = \Auth::user()->id; $logisticsCostLog->logistic_cost_log_modified_user_id_fk = \Auth::user()->id; }); LogisticsCostLog::updating(function ($logisticsCostLog) { $logisticsCostLog->logistic_cost_log_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); EfficiencyIssue::creating(function ($efficiencyIssue) { $efficiencyIssue->created_by = \Auth::user()->id; $efficiencyIssue->updated_by = \Auth::user()->id; }); EfficiencyIssue::updating(function ($efficiencyIssue) { $efficiencyIssue->updated_by = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); MaterialInventoryItem::creating(function ($materialCostLog) { $materialCostLog->mat_inventory_added_user_id_fk = \Auth::user()->id; $materialCostLog->mat_inventory_modified_user_id_fk = \Auth::user()->id; }); MaterialInventoryItem::updating(function ($materialCostLog) { $materialCostLog->mat_inventory_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); WasteCode::creating(function ($wasteCode) { $wasteCode->created_by = \Auth::user()->id; $wasteCode->updated_by = \Auth::user()->id; }); WasteCode::updating(function ($wasteCode) { $wasteCode->updated_by = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); Tds::creating(function ($tds) { $tds->tds_added_user_id_fk = \Auth::user()->id; $tds->tds_modified_user_id_fk = \Auth::user()->id; }); Tds::updating(function ($tds) { $tds->tds_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); LaminatingGsmCheck::creating(function ($laminatingGsmCheck) { $laminatingGsmCheck->created_by = \Auth::user()->id; $laminatingGsmCheck->updated_by = \Auth::user()->id; }); LaminatingGsmCheck::updating(function ($laminatingGsmCheck) { $laminatingGsmCheck->updated_by = \Auth::user()->id; }); }
public static function generate() { if (!\Auth::check()) { return NULL; } $apiKey = new ApiKey(); $apiKey->user_id = \Auth::user()->id; $apiKey->api_key = \App\Helpers\Text::randomCryptoString(); $apiKey->save(); return $apiKey; }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); PrintStation::creating(function ($printStation) { $printStation->tds_ink_link_added_user_fk = \Auth::user()->id; $printStation->tds_ink_link_mod_user_fk = \Auth::user()->id; }); PrintStation::updating(function ($printStation) { $printStation->tds_ink_link_mod_user_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); JobCard::creating(function ($jobCard) { $jobCard->job_cards_added_user_id_fk = \Auth::user()->id; $jobCard->job_cards_modified_user_id_fk = \Auth::user()->id; }); JobCard::updating(function ($jobCard) { $jobCard->job_cards_modified_user_id_fk = \Auth::user()->id; }); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); EfficiencyReportLog::creating(function ($efficiencyReportLog) { $efficiencyReportLog->created_by = \Auth::user()->id; $efficiencyReportLog->updated_by = \Auth::user()->id; }); EfficiencyReportLog::updating(function ($efficiencyReportLog) { $efficiencyReportLog->updated_by = \Auth::user()->id; }); }
public function scopeHabis($query) { $me = \Me::subgudang(); $item = $query->where('status', 1)->where(\DB::raw('(`in` - `out`)'), '=', 0); if ($me->id_gudang > 0) { $item->where('id_gudang', $me->id_gudang); } else { if (\Auth::user()->permission < 3 && !$me->access) { $item->where('id_gudang', 0); } } }
public static function getPricingGridsForCurrentUser() { $user = \Auth::user(); if (!$user) { return []; } $result = self::where('user_id', '=', $user->id)->get(['id', 'name']); if (!$result) { return []; } return $result; }