Skip to content

Instantly share code, notes, and snippets.

View ovicko's full-sized avatar
🎯
Focusing

AMWOLLO VICTOR ovicko

🎯
Focusing
View GitHub Profile
@ovicko
ovicko / Records.php
Last active May 19, 2021 11:09
Add sendMail method to ActiveRecord class.
<?php
class Records extends \yii\db\ActiveRecord
{
 const EVENT_SEND_EMAIL_UPDATE = 'send-email-to-users';
 public function init() {
$this->on(self::EVENT_SEND_EMAIL_UPDATE, [$this, 'sendMail']);
//use this if you want to add custom data to your events
@ovicko
ovicko / RecordsController.php
Last active May 19, 2021 10:06
Trigger the event after bulk upload
<?php
public function actionBulk() {
$model = new Records();
//import excel sheet with 5k records
if ($model->customImport()) {
//trigger the send email event 
$model->trigger(Records::EVENT_SEND_EMAIL_UPDATE);
}
}
customer: {
"firstname":"firstname",
"lastname":"lastname",
"email":"email",
"phone":"phone",
},
seller_id:17,
delivery_type:"sendy default"
delivery_cost: 34.90,
@ovicko
ovicko / mpesa_stk.php
Last active June 23, 2025 10:37
MPESA test
public function actionPay() {
$tillNumber = 174379;
$storeNumber = 174379;
$customerPhoneNumber = 2547xxxx;
$timeStamp = date("Ymdhis");
$passKey = "bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919";
$password = base64_encode($storeNumber . $passKey . $timeStamp);
// $token = $this->getToken();
$token ="GGpPaGYBCs3VLl7W2Bl0KzQ3h5MP";