Skip to content

Instantly share code, notes, and snippets.

View Escarter's full-sized avatar
🏠
Working from home

Mbutuh Escarter Brieno Escarter

🏠
Working from home
  • Douala, Cameroon
View GitHub Profile
@Escarter
Escarter / custom-countdown-for-comming-soon-page-using-js.markdown
Created March 23, 2018 12:20
Custom Countdown For Comming Soon Page Using JS
@Escarter
Escarter / Laravel_Homestead_Oracle after.sh automation of OCI8 Setup
Created April 24, 2019 07:33 — forked from XenitXTD/Laravel_Homestead_Oracle after.sh automation of OCI8 Setup
This was an automation configured on the laravel homestead vagrant VM to automate the setup and configuration of the Oracle OCI8 php .so file and installation of the oracle client so that you are able to connect to an oracle database using the Yajra oracle package for laravel, using the homestead after.sh file to setup the required installers et…
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
apt-get update
# if not installed install it
apt-get install unzip
@Escarter
Escarter / blog.md
Created June 17, 2019 11:34 — forked from alesf/blog.md
Laravel - Eloquent: Cascading delete, forceDelete and restore

If you want to delete a model with related models you can use Laravel model events. There is also a special case if your models cascade.

Lets say you have Folder and File Eloquent models that are related and use SoftDeletes trait and when you delete a folder you also want to delete files in folder and all subfolders with files.

In the boot method or Folder model you catch delete and restore events (actually deleting and restoring events that trigger before restoring or deleting happens). You can delete/restore all files in folder you're deleting/restoring with $folder->files()->delete(); and $folder->files()->withTrashed()->restore();.

Folders on the other hand cascade (folder in a folder in a folder) and because events do not trigger if you don't pull the models (->get() method), the model events won't trigger for subfolders. That's why you need to pull the folders and iterate trough them (->each() method) and delete/restore them.

You could use database CASCADE feature but that does

@Escarter
Escarter / laravel-s3-uploader.php
Created March 31, 2020 08:52 — forked from bosz/laravel-s3-uploader.php
Optimize and upload a file to s3 bucket
use Illuminate\Support\Facades\Storage;
use Carbon\Carbon;
function hlp_file_upload($fileObj, $s3Path, $newDimension=null, $fname=null, $watermark = true)
{
$basePath = storage_path('app/uploads');
$ext = $fileObj->getClientOriginalExtension();
$ext = empty($ext) ? 'jpg' : $ext;
$oldFileName = $fname ? $fname : md5(uniqid(empty($_SERVER['SERVER_ADDR']) ? '' : $_SERVER['SERVER_ADDR'], true)) . '.' . $ext ;
@Escarter
Escarter / resources-mtn-momo-openapi-integration-webinar.md
Last active May 8, 2020 17:24
Resources for the webinar on MTN MoMo OpenAPI integration [01/05/2020]

MTN MoMo OpenAPI Integration

Thanks again for your participation during this session. below are some resources that might help.

Flow

  1. MTN MoMo OpenAPI Overview
    • Registration/Login
    • Available APIs → Registration to APIs
    • Subscription API keys
    • Documentation
  2. Sandbox