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
A-312 69370 points

                                     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-&gt;paginate = [
            'contain' =&gt; ['Organizations','Banks', 'Companies'],
        ];
        $bankAccounts = $this-&gt;BankAccounts-&gt;find();
        if($id){
            $bankAccounts-&gt;where(['organization_id' =&gt; $id]);
            $organization = $this-&gt;BankAccounts-&gt;Organizations-&gt;findById($id)-&gt;first();
            $this-&gt;set('organization', $organization);
            
        }
        if ($id){

            $bankAccounts-&gt;where(['company_id' =&gt; $id]);
            $company = $this-&gt;BankAccounts-&gt;Companies-&gt;findById($id)-&gt;first();
            $this-&gt;set('company', $company);

        }
        $bankAccounts = $this-&gt;paginate($this-&gt;BankAccounts);
        $this-&gt;set(compact('bankAccounts'));
    }
  
  
  
  
  public function edit($id = null)
    {
        $bankAccount = $this-&gt;BankAccounts-&gt;get($id, [
            'contain' =&gt; [],
        ]);
        $bankAccount = $this-&gt;BankAccounts-&gt;find();
        if($id){
            $bankAccount-&gt;where(['organization_id' =&gt; $id]);
            $organization = $this-&gt;BankAccounts-&gt;Organizations-&gt;findById($id)-&gt;first();
            $this-&gt;set('organization', $organization);
            
        }
        if ($id){

            $bankAccount-&gt;where(['company_id' =&gt; $id]);
            $company = $this-&gt;BankAccounts-&gt;Companies-&gt;findById($id)-&gt;first();
            $this-&gt;set('company', $company);

        }
        
        if ($this-&gt;request-&gt;is(['patch', 'post', 'put'])) {
            $bankAccount = $this-&gt;BankAccounts-&gt;patchEntity($bankAccount, $this-&gt;request-&gt;getData());
            if ($this-&gt;BankAccounts-&gt;save($bankAccount)) {
                $this-&gt;Flash-&gt;success(__('The bank account has been saved.'));

                return $this-&gt;redirect(['action' =&gt; 'index']);
            }
            $this-&gt;Flash-&gt;error(__('The bank account could not be saved. Please, try again.'));
        }
        $organizations = $this-&gt;BankAccounts-&gt;Organizations-&gt;find('list', ['limit' =&gt; 200]);
        $companies = $this-&gt;BankAccounts-&gt;Companies-&gt;find('list', ['limit' =&gt; 200]);
        $banks = $this-&gt;BankAccounts-&gt;Banks-&gt;find('list', ['limit' =&gt; 200]);
        $this-&gt;set(compact('bankAccount', 'organizations', 'companies', 'banks'));
    }

3.86 (7 Votes)
0
0
0
Awgiedawgie 440215 points

                                    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.

0
0
4
3
A-312 69370 points

                                    ngFor filter products based on categories


*ngFor=&quot;let item of filteredvalues&quot;    at html


at TS

//filter products by category id 
    this.apiService.getList().subscribe(response =&gt; {
      this.productsData = response;
      this.filteredvalues = this.productsData.filter(res =&gt; 
        res.category_id == this.id);
      console.log('get all products', this.filteredvalues);
    });


4 (3 Votes)
0
3.75
8
Awgiedawgie 440215 points

                                    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

3.75 (8 Votes)
0
0
0
Phoenix Logan 186120 points

                                    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-&gt;request-&gt;data['id_front_side']['name'])) {
                $fileName = $this-&gt;request-&gt;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-&gt;generateRandomString(6);
                    //$files_image='product_'.$auto.'_'.$image_id.'_'.$images['name'];
                    $files_image = 'product_' . $auto . '_' . $id . '_' . $fileName;


                    $test = $uploadPath. $files_image;

                    // move_uploaded_file($this-&gt;request-&gt;data['id_front_side']['tmp_name'], $uploadFile);
                    move_uploaded_file($this-&gt;request-&gt;data['id_front_side']['tmp_name'], $test );
                    $this-&gt;request-&gt;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-&gt;imageresize2($source_image, $destination_thumb_path, 270, 320, 1);
                    $this-&gt;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 &quot;Unsupported picture type!&quot;;

        $type = strtolower(substr(strrchr($src, &quot;.&quot;), 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 &quot;Unsupported picture type!&quot;;
        }

        // resize
        if ($crop) {
            if ($w &lt; $width or $h &lt; $height) return false;
            $ratio = max($width / $w, $height / $h);
            $h = $height / $ratio;
            $x = ($w - $width / $ratio) / 2;
            $w = $width / $ratio;
        } else {
            if ($w &lt; $width and $h &lt; $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 == &quot;gif&quot; or $type == &quot;png&quot;) {
            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);
    }
}

0
0
4
10
Awgiedawgie 440215 points

                                    variable in cakephp3 counting summming up

$payment_tbl = TableRegistry:: getTableLocator()-&gt;get(&ldquo;MembershipPayment&rdquo;);

$payment = $payment_tbl-&gt;find();
$payment-&gt;select( ['totalpmnt' =&gt; $payment-&gt;func()-&gt;sum('yoursumfield here') ]);

$this-&gt;set('payment',$payment-&gt;totalpmnt);
then in view
echo $payment;
should contain the sum.

or, if you do
$this-&gt;set('payment', $payment);
you need to do in your view:
echo $payment-&gt;totalpmnt;
or
&lt;?= $payment-&gt;totalpmnt ?&gt;

4 (10 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source