Member Since 5 Years Ago

Leusden

Experience Points
117,030
Total
Experience

2,970 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
647
Lessons
Completed
Best Reply Awards
80
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 24
117,030 XP
Feb
10
2 weeks ago
Activity icon

Replied to Error With Abstract Metho

The error tells you already what is wrong Class App\Exports\ ItemsSaleExcel contains 1 abstract method and must therefore be declared abstract or implement the remaining methods

And it gives you the missing method as well, collection So you know there is something wrong with collection

Activity icon

Awarded Best Reply on Error With Abstract Metho

Hi @swimmer

You are missing the collection method in your ItemsSaleExcel class.

But I think it is a typo?

 public function collectio ()
        {

        $items_info =  collect($this->links_with_sale);                
        //    $items_info = $items_info->only(['SKU', 'tradesy_sku']);
            
                    
            return $items_info;
        }

Missing the 'n' in your method collectio instead of collection

Activity icon

Replied to Error With Abstract Metho

Hi @swimmer

You are missing the collection method in your ItemsSaleExcel class.

But I think it is a typo?

 public function collectio ()
        {

        $items_info =  collect($this->links_with_sale);                
        //    $items_info = $items_info->only(['SKU', 'tradesy_sku']);
            
                    
            return $items_info;
        }

Missing the 'n' in your method collectio instead of collection

Feb
09
2 weeks ago
Activity icon

Awarded Best Reply on Remove 'CMP/' From A HUGE Array

Hi @jgravois

Try preg_replace()

preg_replace — Perform a regular expression search and replace

https://www.php.net/manual/en/function.preg-replace.php

$output = preg_replace("/(CMP/)(.+)/", "$2", $input);

Attention: The code highlight below removes the $2 in the replacement :/

<?php
$input= [
    "CMP/452",
    "CMP/47",
    "CMP/A117"
];
var_dump(preg_replace("/(CMP\/)(.+)/", "", $input));

/*
array(3) {
  [0]=>
  string(3) "452"
  [1]=>
  string(2) "47"
  [2]=>
  string(4) "A117"
}
*/

?>
Activity icon

Replied to Remove 'CMP/' From A HUGE Array

Hi @jgravois

Try preg_replace()

preg_replace — Perform a regular expression search and replace

https://www.php.net/manual/en/function.preg-replace.php

$output = preg_replace("/(CMP/)(.+)/", "$2", $input);

Attention: The code highlight below removes the $2 in the replacement :/

<?php
$input= [
    "CMP/452",
    "CMP/47",
    "CMP/A117"
];
var_dump(preg_replace("/(CMP\/)(.+)/", "", $input));

/*
array(3) {
  [0]=>
  string(3) "452"
  [1]=>
  string(2) "47"
  [2]=>
  string(4) "A117"
}
*/

?>
Jan
18
1 month 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
1 month 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
1 month 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
2 months 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
2 months 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
2 months 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
2 months 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
3 months 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
3 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
3 months ago
Activity icon

Commented on Tags Component Testing

Thanks Andre! Usefull course.

Nov
17
3 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
4 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
4 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
4 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
5 months ago
Activity icon

Replied to Migrating Wordpress Site

hi @davy_yg

Did you upload the file wp-config.php?

Aug
21
6 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?