This file contains hidden or 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
| func getNetwork(phone string) string { | |
| networks := make(map[string][]string) | |
| networks["mtn"] = []string{"0803", "0806", "0814", "0810", "0813", "0814", "0816", "0703", "0706", "0903", "0906"} | |
| networks["9mobile"] = []string{"0809", "0817", "0818", "0908", "0909"} | |
| networks["airtel"] = []string{"0802", "0808", "0812", "0708", "0701", "0902", "0901", "0907"} | |
| networks["glo"] = []string{"0805", "0807", "0811", "0815", "0705", "0905"} | |
| for k, prefixes := range networks { | |
| for _, p := range prefixes { | |
| if phone[:4] == p { |
This file contains hidden or 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
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| func main() { | |
| dates := []string{"2021-01-20", "2021-03-05", "2021-02-25", "2021-03-04"} | |
| latest, _ := time.Parse("2006-01-02", dates[0]) | |
| for _, date := range dates { | |
| dateValue, _ := time.Parse("2006-01-02", date) // convert 'String' to 'Time' data type |
This file contains hidden or 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((int)$query == 0){ | |
| $states = #fetch states from the session | |
| if(count($states) > 1){ | |
| $count = count($states); | |
| $prev = $count - 2; | |
| $prev_state = $states[$prev]; | |
| if($prev_state != '0'){ | |
| //go to previous key - /menus/{$prev_state} | |
| //show sub-menus | |
| //contatenate '0. Previous Menu' |
This file contains hidden or 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
| function validateDateTime($value){ | |
| $array = explode(" ", $value); | |
| if(count($array) != 2){ | |
| return 'Kindly separate your date and time in this format for example, 11/12/2020 2.20pm'; | |
| } | |
| //validate date | |
| $date = $array[0]; | |
| if(preg_match("/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/", $date) === 0) { | |
| return 'Your date '.$date.' is in an invalid format'; |
This file contains hidden or 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
| For this to work, you have to include CDNs for JQuery and FabricJS. | |
| ***The View**** | |
| ===The blade file=== | |
| The CSS | |
| <style> | |
| #sheet-container { | |
| width: 250px; | |
| height: 100px; | |
| border: 1px solid black; |
This file contains hidden or 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
| For those with Javascript phobia like me, this is how to dynamically load contents into a input textfield using a select box. This gist uses AJAX and JQuery. | |
| The view | |
| <div class="form-group col-sm-8"> | |
| <label class="">Select Bank Account</label> | |
| <select class="form-control bank_account" name="bank_account"> | |
| <option value="">--Please select--</option> | |
| @foreach($banks as $bank) | |
| <option value="{{$bank->id}}">{{$bank->name}}[{{$bank->account_number}}]</option> |
This file contains hidden or 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
| For those with Javascript phobia like me, this is how to dynamically load contents into a select box using another select box. This gist uses AJAX and JQuery. | |
| The view | |
| <div class="form-group col-sm-12"> | |
| <label class=""> Category</label> | |
| <select name="category" class="form-control category" id="input-category"> | |
| <option value=""> --- Please Select ---</option> | |
| @foreach(session('categories') as $category) | |
| <option value="{{$category->id}}">{{$category->name}}</option> |
This file contains hidden or 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
| while($result = mysqli_fetch_assoc($res)){ | |
| $array[] = array( | |
| "title"=> $result['title'], | |
| "image_url"=> $result['img_url'], | |
| "subtitle"=> "See all our colors", | |
| "buttons"=>[ | |
| [ | |
| "type"=>"postback", | |
| "title"=>$result['title'], |