����JFIF��x�x����'
Server IP : 66.29.137.217 / Your IP : 18.116.87.126 Web Server : LiteSpeed System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : gltevjme ( 1095) PHP Version : 7.0.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/gltevjme/cbt.bofirm.com/vendor/staudenmeir/belongs-to-through/src/Traits/ |
Upload File : |
<?php namespace Znck\Eloquent\Traits; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Znck\Eloquent\Relations\BelongsToThrough as Relation; trait BelongsToThrough { /** * Define a belongs-to-through relationship. * * @param string $related * @param array|string $through * @param string|null $localKey * @param string $prefix * @param array $foreignKeyLookup * @return \Znck\Eloquent\Relations\BelongsToThrough */ public function belongsToThrough($related, $through, $localKey = null, $prefix = '', $foreignKeyLookup = []) { $relatedInstance = $this->newRelatedInstance($related); $throughParents = []; $foreignKeys = []; foreach ((array) $through as $model) { $foreignKey = null; if (is_array($model)) { $foreignKey = $model[1]; $model = $model[0]; } $instance = $this->belongsToThroughParentInstance($model); if ($foreignKey) { $foreignKeys[$instance->getTable()] = $foreignKey; } $throughParents[] = $instance; } foreach ($foreignKeyLookup as $model => $foreignKey) { $instance = new $model; if ($foreignKey) { $foreignKeys[$instance->getTable()] = $foreignKey; } } return $this->newBelongsToThrough($relatedInstance->newQuery(), $this, $throughParents, $localKey, $prefix, $foreignKeys); } /** * Create a through parent instance for a belongs-to-through relationship. * * @param string $model * @return \Illuminate\Database\Eloquent\Model */ protected function belongsToThroughParentInstance($model) { $segments = preg_split('/\s+as\s+/i', $model); /** @var \Illuminate\Database\Eloquent\Model $instance */ $instance = new $segments[0]; if (isset($segments[1])) { $instance->setTable($instance->getTable().' as '.$segments[1]); } return $instance; } /** * Instantiate a new BelongsToThrough relationship. * * @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Model $parent * @param \Illuminate\Database\Eloquent\Model[] $throughParents * @param string $localKey * @param string $prefix * @param array $foreignKeyLookup * @return \Znck\Eloquent\Relations\BelongsToThrough */ protected function newBelongsToThrough(Builder $query, Model $parent, array $throughParents, $localKey, $prefix, array $foreignKeyLookup) { return new Relation($query, $parent, $throughParents, $localKey, $prefix, $foreignKeyLookup); } }