methods: {
hasCameraCapability() {
return !!(window.navigator.mediaDevices && window.navigator.getUserMedia)
},
requestCameraAccess(config = {video: true}) {
return window.navigator.getUserMedia(config)
},
This gist describes the processes of allowing us to access the Safaricom's M-Pesa API. At the end of the process
we will obtain all variable needed to start using their API. We will be using the Customer to Business (C2B) API.
This gist has been created as an Appendix to this article (part 1).
⚡ Start by accessing the M-Pesa Developer Portal and create a new account if you don't already have one. Click the build new app button to scaffold a new testing application.
$teams = App\Team::with([
'portfolios' => function ($query) use ($user) {
// Only include portfolios where...
$query->whereHas('wallets', function ($query) use ($user) {
// ...there are wallets...
$query->whereHas('transactions', function ($query) {
// ...with pending transactions...
$query->whereStatus('pending');
});
$teams = App\Team::whereHas('portfolios', function ($query) use ($user) {
// Only include teams with portfolios where...
$query->whereHas('wallets', function ($query) use ($user) {
// ...there are wallets...
$query->whereHas('transactions', function ($query) {
// ...with pending transactions...
$query->whereStatus('pending');
});
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validator::extend('encrypted_unique', function ($attribute, $value, $parameters, $validator) { | |
list ($table, $column, $ignore_id) = $parameters; // or hard-coded if fixed | |
$count = $validator->getPresenceVerifier()->getCount($table, $column, encrypt($value), $ignore_id); | |
return $count === 0; | |
}); | |
'identifier' => "encrypted_unique:table,column,$this_id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$transport = new Swift_SmtpTransport('SMTP-HOST-HERE', SMTP-PORT-HERE); | |
$transport->setUsername('SMTP-USERNAME-HERE'); | |
$transport->setPassword('SMTP-PASSWORD-HERE'); | |
// extra configurations here if needed | |
Then, we use the Swift_SmtpTransport to build our Swift_Mailer object. | |
$swift_mailer = new Swift_Mailer($transport); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html2canvas($("#canvas"), { | |
onrendered: function(canvas) { | |
var imgData = canvas.toDataURL( | |
'image/png'); | |
var doc = new jsPDF('p', 'mm'); | |
doc.addImage(imgData, 'PNG', 10, 10); | |
doc.save('sample-file.pdf'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (starts_with($uploadedFile->getClientMimeType(), 'image')) { | |
} |