Nael.Saeed

Nael.Saeed

Programmer at Hsoub

Member Since 3 Years Ago

Experience Points
9,120
Total
Experience

880 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
67
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 2
9,120 XP
Dec
13
2 months ago
Activity icon

Replied to Laravel Work With Pivot Table With 3 Or More Columns

@amepro you need to replace customer_id_value and user_id with the integer values like for example 1 and 5

Dec
12
2 months ago
Activity icon

Replied to Laravel Work With Pivot Table With 3 Or More Columns

I do not know if I understand what you want well enough. You could try this


$validatedData = $request->validate([
        'work_type'=>'required',
        'dead_line'=>'required',
        'finished'=>'required',
        'information'=>'required',
]);

$newWork = new Work;
$newWork->fill($validatedData);
$newWork->save();

$newWork->users()->attach('user_id', [
    //you can pass any other pivot filed value you want in here
    'customer_id' => 'customer_id_value',
]);

Activity icon

Awarded Best Reply on URL Encoding

Well this is the best way I found so far for doing this, which is using the following packages to parse the URL and break it to components, then encode each component in the right way depending on the component type. At the end we join encoded components together to form the encoded URL

public function (string $url)
{
    $encodedUri = null;

        //create new Leage/Uri/Uri instance
        $uri = Uri::createFromString($url);

        //break the URI into URI components
        $scheme = Scheme::createFromUri($uri);
        $userInfo = UserInfo::createFromUri($uri);
        $host = Host::createFromUri($uri);
        $port = Port::createFromUri($uri);
        $path = Path::createFromUri($uri);
        $query = Query::createFromUri($uri);
        $fargment = Fragment::createFromUri($uri);

        //create an array of encoded components converted into strings
        $components = [
            'scheme' => optional($scheme)->getContent(),
            'user' => optional($userInfo)->getUser(),
            'pass' => optional($userInfo)->getPass(),
            'host' => optional($host)->getContent(),
            'port' => optional($port)->toInt(),
            'path' => optional($path)->getContent(),
            'query' => optional($query)->getContent(),
            'fragment' => optional($fargment)->getContent()
        ];

        //create an encoded URI from the encoded components
        $encodedUri = Uri::createFromComponents($components);
    }

    //compose URI from the component and return it as one string
    return optional($encodedUri)->jsonSerialize();
}

This solution also deals with non english domain names where they are encoded the right way starting with "xn--*" like for example: موقع.com

Would be glade to hear any thoughts related to this solution. Thanks for all participants.

Activity icon

Replied to URL Encoding

Well this is the best way I found so far for doing this, which is using the following packages to parse the URL and break it to components, then encode each component in the right way depending on the component type. At the end we join encoded components together to form the encoded URL

public function (string $url)
{
    $encodedUri = null;

        //create new Leage/Uri/Uri instance
        $uri = Uri::createFromString($url);

        //break the URI into URI components
        $scheme = Scheme::createFromUri($uri);
        $userInfo = UserInfo::createFromUri($uri);
        $host = Host::createFromUri($uri);
        $port = Port::createFromUri($uri);
        $path = Path::createFromUri($uri);
        $query = Query::createFromUri($uri);
        $fargment = Fragment::createFromUri($uri);

        //create an array of encoded components converted into strings
        $components = [
            'scheme' => optional($scheme)->getContent(),
            'user' => optional($userInfo)->getUser(),
            'pass' => optional($userInfo)->getPass(),
            'host' => optional($host)->getContent(),
            'port' => optional($port)->toInt(),
            'path' => optional($path)->getContent(),
            'query' => optional($query)->getContent(),
            'fragment' => optional($fargment)->getContent()
        ];

        //create an encoded URI from the encoded components
        $encodedUri = Uri::createFromComponents($components);
    }

    //compose URI from the component and return it as one string
    return optional($encodedUri)->jsonSerialize();
}

This solution also deals with non english domain names where they are encoded the right way starting with "xn--*" like for example: موقع.com

Would be glade to hear any thoughts related to this solution. Thanks for all participants.

Dec
10
2 months ago
Activity icon

Replied to URL Encoding

No it did not. Could you please share the result you get of applying it to one of the examples we talked about earlier?

Dec
09
2 months ago
Activity icon

Replied to URL Encoding

@sinnbeck

chrome does not encode characters that might cause a problem like this. So chrome will keep the link as: https://www.techmeme.com/191209/p1#a191209p1

as I mentioned in my question above, this was the best solution I found till now but still is not as perfect as should be:

function encodeURI($url) {
    // http://php.net/manual/en/function.rawurlencode.php
    // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
    $unescaped = array(
        '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~',
        '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'
    );
    $reserved = array(
        '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':',
        '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$'
    );
    $score = array(
        '%23'=>'#'
    );
    return strtr(rawurlencode($url), array_merge($reserved,$unescaped,$score));

}
Activity icon

Replied to URL Encoding

@sinnbeck

This will encode this: https://www.techmeme.com/191209/p1#a191209p1

into this: https://www.techmeme.com/191209/p1%23a191209p1

which is a broken URL that will not work once user click on it

Activity icon

Replied to URL Encoding

@sinnbeck

Thanks for your reply,

This way does not get me what I want, I could have used urlencode() and urldecode() instead.

public funtion setUrlAttribute($url)
{
    $this->attributes['url'] = urlencode($value);
}

public funtion getUrlAttribute($url)
{
    return urldecode($value);
}

this way I will use URL not encoded in the frontend like when using in

<a href="http://example.com/لغة-عربية">a link with non English letters</a>

what I need is to save the URL to database in a good format that is encoded but works as expected when using encoded in the frontend inside the HTML code.

Activity icon

Replied to URL Encoding

@bugsysha thanks for your reply,

Well I do store URLs in database. I need URLs to be encoded especially for URLs that has Arabic and non English letters. Later on when I send these URLs to the frontend I do not do decoding because the write thing to do is to set it in href for example is encoded, but rawurlencode() encode everything in the URL that it does not work when a user clicks on it encoded.

For examaple : https://example.com/postid#2 https%3A%2F%2Fexample.com%2Fpostid%232

Activity icon

Started a new Conversation URL Encoding

Hi guys, I need a way to encode URL before saving it to database but in a way similar to how chrome browser does that where symbols like : / - _ # ... etc, is not encoded unlike rawurlencode() does. is there any package or function would do that ? I have made a lot of searches but found nothing.

There was this solution but still it is a one developer written function and looks like there is still characters that are not preserved but chrome does not encode. https://stackoverflow.com/questions/4929584/encodeuri-in-php

Nov
04
3 months ago
Activity icon

Awarded Best Reply on Querying From First Table Where Table1.column1 Has Table2.column2 As A Substring

I solved it by adding this scope function in the Url model related to urls table

/**
     * Scope a query to only include Urls that has no related banned domains
     *
     * @param  \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeHasNoBannedDomains($query)
    {
        return $query->whereRaw("not exists 
                (select * from \"domains\" 
                where \"urls\".\"url\" 
                    like CONCAT('%', \"domains\".\"domain\", '%') 
                                and \"domains\".\"banned\" = 1)");
    }
Activity icon

Replied to Querying From First Table Where Table1.column1 Has Table2.column2 As A Substring

I solved it by adding this scope function in the Url model related to urls table

/**
     * Scope a query to only include Urls that has no related banned domains
     *
     * @param  \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeHasNoBannedDomains($query)
    {
        return $query->whereRaw("not exists 
                (select * from \"domains\" 
                where \"urls\".\"url\" 
                    like CONCAT('%', \"domains\".\"domain\", '%') 
                                and \"domains\".\"banned\" = 1)");
    }
Nov
03
3 months ago
Activity icon

Started a new Conversation Querying From First Table Where Table1.column1 Has Table2.column2 As A Substring

Hi guys, I am stuck with this query,

I have 2 tables, table urls that has url column table domains that has domain and banned columns

I need to get urls where url column has at least one domain column as a substring and the value of banned column is true

Can not manage to accomplish that.

Any help would be appreciated.

Sep
09
5 months ago
Activity icon

Started a new Conversation Url Icon, Title, Description And Feeds Link Fetching

Hi quys, I have been stuck for a while trying to achieve this: I want that when one of my users add a link to his favorites in the website then I want to fetch icon, description, title, and any RSS feeds (rss + atom .. ) exist in that url and save them in my database.

I used to use SimplePie for locating and fetching feeds, but with SimplePie I could not split the work the way I want.

Any advice?