Member Since 5 Years Ago

Leusden

Experience Points
112,230
Total
Experience

2,770 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
614
Lessons
Completed
Best Reply Awards
78
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.

  • Community Pillar

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

Level 23
112,230 XP
Jan
18
5 days ago
Activity icon

Replied to Blade Component Issue

hi @ehsan bagherzadegan

Somewhere in Blade you are calling your component but you don't add the for variable I guess? You need something like:

<x-error for="your for value"></x-error>
Activity icon

Awarded Best Reply on Laravel Rule To Pass If Value Is Either Hostname Or IP

Hi @mathewparet

You don't have to write a regex, PHP has already has a (filter_var) function for this.

private function isValidIP($value)
return filter_var($value, FILTER_VALIDATE_IP) !== false;
}

https://www.w3schools.com/php/filter_validate_ip.asp

Laravel does the same in the IP validation, vendor\laravel\framework\src\Illuminate\Validation\Concerns\ValidatesAttributes.php

/**
     * Validate that an attribute is a valid IP.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function validateIp($attribute, $value)
    {
        return filter_var($value, FILTER_VALIDATE_IP) !== false;
    }
Activity icon

Replied to Laravel Rule To Pass If Value Is Either Hostname Or IP

Hi @mathewparet

You don't have to write a regex, PHP has already has a (filter_var) function for this.

private function isValidIP($value)
return filter_var($value, FILTER_VALIDATE_IP) !== false;
}

https://www.w3schools.com/php/filter_validate_ip.asp

Laravel does the same in the IP validation, vendor\laravel\framework\src\Illuminate\Validation\Concerns\ValidatesAttributes.php

/**
     * Validate that an attribute is a valid IP.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function validateIp($attribute, $value)
    {
        return filter_var($value, FILTER_VALIDATE_IP) !== false;
    }
Activity icon

Replied to Payload Column In Sessions Table

Hi @uniqueginun

It stores the encoded(base64_encode) data from a session.

Example

$request->session()->put('key', 'value');

value (and some more info as user ID and the current timestamp) will be encoded stored in the payload column.

Jan
05
2 weeks ago
Activity icon

Awarded Best Reply on File(docx,pdf) And Image(jpeg,png Etc..) Support Validation Laravel

Hi @neeraj1005

Image

The file under validation must be an image (jpg, jpeg, png, bmp, gif, svg, or webp).

https://laravel.com/docs/8.x/validation#rule-image

You can use a MIME Rule and add the validation mime types from the image validation.

$validatedData = $this->validate([
            'product_name' => 'required',
            'images.*' => 'mimes:jpg,jpeg,png,bmp,gif,svg,webp,pdf,docx|max:1024',
        ]);

https://laravel.com/docs/8.x/validation#basic-usage-of-mime-rule

Activity icon

Replied to File(docx,pdf) And Image(jpeg,png Etc..) Support Validation Laravel

Hi @neeraj1005

Image

The file under validation must be an image (jpg, jpeg, png, bmp, gif, svg, or webp).

https://laravel.com/docs/8.x/validation#rule-image

You can use a MIME Rule and add the validation mime types from the image validation.

$validatedData = $this->validate([
            'product_name' => 'required',
            'images.*' => 'mimes:jpg,jpeg,png,bmp,gif,svg,webp,pdf,docx|max:1024',
        ]);

https://laravel.com/docs/8.x/validation#basic-usage-of-mime-rule

Dec
29
3 weeks ago
Activity icon

Awarded Best Reply on How To Delete Files On Download Cancellation

Hi @daenufrey

I make use of ZipArchive and this is doing what you want to do. https://www.php.net/manual/en/class.ziparchive.php

Here is an example

   $zip = new ZipArchive();
   
    //create the file and throw the error if unsuccessful
    if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
        exit("cannot open <$archive_file_name>\n");
    }
    
    //Add image
    foreach($images as $files)    {
        $zip->addFile($file_path.$files,$files);

    }
    $zip->close();
    //then send the headers to force download the zip file
    header("Content-type: application/zip");
    header("Content-Disposition: attachment; filename=$archive_file_name");
    header("Pragma: no-cache");
    header("Expires: 0");
    readfile("$archive_file_name");

    // remove zip
    unlink($archive_file_name);
    exit;

I did not use Laravel for this code above, so maybe you can look to streamDownload in Laravel https://laravel.com/docs/7.x/responses#file-downloads

Sometimes you may wish to turn the string response of a given operation into a downloadable response without having to write the contents of the operation to disk. You may use the streamDownload method in this scenario. This method accepts a callback, file name, and an optional array of headers as its arguments

Dec
09
1 month ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@rod2rick no errors in the logs?

Your upload code looks fine.

Did you set some dumps/dd code in your upload code for debugging?

Example:

if ($request->hasfile('image')) {
	dump('has file');	
            $image = $request->file('image');
            $filename = $produit->nom . '_' . time() . '.' . $image->getClientOriginalExtension();
            if ($produit->image && $produit->image == 'noproductimage.jpg') {
	dump('in if');
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            } else {
	dump('in else');
                File::delete(public_path('/uploads/produits/' . $produit->image));
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            }
            $produit->image = $filename;
        }
dd('end debugging');
Dec
08
1 month ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

Hi @rod2rick

Add

headers: {
  'Content-Type': 'multipart/form-data'
}

In your Axios request

axios.post("/api/createproduit", {
          nom: this.nom,
          description: this.description,
          image: this.image,
        }, headers: {
    'Content-Type': 'multipart/form-data'
    })
        .then((response) => {
    this.produits = response.data.data;
    this.loading = false;
....
....

Or


            let formData = new FormData();
            formData.append('file', this.image);  

            this.axios.post('/api/createproduit',

                formData,
                {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
              }
.....

Dec
04
1 month ago
Activity icon

Awarded Best Reply on Eloquent Make Exists Return True

You can use exists() on queries, $post = Post::make(); is not a query, with this code you are only creating and returning an un-saved model instance.

Activity icon

Replied to Eloquent Make Exists Return True

You can use exists() on queries, $post = Post::make(); is not a query, with this code you are only creating and returning an un-saved model instance.

Activity icon

Replied to Get All Data From Two Tables

Hi @maltekiefer

    foreach($mail as $id){
        dd($id->communicationtypeCompanies);
        dd($id->communicationtypeContacts);
    }
Dec
03
1 month ago
Activity icon

Replied to Livewire Nested Component Not Working

Hi @adgower

What if you add a Listener?

<?php

namespace App\Http\Livewire\Todos;

use Livewire\Component;

class TodoShow extends Component
{
    public $todo;

protected $listeners = ['render' => 'render'];

    public function render()
    {
        return view('livewire.todos.todo-show');
    }
}
Nov
24
1 month ago
Activity icon

Replied to Anonymous Component Props Always Equal To Default Value

@ignium thanks!

Already tried to recreate input.blade.php step by step?

I don't have Livewire installed on this machine but tried to reproduce your code without Livewire. This is working.

input.blade.php

@props([
'prepend' => null,
'append' => null,
'type' => 'text'
])

<div class="{{ $attributes->get('class') }}">
    <label for="test-input" class="block text-sm font-medium leading-5 text-gray-700">{{ $slot }}</label>
        <input
            {{ $attributes->except('class') }}
            id="test-input"
            type="{{ $type }}"
            data-lpignore="true"
            class="form-input block w-full sm:text-sm sm:leading-5 {{ $prepend ? 'pl-7' : '' }} {{ $append ? 'pr-12' : '' }} disabled:bg-gray-100"
        />
        @if($append)
            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                <span class="text-gray-500 sm:text-sm sm:leading-5" id="price-currency">
                {{ $append }}
                </span>
            </div>
        @endif

</div>

and

<x-input
                            wire:model.lazy="initial_payment"
                            min="0"
                            step="0.01"
                            type="number"
                        prepend="$"
                        placeholder="placeholder....."
                        class="col-span-6 sm:col-span-3"
                        >field name</x-input>
Nov
23
2 months ago
Activity icon

Awarded Best Reply on Real Time Validation Of Nested Object Fails

And removing the space?

'user.badge' => 'required|unique:users, badge',

to

'user.badge' => 'required|unique:users,badge',

?

Activity icon

Replied to Real Time Validation Of Nested Object Fails

And removing the space?

'user.badge' => 'required|unique:users, badge',

to

'user.badge' => 'required|unique:users,badge',

?

Activity icon

Replied to Anonymous Component Props Always Equal To Default Value

Hi @ignium

Can you post the full input.blade.php file?

Activity icon

Replied to Real Time Validation Of Nested Object Fails

hi @jgravois

You can also add the column name in the validation

'user.badge' => 'required|unique:users, badge',
Nov
20
2 months ago
Activity icon

Commented on Tags Component Testing

Thanks Andre! Usefull course.

Nov
17
2 months ago
Activity icon

Replied to Livewire Error On Form - Freezing Screen

@randy_johnson

Error in your code?

<input type="password" class="form-control" wire:model=" name"wire:model="password" required>

Oct
12
3 months ago
Activity icon

Awarded Best Reply on TEMPORARY Table In Laravel

@araw I think this is the case

  • If you run php artisan migrate (for the first time to create the table) and create the table temp_data, the table exists.
  • If you run temporary_check for the first time everything is still working
  • But by running temporary_check you also drop the table temp_data so the next time you run temporary_check the table does not exist and you will get this error.

So you need somewhere recreate the temp_data table.

Another option is to don't drop the table (Schema::drop('temp_data');) but remove all the data inside this table (DB::table('temp_data')->truncate();) so the table keeps existing.

Oct
11
3 months ago
Activity icon

Replied to TEMPORARY Table In Laravel

@araw I think this is the case

  • If you run php artisan migrate (for the first time to create the table) and create the table temp_data, the table exists.
  • If you run temporary_check for the first time everything is still working
  • But by running temporary_check you also drop the table temp_data so the next time you run temporary_check the table does not exist and you will get this error.

So you need somewhere recreate the temp_data table.

Another option is to don't drop the table (Schema::drop('temp_data');) but remove all the data inside this table (DB::table('temp_data')->truncate();) so the table keeps existing.

Oct
10
3 months ago
Activity icon

Replied to TEMPORARY Table In Laravel

@araw

Can you show us your (whole) migration file for this table?

Activity icon

Replied to TEMPORARY Table In Laravel

@araw

Do you have a GUI tool voor your database? Like PHPmyadmin for example and can you see the table temp_data?

Activity icon

Replied to TEMPORARY Table In Laravel

@araw

And you also fired php artisan migrate?

You drop table in the code Schema::drop('temp_data');. Do you run the check temporary_checkmultiple times? Can you give us the output of

...
public function temporary_check()
{
    
    

    DB::table('temp_data')->insert(['sender_id'=>2,'receiver_id'=>3,'message'=>'message temp check']);

    $data = DB::table('temp_data')->get();
dd($data);	
    Schema::drop('temp_data');

    return $data;
}

Still the same error

Activity icon

Replied to TEMPORARY Table In Laravel

Hi @araw

But in this piece of code you don't create the table. Did you create the temp table somewhere?

https://laravel.com/docs/8.x/migrations#creating-tables

Activity icon

Replied to How To Upload Multiple Image In A Single Row?

Hi @majedabdullah

Not tested but something like this?

if($request->hasFile('files')){
    $counter = 0;
    
    $project = [
        'project_name' => $addProjectName,
        'project_des' => $addProjectDes,
        'project_link' => $addProjectLink
    ];
    
    $host = $_SERVER['HTTP_HOST'];
    foreach ($request->file('files') as $file) {
        $files =  $file->store('public');
        $fileName =  (explode('/',$files))[1];        
        $projectImage = 'http://'.$host.'/storage/'.$fileName;
        
        if (!$counter) {
            $project['project_image'] = $projectImage;
        }
        else {
            $project['project_image' . $counter] = $projectImage
        }
        $counter++;
        
    }

    DB::table('projects')->insert($project);
}
Sep
25
3 months ago
Activity icon

Replied to Migrating Wordpress Site

hi @davy_yg

Did you upload the file wp-config.php?

Aug
21
5 months ago
Activity icon

Awarded Best Reply on Illuminate\Contracts\Container\BindingResolutionException Target Class [App\Http\Controllers\CubeController] Does Not Exist.

Hi @niyazvpp

Did you try to clear the cache?

php artisan config:cache or composer dump-autoload?

Activity icon

Replied to Illuminate\Contracts\Container\BindingResolutionException Target Class [App\Http\Controllers\CubeController] Does Not Exist.

Hi @niyazvpp

Did you try to clear the cache?

php artisan config:cache or composer dump-autoload?

Aug
20
5 months ago
Activity icon

Replied to Getting 404 Error In Every Laravel Project After Adding A Virtual Host In Xampp.

Hi @ravish

Can you show us the whole C:/xampp/apache/conf/extra/httpd-vhosts and C:\Windows\System32\drivers\etc\hosts file?

Can you also give us a link to the Youtube video?

Activity icon

Replied to Element-ui Pagination With Table

@msslgomez you already have solved this(I see your answer as solved in your other topic) ?

Aug
19
5 months ago
Activity icon

Replied to Element-ui Pagination With Table

Hi @msslgomez

I never used this package but based on the documentation you need to pass the total items (you already do this), current-page number and page-size, based on those variables the pagination can create the pager.

Example, you have 45 items, you want to show 10 items on a page. So you pass

Total: 45

Page-size: 10

current-page: 1

You will see something like 1 | 2 | 3 | 4 | 5

If you click on another page item, event handleCurrentChange will triggered.

handleCurrentChange(val) {
    console.log(`current page: ${val}`);      
},

Based on the new current page you can do an axios request for example and getting the next/previous 10 items for in you table. I assume :data="displayData" is the data for in el-table?

Something like:

handleCurrentChange(val) {

 axios.get("your-url-to-get-new-data?page=" + ${val})
        .then(response => {
            // update displayData
        })     
},
Activity icon

Replied to Admin-lte Installation And Setup Through Npm

@neeraj1005 did you already create an Blade file with only HTML / CSS / JS for datatables?

Aug
18
5 months ago
Activity icon

Replied to 2000 External Api Call In A Job

Hi @equimper

Now you are doing a query for each player, so yes a lot of queries. Bulk is a good idea but Eloqent does not support bulk for updateOrCreate

Maybe you can use something like this for bulk insert https://gist.github.com/RuGa/5354e44883c7651fd15c ?

Activity icon

Replied to Admin-lte Installation And Setup Through Npm

Hi @neeraj1005

Are there errors in your browser console?

Aug
05
5 months ago
Activity icon

Replied to How To Delete Files On Download Cancellation

@automica it seems like that, if I remove the unlink then I will (of course) see the file if I cancel it

Activity icon

Replied to How To Delete Files On Download Cancellation

@automica

The download popups if the zip is ready so you can't cancel the download if it is not ready. If I cancel the download when it is ready, there is no file on the server.

Activity icon

Replied to How To Delete Files On Download Cancellation

Hi @daenufrey

I make use of ZipArchive and this is doing what you want to do. https://www.php.net/manual/en/class.ziparchive.php

Here is an example

   $zip = new ZipArchive();
   
    //create the file and throw the error if unsuccessful
    if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
        exit("cannot open <$archive_file_name>\n");
    }
    
    //Add image
    foreach($images as $files)    {
        $zip->addFile($file_path.$files,$files);

    }
    $zip->close();
    //then send the headers to force download the zip file
    header("Content-type: application/zip");
    header("Content-Disposition: attachment; filename=$archive_file_name");
    header("Pragma: no-cache");
    header("Expires: 0");
    readfile("$archive_file_name");

    // remove zip
    unlink($archive_file_name);
    exit;

I did not use Laravel for this code above, so maybe you can look to streamDownload in Laravel https://laravel.com/docs/7.x/responses#file-downloads

Sometimes you may wish to turn the string response of a given operation into a downloadable response without having to write the contents of the operation to disk. You may use the streamDownload method in this scenario. This method accepts a callback, file name, and an optional array of headers as its arguments

Aug
03
5 months ago
Activity icon

Awarded Best Reply on Prevent Timestamps When Increment View_count

Hi @naysoewin,

You can disable the timestamps and do a save?

 $post->timestamps = false;
 $post->increment('view_count');
 $post->save();

And you can create a kind of increment in your $post model

public function incrementViewCount() {
        $this->timestamps = false;
        $this->increment('view_count');
        $this->save();
    }

So you can call

$post->incrementViewCount();
Activity icon

Replied to Prevent Timestamps When Increment View_count

Hi @naysoewin,

You can disable the timestamps and do a save?

 $post->timestamps = false;
 $post->increment('view_count');
 $post->save();

And you can create a kind of increment in your $post model

public function incrementViewCount() {
        $this->timestamps = false;
        $this->increment('view_count');
        $this->save();
    }

So you can call

$post->incrementViewCount();
Aug
02
5 months ago
Activity icon

Replied to FullCalendar Is Not Defined

@afoysal

The 2.2.7 version uses Jquery

https://embed.plnkr.co/plunk/wx1lC8 (see script.js how to setup with Jquery)

And some more demo, https://github.com/fullcalendar/fullcalendar/tree/v2.2.7/demos

Aug
01
5 months ago
Activity icon

Replied to FullCalendar Is Not Defined

@afoysal

The JS/HMLT code from

{!! $calendar->calendar() !!}

{!! $calendar->script() !!}
Activity icon

Replied to How To Insert And Fetch Record Same Time Using Vue

@jlrdw

I don't think @tarang19 want do this at the same time but more do a post and return the create record (maybe @tarang19 needs some relationschip or there are some accessors / mutators for this created item). But this is just a assumption because it is a Vue question and not a Laravel / Eloquent question.

Activity icon

Replied to How To Insert And Fetch Record Same Time Using Vue

Hi @tarang19

You can use axio to do a post and return some data.

This article will help you, https://www.itsolutionstuff.com/post/laravel-vue-js-axios-post-request-example-and-demoexample.html to do this.

Activity icon

Replied to FullCalendar Is Not Defined

Hi @afoysal

What is the js output and source from

{!! $calendar->calendar() !!}

{!! $calendar->script() !!}

?

Jul
23
6 months ago
Activity icon

Replied to 404, Non-objects

@hekmatyar it means there are no records in your database with status = 'published' and slug = '$slug'

If there are records, can you show us a screenshot from those records?

Activity icon

Replied to 404, Non-objects

@hekmatyar

Replace

$offer = Offer::where('slug', '=', $slug)
        ->where('status', 'published')
        ->firstOrFail();
dd($offer);

with

$offer = Offer::where('slug', '=', $slug)
        ->where('status', 'published')
        ->get();
dd($offer);

To see if you have results from the query.

Activity icon

Replied to 404, Non-objects

Hi @hekmatyar

Are you sure you set {{ $offer->title }} in view offers.show?

What is the output from this dump?

$offer = Offer::where('slug', '=', $slug)
        ->where('status', 'published')
        ->firstOrFail();
dd($offer);