grepper add code answer
ng if cart icon got items only show numbers
<ion-icon slot="end" (click)="openCart()" #cart class="cart_icons" name="cart-outline"></ion-icon>
<div *ngIf="(cartItemCount | async) >= 1 ">
<span>{{ cartItemCount | async }}</span>
</div>
</div>
3.86
7
to connect relationships and display foreign has links. need to identify
*ngIf this.bankAccounts.id == this.company.id similar to Ionic
public function index($id = null)
{
$this->paginate = [
'contain' => ['Organizations','Banks', 'Companies'],
];
$bankAccounts = $this->BankAccounts->find();
if($id){
$bankAccounts->where(['organization_id' => $id]);
$organization = $this->BankAccounts->Organizations->findById($id)->first();
$this->set('organization', $organization);
}
if ($id){
$bankAccounts->where(['company_id' => $id]);
$company = $this->BankAccounts->Companies->findById($id)->first();
$this->set('company', $company);
}
$bankAccounts = $this->paginate($this->BankAccounts);
$this->set(compact('bankAccounts'));
}
public function edit($id = null)
{
$bankAccount = $this->BankAccounts->get($id, [
'contain' => [],
]);
$bankAccount = $this->BankAccounts->find();
if($id){
$bankAccount->where(['organization_id' => $id]);
$organization = $this->BankAccounts->Organizations->findById($id)->first();
$this->set('organization', $organization);
}
if ($id){
$bankAccount->where(['company_id' => $id]);
$company = $this->BankAccounts->Companies->findById($id)->first();
$this->set('company', $company);
}
if ($this->request->is(['patch', 'post', 'put'])) {
$bankAccount = $this->BankAccounts->patchEntity($bankAccount, $this->request->getData());
if ($this->BankAccounts->save($bankAccount)) {
$this->Flash->success(__('The bank account has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The bank account could not be saved. Please, try again.'));
}
$organizations = $this->BankAccounts->Organizations->find('list', ['limit' => 200]);
$companies = $this->BankAccounts->Companies->find('list', ['limit' => 200]);
$banks = $this->BankAccounts->Banks->find('list', ['limit' => 200]);
$this->set(compact('bankAccount', 'organizations', 'companies', 'banks'));
}
Thank you!
7
0
0
0
cakephp3
find($id) takes an id and returns a single model. If no matching model exist, it returns null.
findOrFail($id) takes an id and returns a single model. If no matching model exist, it throws an error1.
first() returns the first record found in the database. If no matching model exist, it returns null.
firstOrFail() returns the first record found in the database. If no matching model exist, it throws an error1.
get() returns a collection of models matching the query.
pluck($column) returns a collection of just the values in the given column. In previous versions of Laravel this method was called lists.
toArray() converts the model/collection into a simple PHP array.
Thank you!
0
0
4
3
ngFor filter products based on categories
*ngFor="let item of filteredvalues" at html
at TS
//filter products by category id
this.apiService.getList().subscribe(response => {
this.productsData = response;
this.filteredvalues = this.productsData.filter(res =>
res.category_id == this.id);
console.log('get all products', this.filteredvalues);
});
Thank you!
3
0
3.75
8
solve the error issue
$ cordova plugin add cordova-plugin-androidx
$ cordova plugin add cordova-plugin-androidx-adapter
npm install jetifier --save
npx jetify
npx cap sync
Thank you!
8
0
0
0
Cakephp 3 image upload with thumbnail and resize image
check Tables if its AllowEmptyString or AllowEmptyFile
check Form Control Create Type File is it exist?
if (!empty($this->request->data['id_front_side']['name'])) {
$fileName = $this->request->data['id_front_side']['name']; //put the data into a var for easy use
$id_front_side = $fileName;
$extm = substr(strtolower(strrchr($fileName, '.')), 1); //get the extension
$arr_extm = array('jpg', 'jpeg', 'gif', 'png'); //set allowed extensions
if (in_array($extm, $arr_extm)) {
$uploadPath = WWW_ROOT . DS . 'images' . DS . 'organisations' . DS . $id . DS . 'media'. DS;
$uploadFile = $uploadPath . $fileName;
if(!is_dir($uploadPath)) {
mkdir($uploadPath);
}
$auto = $this->generateRandomString(6);
//$files_image='product_'.$auto.'_'.$image_id.'_'.$images['name'];
$files_image = 'product_' . $auto . '_' . $id . '_' . $fileName;
$test = $uploadPath. $files_image;
// move_uploaded_file($this->request->data['id_front_side']['tmp_name'], $uploadFile);
move_uploaded_file($this->request->data['id_front_side']['tmp_name'], $test );
$this->request->data['id_front_side'] = $test;
$source_image = $test;
$destination_thumb_path = $uploadPath. DS . 'small' . DS . $files_image;
$destination_thumb_path1 = $uploadPath . DS . 'large' . DS . $files_image;
// $directory = new Folder();
$this->imageresize2($source_image, $destination_thumb_path, 270, 320, 1);
$this->imageresize2($source_image, $destination_thumb_path1, 500, 500, 1);
}
}
////////////////////////////////////////
public function imageresize2($src, $dst, $width, $height, $crop = 0)
{
if (!list($w, $h) = getimagesize($src)) return "Unsupported picture type!";
$type = strtolower(substr(strrchr($src, "."), 1));
if ($type == 'jpeg') $type = 'jpg';
switch ($type) {
case 'bmp':
$img = imagecreatefromwbmp($src);
break;
case 'gif':
$img = imagecreatefromgif($src);
break;
case 'jpg':
$img = imagecreatefromjpeg($src);
break;
case 'png':
$img = imagecreatefrompng($src);
break;
default:
return "Unsupported picture type!";
}
// resize
if ($crop) {
if ($w < $width or $h < $height) return false;
$ratio = max($width / $w, $height / $h);
$h = $height / $ratio;
$x = ($w - $width / $ratio) / 2;
$w = $width / $ratio;
} else {
if ($w < $width and $h < $height) return false;
$ratio = min($width / $w, $height / $h);
$width = $w * $ratio;
$height = $h * $ratio;
$x = 0;
}
$new = imagecreatetruecolor($width, $height);
// preserve transparency
if ($type == "gif" or $type == "png") {
imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
imagealphablending($new, false);
imagesavealpha($new, true);
}
imagecopyresampled($new, $img, 0, 0, $x, 0, $width, $height, $w, $h);
switch ($type) {
case 'bmp':
imagewbmp($new, $dst);
break;
case 'gif':
imagegif($new, $dst);
break;
case 'jpg':
imagejpeg($new, $dst);
break;
case 'png':
imagepng($new, $dst);
break;
}
return true;
}
public function generateRandomString($length = null)
{
return substr(str_shuffle(str_repeat($x = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
}
}
Thank you!
0
0
4
10
variable in cakephp3 counting summming up
$payment_tbl = TableRegistry:: getTableLocator()->get(“MembershipPayment”);
$payment = $payment_tbl->find();
$payment->select( ['totalpmnt' => $payment->func()->sum('yoursumfield here') ]);
$this->set('payment',$payment->totalpmnt);
then in view
echo $payment;
should contain the sum.
or, if you do
$this->set('payment', $payment);
you need to do in your view:
echo $payment->totalpmnt;
or
<?= $payment->totalpmnt ?>
Thank you!
10
0
Are there any code examples left?
New code examples in category Javascript
-
Javascript 2023-04-21 22:52:36
-
Javascript 2022-03-27 22:25:20 javascript download string as file
-
Javascript 2022-03-27 21:40:22 sort numbers in array javascript
-
Javascript 2022-03-27 21:20:04 compare two arrays and return the difference javascript
-
Javascript 2022-03-27 21:15:02 javascript regex french phone number
-
Javascript 2022-03-27 21:05:03 cypress custom error message
-
Javascript 2022-03-27 21:00:05 create element javascript with id
-
Javascript 2022-03-27 20:40:57 feather icons react
-
Javascript 2022-03-27 20:20:01 how to make graphql request in axios
-
Javascript 2022-03-27 20:15:07 bootstrap validator password and confirm password