AhmedNaser

AhmedNaser

Member Since 9 Months Ago

Experience Points
11,110
Total
Experience

3,890 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
105
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 3
11,110 XP
Apr
01
4 days ago
Activity icon

Replied to Laravel Validations Doesn't Accept Some Emails Formats

You cannot have an email address @ a top level domain, I don't understand what do u mean?

Activity icon

Started a new Conversation Laravel Validations Doesn't Accept Some Emails Formats

Hi there I did use laravel's validation for validating the email format, but some formats didn't pass from the validation considered as invalid emails however it seems good and valid emails,

 public function rules()
    {
        return [
            'email'  => ['required', 'email:rfc,dns,filter', 'unique:users,email,NULL,id,deleted_at,NULL'],
        ];
    }

this is the email validations rule I have used, if anyone have any idea how to tackle this issue, it would be appreciated.

Note: the invalid emails format are: [email protected], [email protected], [email protected]

Activity icon

Replied to Execute If The Condition Is False

ummm I think this is because php converts Boolean into 0 for false values and 1 for true values, if you want to strict this try something like this

public function check_vendor_vat()
    {
        if ($this->vendor_company->vat_no != null) {
            return true;
        } else {
            return false;
        }
    }


if($check->vendor_vat() === false)
{
 //Execute Code
}


Activity icon

Awarded Best Reply on At Least One Value Selected With Validations

Hi there I made this hooks for the validation if anyone has such a case like this

 /**
     * Configure the validator instance.
     *
     * @param  Validator  $validator
     * @return void
     */
    public function withValidator($validator)
    {
        $selected = [];
        $validator->after(function ($validator) use ($selected) {
            if (request()->has('permissions')) {
                foreach (request('permissions') as $permission) {
                    foreach ($permission as $item) {
                        array_push($selected, $item['selected']);
                    }
                }
                if (!in_array(true, $selected)) {
                    $validator->errors()->add('permissions', 'Permission must be select, one action at least.');
                }
            }
        });
    }

Activity icon

Replied to At Least One Value Selected With Validations

Hi there I made this hooks for the validation if anyone has such a case like this

 /**
     * Configure the validator instance.
     *
     * @param  Validator  $validator
     * @return void
     */
    public function withValidator($validator)
    {
        $selected = [];
        $validator->after(function ($validator) use ($selected) {
            if (request()->has('permissions')) {
                foreach (request('permissions') as $permission) {
                    foreach ($permission as $item) {
                        array_push($selected, $item['selected']);
                    }
                }
                if (!in_array(true, $selected)) {
                    $validator->errors()->add('permissions', 'Permission must be select, one action at least.');
                }
            }
        });
    }

Mar
26
1 week ago
Activity icon

Started a new Conversation At Least One Value Selected With Validations

Hi there I have an array of Boolean values I want to make sure that the array has at least 1 true value

  public function rules()
    {
        return [
            'name'                     => ['required', 'string', 'min:2', 'max:100', 'unique:roles,name'],
            'permissions'              => ['required', 'array'],
            'permissions.*'            => ['required', 'array'],
            'permissions.*.*'          => ['required', 'array'],
            'permissions.*.*.name'     => ['required', 'alpha_dash'],
            'permissions.*.*.selected' => ['required', 'boolean'],
        ];
    }
Mar
19
2 weeks ago
Activity icon

Replied to Laravel Select Or CAST As UNSIGNED In Database

I found mysql CAST function but it did not make difference

Activity icon

Started a new Conversation Laravel Select Or CAST As UNSIGNED In Database

Hi there I have a situation that I have to store a serial number in the database as a string because in some too rare cases this serial could have some letters, and the problem is whenever I sort by this column the sorting is not correct because it deals with this field as a string but I need to select these columns as integers to be able to sort correctly.

serial==>1231551238451313 but as a string not number
Activity icon

Replied to Filter Data By Keyword Separated Into Two Columns In DB

Thank you sir you made my day <3

Activity icon

Started a new Conversation Filter Data By Keyword Separated Into Two Columns In DB

I have 2 fields in the DB 1 for country code and 1 for phone number, the user can search in the front end by the whole phone number e.g +2010304050, so I want to take this value and filter the data from database by this value, but I have 2 separate columns in the DB country_code, phone_number.

 public function keyword(string $keyword)
    {
        $countryCode = str_split($keyword, 2)[0];
        return $this->where(function ($query) use ($keyword, $countryCode) {
            $query->where("devices.imei", "LIKE", "%{$keyword}%")
                ->orWhere("devices.sim_number", "LIKE", "%{$keyword}%")
                ->orWhere("devices.country_code", "LIKE", "%{$countryCode}%")
                ->orWhere("devices.sim_serial", "LIKE", "%{$keyword}%");
        });
    }
Mar
16
2 weeks ago
Activity icon

Replied to Laravel Unique Validation Rule

@tray2 @sinnbeck Thank you guys for replying me both works fine for me I appreciate

Mar
15
3 weeks ago
Activity icon

Replied to Laravel Unique Validation Rule

I checked the second approach but I didn't understand what you mean when you're using where function? it could be better if you submit some explanation

Activity icon

Started a new Conversation Laravel Unique Validation Rule

Hi there I have two fields one for country code and one for phone number I want to make validation to make the both fields unique together.


public function rules()
    {
        return [
            'countryCode'  => ['required', 'between:2,4'],
            'phone'    => ['required', 'digits:9', 'unique:devices,phone],
        ];
    }

I have two fields in the database one for country code, one for the phone number

I need the validation to check if the combination (country code with phone) is unique e.g +200102030 not the phone number only 0102030

Activity icon

Started a new Conversation Larave Unique Validation Rule

Hi there I have two fields one for country code and one for phone number I want to make validation to make the both fields unique together.


public function rules()
    {
        return [
            'countryCode'  => ['required', 'between:2,4'],
            'phone'    => ['required', 'digits:9', 'unique:devices,phone],
        ];
    }

I have two fields in the database one for country code, one for the phone number

I need the validation to check if the combination (country code with phone) is unique e.g +200102030 not the phone number only 0102030

Mar
09
3 weeks ago
Activity icon

Started a new Conversation Laravel Throttle

I want to limit the users login on my system and I used the throttle middleware but the max attempts counting wrongly.

Route::post('login', 'Auth\[email protected]')->middleware('throttle:3,30', 'interface');

what I want to do is to block or throttle the user after 3 times of login failure and the decay minutes 30 min

Mar
04
1 month ago
Activity icon

Replied to Laravel Headers Validations

I made the middleware now and it works fine but I am facing problem with handling my new custom exception, the exception thrown as an error I want to handle it to a readable message for the user.

the thrown exception [2020-03-04 14:32:25] local.ERROR: {"Error":"You must send the 'User-Agent' key in the request header either mobile or portal"} {"exception":"[object] (Exception(code: 0): {"Error":"You must send the 'User-Agent' key in the request header either mobile or portal"} at /var/www/html/test-backend/app/test/User/Http/Middleware/ValidateUserAgentHeader.php:25) [stacktrace]

Mar
03
1 month ago
Activity icon

Replied to Laravel Headers Validations

Thanks I will try it, thanks for the quick response dude

Activity icon

Started a new Conversation Laravel Headers Validations

Hi there I have a case with my API, the API is consumed by Mobile, Web Portal and based on the "User-Agent" key in the request headers I asked the user to enter a different data for my API, so I need to make sure that the request header have the key "User-Agent" with either value web portal or mobile, how can I make such a thing like this in laravel validations?