ahmeddabak

ahmeddabak

Software developer at LASE PeCo

Member Since 4 Years Ago

Wesel

Experience Points
201,580
Total
Experience

3,420 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
1365
Lessons
Completed
Best Reply Awards
103
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 41
201,580 XP
Jul
05
4 days ago
Activity icon

Awarded Best Reply on How To Make Responsive

You are using the class pull-right on the anchor tag which cases the tag to float, try using

 <li class="ui-state-default my-2 ui-sortable-handle d-flex" data-id="{{ $detail['product_id'] }}" data-name="{{ $detail['product_name'] }}"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>{{ $detail['product_name'] }}   
            <a href="#" class="ml-auto remove_data">remove</a>
        </li>
Jul
01
1 week ago
Activity icon

Awarded Best Reply on HasOne Relationship Between Two Tables From Different Databases

I think it is possible.

  • create a new connection in config/database.php for the second database.
  • in the model override the default database connection by setting the connection property protected $connection = 'second_database_connection';
  • work with the relations like you would normally do
Jun
25
2 weeks ago
Activity icon

Awarded Best Reply on Resolving Class From Container Is Null In Queued Job

Such problems happens when the job is serialized and then deserialized before execution. If you are resolving the instance in the constructor, Try resolving the instance in the handle method instead.

Activity icon

Replied to Where Are You All From?

Any Syrians here?

Jun
24
2 weeks ago
Activity icon

Replied to Two Api Request

Since both apis works correctly when you call them separately, and you do not get an error but the browser keep spinning .

Try setting a timeout on the http client you are using in the Api class prevent the call from taking too long. but this won't solve your problem, maybe the api you are trying to call has a rate limit and only allows one call per minute or maybe the called data is too big that it takes a long time to download, try contacting their support.

Activity icon

Awarded Best Reply on Compile Css And Js

Yes, for each css or js file you are making a new request to the server, the server has to find the file and send a response. it is better if you bundle your assets in one file.

Activity icon

Replied to Two Api Request

What get returned when you call both, do you get null or an error

Activity icon

Replied to Dompdf Id Givving ???

Read the docs of the package, i gave you the link

Activity icon

Replied to How To Make Responsive

You are using the class pull-right on the anchor tag which cases the tag to float, try using

 <li class="ui-state-default my-2 ui-sortable-handle d-flex" data-id="{{ $detail['product_id'] }}" data-name="{{ $detail['product_name'] }}"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>{{ $detail['product_name'] }}   
            <a href="#" class="ml-auto remove_data">remove</a>
        </li>
Activity icon

Replied to Two Api Request

Please share the logic for Countries::getApiCountries()

Activity icon

Replied to Download Options

You should wait and try again later, the limit is there so that users does not take all bandwidth downloading videos.

Activity icon

Replied to Dompdf Id Givving ???

Like i told you yesterday install this package khaledsabbah / laravel-dompdf instead of barryvdh/laravel-dompdf.

this library has support for right to left arabic letters which are used in Farsi and it exports all pdfs in utf-8 unicode

Activity icon

Replied to Compile Css And Js

Normally you do not need to extract jquery, there are some cases where this necessary like when you need to load a library after jquery but before some code in app.js is executed. but you can always import that library in app.js to resolve the problem.

to import it in the view use <script src="{{ asset('js/app.js') }}"></script> and <link rel="stylesheet" href="{{ asset('css/app.css') }}">

Activity icon

Replied to Compile Css And Js

Yes, for each css or js file you are making a new request to the server, the server has to find the file and send a response. it is better if you bundle your assets in one file.

Activity icon

Replied to Resolving Class From Container Is Null In Queued Job

Such problems happens when the job is serialized and then deserialized before execution. If you are resolving the instance in the constructor, Try resolving the instance in the handle method instead.

Activity icon

Replied to Dompdf Id Givving ???

Please explain better what you want to do, which errors you are facing. the title has no meaning, and i do not see where is the problem in the image

Activity icon

Replied to HasOne Relationship Between Two Tables From Different Databases

I think it is possible.

  • create a new connection in config/database.php for the second database.
  • in the model override the default database connection by setting the connection property protected $connection = 'second_database_connection';
  • work with the relations like you would normally do
Activity icon

Replied to How To Make Responsive

Please explain better what you need to do?

Activity icon

Replied to Compile Css And Js

You should check which libraries your template is using, and which version for each library. then install them using npm. then in your app.js, and app.scss import the scripts and styles for the libraries.

Jun
23
2 weeks ago
Activity icon

Replied to Eloquent Multiple Relationship Return Attributes Array

It is a belongsTo relation, it should return a Model object and not a collection

Activity icon

Replied to Eloquent Multiple Relationship Return Attributes Array

Normally you will have an model object returned, you must have something in your model that changing the default behavior.

Please post the complete code of the Sensor and Equipement models.

Activity icon

Replied to How To Add User Id When Attaching

The attach method takes a second parameter, it is an array of the additional fields you want to insert

$post->spams()->attach($request->spams, [
    'user_id' => $user_id
]);

check the docs for more info Attaching / Detaching

Activity icon

Replied to How To Convert This Raw Query Into Laravel Eloquent Way?

In order to use Eloquent you need to have a model for each table in the database and you need to define the relations between the tables in the models. but you can use the query builder to achieve similar results.

\Illuminate\Support\Facades\DB::table('ARCHIVE_LOG_SHEET_HDR')
    ->leftJoin('ARCHIVE_LOG_SHEET_PROG01', 'ARCHIVE_LOG_SHEET_HDR.LOG_ID','=','ARCHIVE_LOG_SHEET_PROG01.LOG_ID')
    ->leftJoin('ARCHIVE_LOG_SHEET_DTL', 'ARCHIVE_LOG_SHEET_HDR.LOG_ID','=','ARCHIVE_LOG_SHEET_DTL.LOG_ID')
    ->select([
        'ARCHIVE_LOG_SHEET_HDR.MATERIAL_ID as media_no',
        'SHOOT as media_type',
        '"" as media_format',
        'ARCHIVE_LOG_SHEET_PROG01.HOUSE_NO as house_no',
        'ARCHIVE_LOG_SHEET_HDR.LOG_DATE as entry_date',
        'ARCHIVE_LOG_SHEET_PROG01.FILM_NAME as program_name',
        '"" as episode_title',
        '"" as episode_no',
        '"" as last_tx',
        'ARCHIVE_LOG_SHEET_HDR.REMARKS as remarks',
        'ARCHIVE_LOG_SHEET_HDR.LOCATION_ID as shelf_no',
        'ARCHIVE_LOG_SHEET_DTL.REMARKS as short_list '
    ])->get();

Please note that this is not a working solution, it is just an example of how you might achieve what you asked for.

for more info check the documentation Database: Query Builder

Activity icon

Replied to Help Converting CURL Request Into Guzzle Request

You are not sending the headers with the get request.


$client = new Client();

$response = $client->get("https://xxxxxxx.xx.auth0.com/api/v2/users/{$userId}" ,[
    'headers' => [
        "Authorization" => "Bearer {$temp_token}",
	"Cache-Control" => "no-cache",
	"Accept" => "application/json",
    ]
]);

echo $response->getBody()->getContents();
Activity icon

Replied to Is It Possible To Be Many To Many Polymorphic?

Yes there are three types of polymorphic relations

for more info check the docs Polymorphic Relationships

May
08
2 months ago
Activity icon

Awarded Best Reply on Delete Many To Many Polymorphic Relationship

Yes it is okay to do it like this, but you are not using the relations On your Order model, i guess you should have a relation to the Product model for ex. orderable

public function orderable() {
    return $this->morphTo();
}

you can use this relation to delete any records in the relation associated with this order like this

static::deleting(function($order) {
    $order->orderable()->delete();
});
Apr
06
3 months ago
Activity icon

Replied to Error Accessing (distant) BelongsToMany Relationship

You do not have a foreign key user_id in you departments table

Activity icon

Replied to Error Accessing (distant) BelongsToMany Relationship

Auth::user()->projects please read my previous replay, when a relation is called as a property it returns a collection

Activity icon

Replied to Error Accessing (distant) BelongsToMany Relationship

You need to define the hasManyThrough relation

public function projects() {
	return $this->hasManyThrough('App\Project', 'App\Department');
}

for more info read the laravel docs: Has Many Through

Activity icon

Replied to Ionrangeslider Is Not Displaying

make sure you are requiring require("ion-rangeslider"); before calling it. you can also try assigning the library to a global variable

window.ionRangeSlider = require("ion-rangeslider");

also make sure you are compiling the code and using the result js file.

Activity icon

Replied to Error Accessing (distant) BelongsToMany Relationship

First there is a diffirence between calling the relation like a method, or like a property.

when called as a method Auth::user()->departments() you get the relation it self, which in this case is a BelongsToMany relation. that allows you to extends the query or create new records

Auth::user()->departments()->create([
	//
]);

but when called as a property Auth::user()->departments you get the result of the relation, which in this case is a collection of many departments it is equivalent to Auth::user()->departments()->get().

now to resolve the error, you need to know that the projects relation is not on the collection of many items returned by departments but it is on the models inside of it.

so you can do the following on User you can use the hasManyThrough relation which let you query the projects directly from the user model

Auth::user()->projects

or you get the departments and for each of them you get the projects, which will result to a collection of collections.

Auth::user()->departments->map->projects
Apr
05
3 months ago
Activity icon

Awarded Best Reply on Only Display Data In Views If It Exists

Since it is a table you must echo the last column even if it was empty, you can use the optional helper to avoid throwing an error when updated by is not set.

 @foreach($tasks as $task)
            <tr>
                <td>{{$task->id}}</td>
                <td>{{$task->title}}</td>
                <td>{{$task->description}}</td>
                <td>{{$task->created_at}}</td>
           	<td>{{$task->createdBy->name}}</td>
                <td>{{optional($task->updatedBy)->name}}</td>
	</tr>
@endforeach
Activity icon

Replied to Array_key_exists(): Using Array_key_exists() On Objects Is Deprecated In Laravel 6 With PHP 7.4

The error is clear. in this file headerTwo.blade.php you are using array_key_exists() to check if an object has a specific property. which is now deprecated. so you instead use isset like this isset($object->property) of using property_exists like this property_exists($object,'property')

Activity icon

Replied to Only Display Data In Views If It Exists

Since it is a table you must echo the last column even if it was empty, you can use the optional helper to avoid throwing an error when updated by is not set.

 @foreach($tasks as $task)
            <tr>
                <td>{{$task->id}}</td>
                <td>{{$task->title}}</td>
                <td>{{$task->description}}</td>
                <td>{{$task->created_at}}</td>
           	<td>{{$task->createdBy->name}}</td>
                <td>{{optional($task->updatedBy)->name}}</td>
	</tr>
@endforeach
Mar
16
3 months ago
Activity icon

Replied to ERROR 404

can you please provide more info about the error, also please share any relevant code

Mar
13
3 months ago
Activity icon

Replied to Nested Categories, How To Fetch A Full Branch?

i have updated the code

Mar
12
3 months ago
Activity icon

Replied to How I Can Search Inside Multiple Websites

After scrapping the page, you can search the html for the words you need to find.

Activity icon

Replied to How I Can Search Inside Multiple Websites

it is not an easy task, but to know more you can learn about 'crawlers', there is a good one from spatie

Activity icon

Replied to Nested Categories, How To Fetch A Full Branch?

Yes, it is a little bit tricky but not that hard.

class Category extends Model
{
    public function categories()
    {
        return $this->hasMany(static::class, 'parent_id');
    }

    public function nestedCategories()
    {
        return $this->categories()->with('nestedCategories');
    }


    /**
     * Return a collection with all the nested categories
     *
     * @return \Illuminate\Support\Collection
     */
    public function categoryTree()
    {
        return $this->getNestedCategories($this);
    }

    /**
     * Internal recursive call function
     *
     * @param $category
     * @return \Illuminate\Support\Collection
     */
    private function getNestedCategories($category)
    {
        $tree = collect([]);

        foreach ($category->nestedCategories as $category) {
            $tree->push($category);

            $sub_tree = $category->getNestedCategories($category);
            if ($sub_tree->isNotEmpty()) {
                $tree->push($sub_tree);
            }
        }

        return $tree;
    }

}

so now you can call the following code, it lets you get all ids for the category with id 1 and all sub categories, and using the nested relation, you would do one or two queries for the whole branch


$ids = Category::with('nestedCategories')->where('id',1)->get()->categoryTree()->flatten()->pluck('id');
Activity icon

Replied to WhereRaw Doesnt Respect To The Global Scope

Your are right, this subject was discussed on stackoverflow, here is the little hack they used to fix it

Mar
05
4 months ago
Activity icon

Awarded Best Reply on Date Interval Between Using Where

You are checking if the start_date bigger then both dateInStart and dateInStart

and the end_date smaller then both dateInStart and dateInEnd

are you sure this is what you want?

Feb
26
4 months ago
Activity icon

Awarded Best Reply on Laravel Eloquent Conditional BelongsTo Relationship

the foreign key customer_id on the users table an be null, when a user selects a customer, then you change the value to the customer->id, if the user changed the customer again you just need to update the customer_id to the new customer->id

Feb
22
4 months ago
Activity icon

Awarded Best Reply on Create Fake Pdf Or Image In Laravel Seeder At The Time Of Migration And Store The Record In Database

$file = \Illuminate\Http\UploadedFile::fake()->create('test.pdf')->store('pdfs')
Activity icon

Replied to MS SQL Error When Running A Laravel Seeder

runphp artisan db:seed -v and post the full stack

Activity icon

Replied to Using Vue In Laravel - Router Or Not When Passing Ids?

Since it is not an spa, i would let laravel do the work of passing the data to the view and handling the logic

Feb
17
4 months ago
Activity icon

Replied to Phpunit THE ERROR HANDLER HAS CHANGED!

if you have phpunit globally installed just run phpunit --self-update on linux or mac or vendor\bin\phpunit --self-update on windows. it should Update PHPUnit to the latest version.

otherwise try to upgrade it using composer.