ahmedmsvb

ahmedmsvb

Member Since 1 Year Ago

Experience Points 30,310
Experience
Level
Lessons Completed 274
Lessons
Completed
Best Reply Awards 5
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

05 Jun
6 months ago

ahmedmsvb started a new conversation Laravel Passport - Two Questions

Hello,

I'm developing a mobile application that connects to a Laravel back-end via API. I use Passport for authentication to all my API routes.

The questions are:

  1. Will calling the refresh token everytime the app is launched considered an overhead?
  2. Using migrate:refresh in development/test environment will destroy the client id & client secret, is there a way to keep my client secret during the migrate:refresh?

Thanks,

13 Apr
8 months ago

ahmedmsvb left a reply on How To Get All Comments Of All Tasks Of All Sprints

HI,

You need nested eager loading, this is an example from Laravel documentation:

To eager load nested relationships, you may use "dot" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts in one Eloquent statement: $books = App\Book::with('author.contacts')->get();

so, you need to modify:

$sprints = Project::first()->sprints()->with('tasks')->get();

to

$sprints = Project::first()->sprints()->with('tasks.comments')->get();
02 Apr
8 months ago

ahmedmsvb left a reply on Advanced Validation

Have a look on required_if, required_with, ... @https://laravel.com/docs/5.6/validation

04 Mar
9 months ago

ahmedmsvb left a reply on Array To String Conversion Error

+1 for making some effort while posting a new question

DB::select('select curdate() ');

According to laravel docs

The select method will always return an array of results. Each result within the array will be a PHP StdClass object, allowing you to access the values of the results.

Use:

DB::select('select curdate() as cur_date')[0]->cur_date;

ahmedmsvb left a reply on Can Anyone Spot My Error (Where Clauses Not Firing)

                ->with('todos.todoitems')->orderBy('weight')
                ->with('todos.todoitems.user')

are loaded against the parent model "Todo_category".

I'm expecting you need to load them inside the "->with(['todos' => function ..." part

e.x.:
```php
                ->with(['todos' => function($query1) use ($runid,$yearid){
                    $query1->where('run_id', $runid)->where('year_id',$yearid)->with('todoitems');
                }])
16 Feb
10 months ago

ahmedmsvb left a reply on Best Way To Set Up Confirmation For 1 Date Out Of Multiple Dates

May be in the "bookings" table you have a "confirmed_booking_date_id" column. Another option is to add a "confirmed_flg" column to the "booking_dates" table.

13 Jan
11 months ago

ahmedmsvb left a reply on Syntax Error Or Access Violation: 1071 Specified Key Was Too Long

Hi,

You might need to check this: https://laravel.com/docs/5.5/migrations#creating-indexes [section# Index Lengths & MySQL / MariaDB]

28 Dec
11 months ago

ahmedmsvb left a reply on Laravel 5.4 Relation Between Models Not Fetching Correct Data

Change this:

    public function brand(){
        return $this->hasOne('App\Brands', 'brandID');
     }

to:

    public function brand(){
        return $this->belongsTo('App\Brands', 'brandID');
     }
23 Dec
11 months ago

ahmedmsvb started a new conversation [Opinion] Unused Controller Methods

Hi,

I'm working on a mid-size project. At the beginning, I was always generating resource controllers (even if I'm not going to use all the methods)

Now, my controllers contain 50% working code and 50% idle empty methods generated from "make controller -r" command.

What is the best practice here:

  1. delete these methods and re-create them as necessary?
  2. or, just keep them just in case I need them later?

(I tend to follow approach #1)

Thanks,

30 Oct
1 year ago

ahmedmsvb left a reply on Switching From Development To Production Questions

That's what the .env file is used for.

As you stated, use one .env file for local and the other for production.

Regarding the "env('APP_ENV', 'production')," code, it performs the following: 1- Looks for a variable named "APP_ENV" in the .env file. 1.a. If found => return its value. 1.b Otherwise, return the default 'hardcoded' value ('production' in our case).

Usually we add the .env file to our .gitignore. This ensures not overwriting the production or sharing our settings/passwords in different environments.

25 Oct
1 year ago

ahmedmsvb left a reply on Protecting A DELETE Route For The Already Logged-in Users

But doesn't this break the single responsibility rule? (delete method will be responsible for two actions)

ahmedmsvb left a reply on Protecting A DELETE Route For The Already Logged-in Users

First of all, thanks!

This will solve my problem the easy way (not sure if I' over-complicating things!)

But what if I need to implement something like the "confirm your password" page displayed by yahoo when editing important profile info?

The flow that I have to implement is: 1- User clicks delete => 2- display the "enter password" page => 3- user enters password and click submit => 4- call the delete action on my model (somehow)

I have several Model objects with their respective "delete" actions, so step #4 needs to be dynamic.

ahmedmsvb started a new conversation Protecting A DELETE Route For The Already Logged-in Users

I created an application that enforces the users to keep logged-in always (all routes have "auth" middleware)

During specific actions from the user (delete a record for example), I need the user to re-enter his password for verification.

I created a middleware called ConfirmPassword checking for a session-flashed variable (not the best option); if the variable is not set:

  • user must confirm his password
  • set the flash variable => true

The problem happens after I validate the user's password, where the old URL is removed from my session. I tried saving the url as well to the session, but this changed the method from DELETE to GET

Any ideas/help?