Skip to content

Commit

Permalink
Release version 2.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenanhung committed Sep 12, 2024
1 parent 1e48fdb commit d55f09a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
interface Environment
{
const PROJECT_NAME = 'My Database Packages by HungNG';
const VERSION = '2.2.3';
const LAST_MODIFIED = '2024-09-11';
const VERSION = '2.2.4';
const LAST_MODIFIED = '2024-09-12';
const AUTHOR_NAME = 'Hung Nguyen';
const AUTHOR_EMAIL = '[email protected]';
const AUTHOR_URL = 'https://nguyenanhung.com';
Expand Down
53 changes: 46 additions & 7 deletions src/Model/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,25 +771,49 @@ public function buildOperatorSpaceShipTo(Builder $db, $id, $field = 'id', $table
* @param $orderByField
* @param $defaultField
* @param $table
* @param $tmpTable
* @param $tmpField
*
* @return \Illuminate\Database\Query\Builder
* @author : 713uk13m <dev@nguyenanhung.com>
* @copyright: 713uk13m <dev@nguyenanhung.com>
* @time : 07/02/2023 28:46
*/
public function bindOrderBy(Builder $db, $orderByField, $defaultField = 'updated_at', $table = null)
{
public function bindOrderBy(
Builder $db,
$orderByField,
$defaultField = 'updated_at',
$table = null,
$tmpTable = null,
$tmpField = null
) {
if (empty($table)) {
$table = $this->table;
}
if (isset($orderByField) && is_array($orderByField) && count($orderByField) > 0) {
foreach ($orderByField as $field) {
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']);
if (
($tmpTable !== null && $tmpField !== null) &&
$field['field_name'] === $tmpField &&
$this->getSchema()->hasColumn($tmpTable, $tmpField)
) {
$db->orderBy($tmpTable . '.' . $tmpField, $field['order_value']);
} else {
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']);
}
}
} elseif (strtolower($defaultField) === 'random') {
$db->inRandomOrder();
} else {
$db->orderByDesc($table . '.' . $defaultField);
if (
($tmpTable !== null && $tmpField !== null) &&
$defaultField === $tmpField &&
$this->getSchema()->hasColumn($tmpTable, $tmpField)
) {
$db->orderByDesc($tmpTable . '.' . $tmpField);
} else {
$db->orderByDesc($table . '.' . $defaultField);
}
}

return $db;
Expand All @@ -801,20 +825,35 @@ public function bindOrderBy(Builder $db, $orderByField, $defaultField = 'updated
* @param \Illuminate\Database\Query\Builder $db
* @param $orderByField
* @param $table
* @param $tmpTable
* @param $tmpField
*
* @return \Illuminate\Database\Query\Builder
* @author : 713uk13m <dev@nguyenanhung.com>
* @copyright: 713uk13m <dev@nguyenanhung.com>
* @time : 07/02/2023 28:41
*/
public function bindOrderByNoDefault(Builder $db, $orderByField, $table = null)
{
public function bindOrderByNoDefault(
Builder $db,
$orderByField,
$table = null,
$tmpTable = null,
$tmpField = null
) {
if (empty($table)) {
$table = $this->table;
}
if (isset($orderByField) && is_array($orderByField) && count($orderByField) > 0) {
foreach ($orderByField as $field) {
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']);
if (
($tmpTable !== null && $tmpField !== null) &&
$field['field_name'] === $tmpField &&
$this->getSchema()->hasColumn($tmpTable, $tmpField)
) {
$db->orderBy($tmpTable . '.' . $tmpField, $field['order_value']);
} else {
$db->orderBy($table . '.' . $field['field_name'], $field['order_value']);
}
}
}

Expand Down

0 comments on commit d55f09a

Please sign in to comment.