mvd

Member Since 5 Years Ago

Leusden

Experience Points
104,420
Total
Experience

580 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
575
Lessons
Completed
Best Reply Awards
72
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 21
104,420 XP
Oct
12
2 weeks 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
2 weeks 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
2 weeks 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
1 month ago
Activity icon

Replied to Migrating Wordpress Site

hi @davy_yg

Did you upload the file wp-config.php?

Aug
21
2 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
2 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
2 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
2 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
2 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
2 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
2 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
2 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
3 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);
Jul
21
3 months ago
Activity icon

Replied to Request File Validation Fails Not Redirecting To View Page In Which Form Is Submitting.

@amit028 I am not familiar with the CoreRequest class.

Does the CoreRequest class make use of the formrequest class? Maybe you can implement the failedValidation method?

class RegisterCompany extends CoreRequest {

protected function failedValidation(Validator $validator)
    {
        throw (new ValidationException($validator))
                    ->errorBag($this->errorBag)
                    ->redirectTo($this->getRedirectUrl());
    }

public function rules()
{
...
}

}
Activity icon

Replied to Request File Validation Fails Not Redirecting To View Page In Which Form Is Submitting.

Hi @amit028

Can you show us your controller code where you do the validation?

Activity icon

Replied to Request File Validation Fails Not Redirecting To View Page In Which Form Is Submitting.

Hi @amit028

This is not a validation error but a sql error. If you want a validation for a unique e-mail you need this

'email' => 'required|email|unique:company_table_name,email'

And change 'company_table_name'to your sql table name for companies.

https://laravel.com/docs/7.x/validation#rule-unique

Jul
20
3 months ago
Activity icon

Replied to Model Factory Loop

@davidsprauel

With the 'function'

'contact_id'      => function() {
            return factory(Contact::class)->create()->id;
        },

you can pass a variable and use it for the 'contact_id'. If you don't pass this variable it will use the return factory(Cont.... code.

With

'contact_id' => factory(Contact::class)

You are generating a new contact and you can not override the 'contact_id'

Activity icon

Replied to Model Factory Loop

Hi @davidsprauel

Yes there is a problem a contact factory creates a company but the company factory creates again a contact ...you are in a loop. I am not sure if this is the best way but this will not loop.

Change the company factory to this

$factory->define(Company::class, function (Faker $faker) {
    return [
        'name'            => $faker->company,
        'contact_id'      => function() {
            return factory(Contact::class)->create()->id;
        },
        'location_id'     => factory(Location::class),
        'company_type_id' => rand(1, 3),
    ];
});

Create a company but you don't have a contact yet, so set this to 0

$company = factory(Company::class)->create(['contact_id' => 0]);

Update contact factory

$factory->define(Contact::class, function (Faker $faker) {
    return [
        'company_id'       => function() {
            return factory(Company::class)->create()->id;
}       ,
        'user_category_id' => rand(1, 3),
        'entry_date'       => now(),
        'key'              => Str::random(16),
        'email'            => $faker->safeEmail
    ];
});

Create the contact

$contact = factory(Contact::class)->create(['company_id' => $company->id]);

Now we have also a contact so we can update company with this contact id.

$company->contact_id = $contact->id;
$company->save();

Change the user factory

$factory->define(User::class, function (Faker $faker) {
    return [
        'contact_id'     => function() {
            return factory(Contact::class)->create()->id;
        },
        'firstname'      => $faker->firstName,
        'lastname'       => $faker->lastName,
        'email'          => $faker->unique()->safeEmail,
        'password'       => 'yIXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password,
        'key'            => Str::random(16),
        'remember_token' => Str::random(10),
    ];
});

Last step, create the user

$user= factory(User::class)->create(['contact_id' => $contact->id]);
Activity icon

Replied to Cannot Send Request For API In Postman

Hi @nickywan123

Can you show us some Postman screenshots with you settings and response?

Jul
19
3 months ago
Activity icon

Awarded Best Reply on Function () Does Not Exist Http://localhost/Laravel/public/signup

Hi @prachee

I think you need uses and not users

Route::post('/signup', [
	'uses' => '[email protected]',
	'as' => 'signup'
]);
....
Activity icon

Replied to Function () Does Not Exist Http://localhost/Laravel/public/signup

Hi @prachee

I think you need uses and not users

Route::post('/signup', [
	'uses' => '[email protected]',
	'as' => 'signup'
]);
....
Jul
18
3 months ago
Activity icon

Replied to Field Missing In ::create But Works With ::insert

Hi @sumeshvasu

If you add this (test) code to your route/web.php

Route::get('test', function () {

// Don't know your model path/name, just a guess	
    \App\freelancerVehicleModel::create([
        'user_id' => 1,
        'vehicle_type' => 'bike',
        'vehicle_brand' => 'sample brand',// hardcoded
        'vehicle_model' => 'sample model',// hardcoded
        'vehicle_color' => 'red',
        'vehicle_number' => 123,
        'status' => true,
    ]);
});

And run 'yoursite/test' in your browser? Is there a new record in your database?

Activity icon

Replied to Group By Date In Controller

Hi @bhhussain,

Something like this?

->groupBy(DB::raw("DATE_FORMAT(job_invoice_date, '%Y-%m-%d')")

?

Activity icon

Replied to Field Missing In ::create But Works With ::insert

Hi @sumeshvasu ,

Can you show us the controller code where you hardcoded this and where do the create?

Activity icon

Replied to Field Missing In ::create But Works With ::insert

Hi @sumeshvasu

You are not passing a ‘vehicle_brand’ from the postman request I guess. And the database field has no default value.

Activity icon

Replied to Eloquent Issue With Vue.js - Stuck With Loop

@boubou

How do you bind the response in your Axios request.

Code looks fine, example: https://jsfiddle.net/mvd81/a1nsvqL4/16/

Activity icon

Awarded Best Reply on Delete File After Download

Hi @trifek,

You can use deleteFileAfterSend

return response()->download(storage_path($fileNameServer), $fileName)->deleteFileAfterSend(true);

https://laravel.com/docs/5.0/responses#other-responses

Activity icon

Replied to Delete File After Download

Hi @trifek,

You can use deleteFileAfterSend

return response()->download(storage_path($fileNameServer), $fileName)->deleteFileAfterSend(true);

https://laravel.com/docs/5.0/responses#other-responses

Activity icon

Replied to Conditionally Changing Vue Data Doesn't Effect In The View

Hi @kundefine

Sorry forget my previous post, I can't see at the moment why it is not working.

What is the output if you log, response.data

console.log(response.data);

Created a quick example and this does work, https://jsfiddle.net/mvd81/z7mafx92/4/

Jul
17
3 months ago
Activity icon

Replied to Is This A Good Practice Or Not?

Hi @joaquinvilchez,

That is an option, also you have a price history for your product. You can copy the id from the current price table to your order_product table.

Example: id | order_id | product_id | id_from_price_table

Other option (if you don't care about the price history) is to copy the price to an 'order_products' table when someone place an order.

Example: id | order_id | products_id | price |

Jul
14
3 months ago
Activity icon

Awarded Best Reply on How To Modify Relationships Loaded Using With()

Hi @doctolly,

I never used presenters but does this work?

$staff = $duties->staff->present(StafPresenter::class);
Jul
12
3 months ago
Activity icon

Replied to Format Date With Carbon DiffForHumans

Hi @adgower,

Does this works?

 $event = Carbon\Carbon::parse($events->first()->start_date);
 $diffInHours = $event->diffInHours(Carbon\Carbon::now());
 dd($diffInHours);
Jul
11
3 months ago
Activity icon

Replied to Laravel HTTP - CURL Error 60: SSL Certificate Problem: Unable To Get Local Issuer Certificate

If you run

phpinfo();

in a php script and call this php file in your browser, search for 'php.ini' you can see which is in use.

Activity icon

Replied to Laravel HTTP - CURL Error 60: SSL Certificate Problem: Unable To Get Local Issuer Certificate

Hi @jeroenvanrensen

You have to make sure SSL / HTTPS is enabled. Search for 'wampserver enable ssl error 60' on Google