Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
esyede committed Oct 8, 2023
1 parent a35a4a0 commit 2e1d347
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 36 deletions.
2 changes: 0 additions & 2 deletions system/database/facile/relationships/belongsto.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public function foreign_value()
/**
* Bind objek ke relasi belongs-to menggunakan id-nya.
*
* @param int $id
*
* @return Facile
*/
public function bind($id)
Expand Down
4 changes: 3 additions & 1 deletion system/database/facile/relationships/belongstomany.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function __construct($model, $associated, $table, $foreign, $other)
protected function joining($model, $associated)
{
$models = [class_basename($model), class_basename($associated)];

sort($models);

return strtolower($models[0] . '_' . $models[1]);
Expand Down Expand Up @@ -214,6 +213,7 @@ protected function constrain()
{
$other = $this->other_key();
$foreign = $this->foreign_key();

$this->set_select($foreign, $other)->set_join($other)->set_where($foreign);
}

Expand All @@ -233,6 +233,7 @@ protected function set_select($foreign, $other)
}

$this->table->select($columns);

return $this;
}

Expand Down Expand Up @@ -338,6 +339,7 @@ public function with($columns)
$columns = is_array($columns) ? $columns : func_get_args();
$this->with = array_unique(array_merge($this->with, $columns));
$this->set_select($this->foreign_key(), $this->other_key());

return $this;
}

Expand Down
3 changes: 3 additions & 0 deletions system/database/facile/relationships/hasmany.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ public function save($models)
foreach ($models as $attributes) {
$class = get_class($this->model);
$model = ($attributes instanceof $class) ? $attributes : $this->fresh_model($attributes);

$foreign = $this->foreign_key();
$model->{$foreign} = $this->base->get_key();

$id = $model->get_key();
$model->exists = (!is_null($id) && in_array($id, $current));

$model->original = [];
$model->save();
}
Expand Down
2 changes: 1 addition & 1 deletion system/database/facile/relationships/hasone.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function initialize(array &$parents, $relationship)
*/
public function match($relationship, array &$parents, array $childrens)
{
$dictionary = [];
$foreign = $this->foreign_key();
$dictionary = [];

foreach ($childrens as $children) {
$dictionary[$children->{$foreign}] = $children;
Expand Down
1 change: 0 additions & 1 deletion system/database/facile/relationships/hasoneormany.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function insert($attributes)
}

$attributes[$this->foreign_key()] = $this->base->get_key();

return $this->model->create($attributes);
}

Expand Down
1 change: 0 additions & 1 deletion system/database/facile/relationships/relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static function foreign($model, $foreign = null)
}

$model = is_object($model) ? class_basename($model) : $model;

return strtolower(basename((string) $model) . '_id');
}

Expand Down
9 changes: 1 addition & 8 deletions system/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/*
|--------------------------------------------------------------------------
| Buat Application Key
| Buat / Baca Rakit Key
|--------------------------------------------------------------------------
| Pastikan file key.php sudah ada di base path, buat jika belum ada.
*/
Expand Down Expand Up @@ -83,13 +83,6 @@
}
}

/*
|--------------------------------------------------------------------------
| Salin _ide_helper.php
|--------------------------------------------------------------------------
| Utuk mengakomodasi autocomplete IDE anda agar lebih akurat.
*/

if (!is_file($file = dirname(__DIR__) . DS . '_ide_helper.php')) {
$stub = __DIR__ . DS . 'console' . DS . 'commands' . DS . 'stubs' . DS . 'system' . DS . '_ide_helper.stub';
copy($stub, $file);
Expand Down
4 changes: 2 additions & 2 deletions system/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public static function query($key = null, $default = null)
*/
public static function json($as_object = false)
{
static::$json = static::$json ?: json_decode(Request::foundation()->getContent());
return static::$json = $as_object
static::$json = static::$json ?: json_decode(Request::foundation()->getContent());
return static::$json = $as_object
? json_decode(json_encode(static::$json, JSON_FORCE_OBJECT), false)
: json_decode(json_encode(static::$json), true);
}
Expand Down
4 changes: 1 addition & 3 deletions system/redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ public function __construct($host, $port, $database = 0)
public static function db($name = 'default')
{
if (!isset(static::$databases[$name])) {
$config = Config::get('database.redis.' . $name, []);

if (empty($config)) {
if (empty($config = Config::get('database.redis.' . $name, []))) {
throw new \Exception(sprintf('Redis database config is not configured: %s', $name));
}

Expand Down
10 changes: 9 additions & 1 deletion system/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,15 @@ public static function error($code, array $headers = [])
return static::json(compact('status', 'message'), $code, $headers);
}

$view = View::exists('error.' . $code) ? 'error.' . $code : 'error.unknown';
$view = View::exists('error.' . $code)
? 'error.' . $code
: (View::exists('error.unknown') ? 'error.unknown' : false);

if (!$view) {
$view = Storage::get(path('system') . DS . 'foundation' . DS . 'oops' . DS . 'assets' . DS . 'debugger' . DS . '500.phtml');
return static::make($view, 500, $headers);
}

return static::view($view, compact('code', 'message'), $code, $headers);
}

Expand Down
32 changes: 16 additions & 16 deletions system/str.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,22 +607,22 @@ public static function lorem($count = 1, $max = 20, $standard = true)
$pool = explode(
' ',
'a ab ad accusamus adipisci alias aliquam amet animi aperiam ' .
'architecto asperiores aspernatur assumenda at atque aut beatae ' .
'blanditiis cillum commodi consequatur corporis corrupti culpa ' .
'cum cupiditate debitis delectus deleniti deserunt dicta ' .
'dignissimos distinctio dolor ducimus duis ea eaque earum eius ' .
'eligendi enim eos error esse est eum eveniet ex excepteur ' .
'exercitationem expedita explicabo facere facilis fugiat harum ' .
'hic id illum impedit in incidunt ipsa iste itaque iure iusto ' .
'laborum laudantium libero magnam maiores maxime minim minus ' .
'modi molestiae mollitia nam natus necessitatibus nemo neque ' .
'nesciunt nihil nisi nobis non nostrum nulla numquam occaecati ' .
'odio officia omnis optio pariatur perferendis perspiciatis ' .
'placeat porro possimus praesentium proident quae quia quibus ' .
'quo ratione recusandae reiciendis rem repellat reprehenderit ' .
'repudiandae rerum saepe sapiente sequi similique sint soluta ' .
'suscipit tempora tenetur totam ut ullam unde vel veniam vero ' .
'vitae voluptas'
'architecto asperiores aspernatur assumenda at atque aut beatae ' .
'blanditiis cillum commodi consequatur corporis corrupti culpa ' .
'cum cupiditate debitis delectus deleniti deserunt dicta ' .
'dignissimos distinctio dolor ducimus duis ea eaque earum eius ' .
'eligendi enim eos error esse est eum eveniet ex excepteur ' .
'exercitationem expedita explicabo facere facilis fugiat harum ' .
'hic id illum impedit in incidunt ipsa iste itaque iure iusto ' .
'laborum laudantium libero magnam maiores maxime minim minus ' .
'modi molestiae mollitia nam natus necessitatibus nemo neque ' .
'nesciunt nihil nisi nobis non nostrum nulla numquam occaecati ' .
'odio officia omnis optio pariatur perferendis perspiciatis ' .
'placeat porro possimus praesentium proident quae quia quibus ' .
'quo ratione recusandae reiciendis rem repellat reprehenderit ' .
'repudiandae rerum saepe sapiente sequi similique sint soluta ' .
'suscipit tempora tenetur totam ut ullam unde vel veniam vero ' .
'vitae voluptas'
);

$max = ($max <= 3) ? 4 : $max;
Expand Down

0 comments on commit 2e1d347

Please sign in to comment.