grepper add code answer

Solutions on MaxInterview for grepper add code answer by the best coders in the world

showing results for - "grepper add code answer"
Ella
04 Nov 2020
1ng if cart icon got items only show numbers
2
3<ion-icon slot="end" (click)="openCart()" #cart class="cart_icons" name="cart-outline"></ion-icon>
4        <div *ngIf="(cartItemCount | async) >= 1 ">
5          <span>{{ cartItemCount | async }}</span>
6        </div>
7      </div>
Silvia
29 Sep 2019
1Cakephp 3 image upload with thumbnail and resize image
2
3check Tables if its AllowEmptyString or AllowEmptyFile
4
5check Form Control Create Type File is it exist?
6
7
8if (!empty($this->request->data['id_front_side']['name'])) {
9                $fileName = $this->request->data['id_front_side']['name']; //put the data into a var for easy use
10
11                $id_front_side = $fileName;
12
13                $extm = substr(strtolower(strrchr($fileName, '.')), 1); //get the extension
14                $arr_extm = array('jpg', 'jpeg', 'gif', 'png'); //set allowed extensions
15                if (in_array($extm, $arr_extm)) {
16                    $uploadPath = WWW_ROOT . DS . 'images' . DS . 'organisations' . DS . $id . DS . 'media'. DS;
17
18                    $uploadFile = $uploadPath . $fileName;
19                    if(!is_dir($uploadPath)) {
20                    mkdir($uploadPath);
21                    }
22
23                    $auto = $this->generateRandomString(6);
24                    //$files_image='product_'.$auto.'_'.$image_id.'_'.$images['name'];
25                    $files_image = 'product_' . $auto . '_' . $id . '_' . $fileName;
26
27
28                    $test = $uploadPath. $files_image;
29
30                    // move_uploaded_file($this->request->data['id_front_side']['tmp_name'], $uploadFile);
31                    move_uploaded_file($this->request->data['id_front_side']['tmp_name'], $test );
32                    $this->request->data['id_front_side'] = $test;
33
34                    $source_image =  $test;
35                    $destination_thumb_path = $uploadPath. DS . 'small' . DS . $files_image;
36                    $destination_thumb_path1 = $uploadPath . DS . 'large' . DS . $files_image;
37                    // $directory = new Folder();
38                    $this->imageresize2($source_image, $destination_thumb_path, 270, 320, 1);
39                    $this->imageresize2($source_image, $destination_thumb_path1, 500, 500, 1);
40                }
41            }
42            //////////////////////////////////////// 
43
44
45
46    public function imageresize2($src, $dst, $width, $height, $crop = 0)
47    {
48
49        if (!list($w, $h) = getimagesize($src)) return "Unsupported picture type!";
50
51        $type = strtolower(substr(strrchr($src, "."), 1));
52        if ($type == 'jpeg') $type = 'jpg';
53        switch ($type) {
54            case 'bmp':
55                $img = imagecreatefromwbmp($src);
56                break;
57            case 'gif':
58                $img = imagecreatefromgif($src);
59                break;
60            case 'jpg':
61                $img = imagecreatefromjpeg($src);
62                break;
63            case 'png':
64                $img = imagecreatefrompng($src);
65                break;
66            default:
67                return "Unsupported picture type!";
68        }
69
70        // resize
71        if ($crop) {
72            if ($w < $width or $h < $height) return false;
73            $ratio = max($width / $w, $height / $h);
74            $h = $height / $ratio;
75            $x = ($w - $width / $ratio) / 2;
76            $w = $width / $ratio;
77        } else {
78            if ($w < $width and $h < $height) return false;
79            $ratio = min($width / $w, $height / $h);
80            $width = $w * $ratio;
81            $height = $h * $ratio;
82            $x = 0;
83        }
84
85        $new = imagecreatetruecolor($width, $height);
86
87        // preserve transparency
88        if ($type == "gif" or $type == "png") {
89            imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
90            imagealphablending($new, false);
91            imagesavealpha($new, true);
92        }
93
94        imagecopyresampled($new, $img, 0, 0, $x, 0, $width, $height, $w, $h);
95
96        switch ($type) {
97            case 'bmp':
98                imagewbmp($new, $dst);
99                break;
100            case 'gif':
101                imagegif($new, $dst);
102                break;
103            case 'jpg':
104                imagejpeg($new, $dst);
105                break;
106            case 'png':
107                imagepng($new, $dst);
108                break;
109        }
110        return true;
111    }
112
113
114    
115    public function generateRandomString($length = null)
116    {
117        return substr(str_shuffle(str_repeat($x = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
118    }
119}
120
Amelia
05 Apr 2016
1solve the error issue 
2
3$ cordova plugin add cordova-plugin-androidx
4$ cordova plugin add cordova-plugin-androidx-adapter
5
6
7npm install jetifier --save
8npx jetify
9npx cap sync
Amelie
09 Feb 2020
1cakephp3 
2
3
4find($id) takes an id and returns a single model. If no matching model exist, it returns null.
5
6findOrFail($id) takes an id and returns a single model. If no matching model exist, it throws an error1.
7
8first() returns the first record found in the database. If no matching model exist, it returns null.
9
10firstOrFail() returns the first record found in the database. If no matching model exist, it throws an error1.
11
12get() returns a collection of models matching the query.
13
14pluck($column) returns a collection of just the values in the given column. In previous versions of Laravel this method was called lists.
15
16toArray() converts the model/collection into a simple PHP array.
Eve
03 Aug 2017
1 to connect relationships and display foreign has links. need to identify 
2 *ngIf this.bankAccounts.id == this.company.id similar to Ionic
3 
4 
5 public function index($id = null)
6    {
7        $this->paginate = [
8            'contain' => ['Organizations','Banks', 'Companies'],
9        ];
10        $bankAccounts = $this->BankAccounts->find();
11        if($id){
12            $bankAccounts->where(['organization_id' => $id]);
13            $organization = $this->BankAccounts->Organizations->findById($id)->first();
14            $this->set('organization', $organization);
15            
16        }
17        if ($id){
18
19            $bankAccounts->where(['company_id' => $id]);
20            $company = $this->BankAccounts->Companies->findById($id)->first();
21            $this->set('company', $company);
22
23        }
24        $bankAccounts = $this->paginate($this->BankAccounts);
25        $this->set(compact('bankAccounts'));
26    }
27  
28  
29  
30  
31  public function edit($id = null)
32    {
33        $bankAccount = $this->BankAccounts->get($id, [
34            'contain' => [],
35        ]);
36        $bankAccount = $this->BankAccounts->find();
37        if($id){
38            $bankAccount->where(['organization_id' => $id]);
39            $organization = $this->BankAccounts->Organizations->findById($id)->first();
40            $this->set('organization', $organization);
41            
42        }
43        if ($id){
44
45            $bankAccount->where(['company_id' => $id]);
46            $company = $this->BankAccounts->Companies->findById($id)->first();
47            $this->set('company', $company);
48
49        }
50        
51        if ($this->request->is(['patch', 'post', 'put'])) {
52            $bankAccount = $this->BankAccounts->patchEntity($bankAccount, $this->request->getData());
53            if ($this->BankAccounts->save($bankAccount)) {
54                $this->Flash->success(__('The bank account has been saved.'));
55
56                return $this->redirect(['action' => 'index']);
57            }
58            $this->Flash->error(__('The bank account could not be saved. Please, try again.'));
59        }
60        $organizations = $this->BankAccounts->Organizations->find('list', ['limit' => 200]);
61        $companies = $this->BankAccounts->Companies->find('list', ['limit' => 200]);
62        $banks = $this->BankAccounts->Banks->find('list', ['limit' => 200]);
63        $this->set(compact('bankAccount', 'organizations', 'companies', 'banks'));
64    }
Emely
17 Mar 2018
1variable in cakephp3 counting summming up
2
3$payment_tbl = TableRegistry:: getTableLocator()->get(“MembershipPayment”);
4
5$payment = $payment_tbl->find();
6$payment->select( ['totalpmnt' => $payment->func()->sum('yoursumfield here') ]);
7
8$this->set('payment',$payment->totalpmnt);
9then in view
10echo $payment;
11should contain the sum.
12
13or, if you do
14$this->set('payment', $payment);
15you need to do in your view:
16echo $payment->totalpmnt;
17or
18<?= $payment->totalpmnt ?>
Francesca
01 Oct 2020
1ngFor filter products based on categories
2
3
4*ngFor="let item of filteredvalues"    at html
5
6
7at TS
8
9//filter products by category id 
10    this.apiService.getList().subscribe(response => {
11      this.productsData = response;
12      this.filteredvalues = this.productsData.filter(res => 
13        res.category_id == this.id);
14      console.log('get all products', this.filteredvalues);
15    });
16
17
18