Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Commit

Permalink
Update CBController.php
Browse files Browse the repository at this point in the history
fixing count() is not array
  • Loading branch information
fherryfherry authored Aug 14, 2018
1 parent 2921b2e commit 6a73c27
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/controllers/CBController.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function cbView($template, $data)

private function checkHideForm()
{
if (count($this->hide_form)) {
if ($this->hide_form && count($this->hide_form)) {
foreach ($this->form as $i => $f) {
if (in_array($f['name'], $this->hide_form)) {
unset($this->form[$i]);
Expand Down Expand Up @@ -587,7 +587,7 @@ public function getIndex()
$prevalue[] = $d['label'];
}
}
if (count($prevalue)) {
if ($prevalue && count($prevalue)) {
$value = implode(", ", $prevalue);
}
}
Expand Down Expand Up @@ -912,7 +912,7 @@ public function validation($id = null)
if (@$di['validation']) {

$exp = explode('|', $di['validation']);
if (count($exp)) {
if ($exp && count($exp)) {
foreach ($exp as &$validationItem) {
if (substr($validationItem, 0, 6) == 'unique') {
$parseUnique = explode(',', str_replace('unique:', '', $validationItem));
Expand Down Expand Up @@ -999,7 +999,7 @@ public function input_assignment($id = null)
continue;
}

if (count($hide_form)) {
if ($hide_form && count($hide_form)) {
if (in_array($name, $hide_form)) {
continue;
}
Expand Down Expand Up @@ -1063,8 +1063,8 @@ public function input_assignment($id = null)
if ($ro['type'] == 'multitext') {
$name = $ro['name'];
$multitext = "";

for ($i = 0; $i <= count($this->arr[$name]) - 1; $i++) {
$maxI = ($this->arr[$name])?count($this->arr[$name]):0;
for ($i = 0; $i <= $maxI - 1; $i++) {
$multitext .= $this->arr[$name][$i]."|";
}
$multitext = substr($multitext, 0, strlen($multitext) - 1);
Expand Down Expand Up @@ -1196,7 +1196,8 @@ public function postAddSave()
if ($ro['type'] == 'child') {
$name = str_slug($ro['label'], '');
$columns = $ro['columns'];
$count_input_data = count(Request::get($name.'-'.$columns[0]['name'])) - 1;
$getColName = Request::get($name.'-'.$columns[0]['name']);
$count_input_data = ($getColName)?(count($getColName) - 1):0;
$child_array = [];

for ($i = 0; $i <= $count_input_data; $i++) {
Expand Down Expand Up @@ -1333,7 +1334,8 @@ public function postEditSave($id)
if ($ro['type'] == 'child') {
$name = str_slug($ro['label'], '');
$columns = $ro['columns'];
$count_input_data = count(Request::get($name.'-'.$columns[0]['name'])) - 1;
$getColName = Request::get($name.'-'.$columns[0]['name']);
$count_input_data = ($getColName)?(count($getColName) - 1):0;
$child_array = [];
$childtable = CRUDBooster::parseSqlTable($ro['table'])['table'];
$fk = $ro['foreign_key'];
Expand Down Expand Up @@ -1450,16 +1452,18 @@ public function getImportData()
$file = storage_path('app/'.$file);
$rows = Excel::load($file, function ($reader) {
})->get();

Session::put('total_data_import', count($rows));

$countRows = ($rows)?count($rows):0;

Session::put('total_data_import', $countRows);

$data_import_column = [];
foreach ($rows as $value) {
$a = [];
foreach ($value as $k => $v) {
$a[] = $k;
}
if (count($a)) {
if ($a && count($a)) {
$data_import_column = $a;
}
break;
Expand Down

0 comments on commit 6a73c27

Please sign in to comment.