Skip to content

Instantly share code, notes, and snippets.

View muarachmann's full-sized avatar
Automating the boring processes!

Mua Rachmann muarachmann

Automating the boring processes!
View GitHub Profile
@muarachmann
muarachmann / gist:edc30f43e067ef6007a1c162c6f0941b
Last active February 25, 2022 09:44
network-operators-query-scope-laravel
Before diviing into the hassle of creating this post, I had one big concern dealing with tons of telephone data (numbers), I had to filter these based on Cameroonian network operators (MTN, ORANGE, CAMTEL & NEXTTEL). While this was an easy thing to do with the `'LIKE'` functionality of mysql. However, I didn't like my solution as shown below.
```php
// scope for network operators
public function scopeNetworkOperator($query, string $operator = null)
{
switch ($operator) {
case "mtn":
return $query->where('phone', 'like', '67%')
->orWhere('phone', 'like', '650%')

Keybase proof

I hereby claim:

  • I am muarachmann on github.
  • I am muarachmann (https://keybase.io/muarachmann) on keybase.
  • I have a public key ASCCxmtCXcj6R1edR6Az30FucETliNBQHYNvVBQjVh9n5go

To claim this, I am signing this object: