mvd

Member Since 4 Years Ago

Leusden

Experience Points
99,630
Total
Experience

370 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
542
Lessons
Completed
Best Reply Awards
70
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 20
99,630 XP
Aug
06
6 days 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

Aug
05
1 week ago
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
04
1 week 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
03
1 week 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
02
1 week 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
24
2 weeks 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?

Jul
23
2 weeks ago
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 weeks 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 weeks 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?

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 weeks 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 weeks 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
4 weeks 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
13
4 weeks 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
1 month 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

Jun
28
1 month ago
Activity icon

Replied to Factory Doesn't Save The Value Of Random Integer To Db?

Hi @kkatwork,

seems fine.

Do you use $fillibable in your Form model and is category_idset?

Can you show us the migration for Form?

Validation problem?

Jun
24
1 month ago
Activity icon

Replied to What Is Best Way To Solve This?

Hi @ramlashkar,

<div><input type="checkbox" name="" value="{{ $lr->id }}" @if($lr->route_number == $number) checked="checked" @endif id="exampleCheck1"></div> ?

ps. you can only use an id once, now you have multiple exampleCheck1 id's.

Jun
19
1 month ago
Activity icon

Replied to Change From Local To Production On A Project Already In Use

@msslgomez

No (or you have some fields where you use the the APP_ENV).

Activity icon

Replied to Change From Local To Production On A Project Already In Use

Hi @msslgomez

It is often helpful to have different configuration values based on the environment where the application is running. For example, you may wish to use a different cache driver locally than you do on your production server.

https://laravel.com/docs/6.x/configuration#environment-configuration

Local, .env file

APP_ENV=local
APP_DEBUG=true
....

Production .env file:

APP_ENV=production
APP_DEBUG=false

To use the vue / js in production, run npm run prod first (local / on dev) before your release. This will minify the js code for example.

Jun
03
2 months ago
Activity icon

Replied to Getting Author To View Correct Story In Laravel

@ifrit

I will check the link out, but what do you mean by extend ViewStory.php?

In your ViewStory.php also do check if this user can see the story

if(Auth::check())
{
    if (!here_a_function_and_return_a_boolean_to_check_if_this_user_can_see_this_story) {
        abort(401);
    }
    
    return $next($request);
}else{
    abort(401);
}
Jun
02
2 months ago
Activity icon

Replied to Getting Author To View Correct Story In Laravel

Hi @ifrit

You can create a seperate middleware function (or extend ViewStory.php) or create a policy for this, https://laravel.com/docs/7.x/authorization#writing-policies

Activity icon

Replied to Error Redirecting To Id

@danistrk yes, thats is what I wrote ;)

$lesson = Lesson::with('lessons') Lesson has no relationship 'lessons', that relationship only exists (as far I can see) in the User model

Activity icon

Replied to Error Redirecting To Id

hi @danistrk

Model lessons had no releationship lessons, the relationship is in the user model.

You can do: User::with('lessons')

Or Lesson::with('user')

Activity icon

Replied to Smart Button Paypal

@batoolalsulh I think if you incorrectly upload the site, there also will be errors?

I saw it is possible to pay with also other payment providers than Paypal, maybe this is the problem? Screenshot for payment options, https://ibb.co/VC9MTkZ

May
28
2 months ago
Activity icon

Replied to Smart Button Paypal

@batoolalsulh so some orders are saved and some not. Maybe some customers don't go back to your website after a purchase? Whats is the URL from your site?

May
27
2 months ago
Activity icon

Started a new Conversation DockerCon 2020, May 28th 9AM - 5PM PT | GMT-7

Hi all!

Not a question, but maybe this (free and online) event is also interesting for you.

https://docker.events.cube365.net/docker/dockercon

May
26
2 months ago
Activity icon

Replied to Smart Button Paypal

Hi @batoolalsulh

Hard to see without any code but exaclty 100?

  • Is there no limit from 100 in your code?
  • Or a limit from 100 in your Mysql GUI tool?
  • Did you check de (server) logs?
  • Did you tried a test and ordered something?
May
25
2 months ago
Activity icon

Awarded Best Reply on What Is The Best Way To Include An External Library With Webpack.mix

@heremiguel

Not tested but

Download scrollreveal.min.js and copy it to folder resources/js/ Do the same for jquery.ajaxchimp.min.js

Download slider.css and copy this file to resources/sass/

Change your webpack.mix file (note: includes app.js for Jquery)

mix.scripts(['resources/js/app.js',
        'resources/js/jquery.ajaxchimp.min.js',
        'resources/js/scrollreveal.min.js'],
    'public/js/scripts.js')
    .styles(['resources/sass/app.css',
        'resources/sass/slider.css'],
        'public/css/styles.css');

Run npm run dev

In your HTML head

For scripts:

<script src="{{ asset('js/scripts.js') }}" defer></script>

And styles

<link href="{{ asset('css/styles.css') }}" rel="stylesheet">
May
23
2 months ago
Activity icon

Replied to What Is The Best Way To Include An External Library With Webpack.mix

@heremiguel

Not tested but

Download scrollreveal.min.js and copy it to folder resources/js/ Do the same for jquery.ajaxchimp.min.js

Download slider.css and copy this file to resources/sass/

Change your webpack.mix file (note: includes app.js for Jquery)

mix.scripts(['resources/js/app.js',
        'resources/js/jquery.ajaxchimp.min.js',
        'resources/js/scrollreveal.min.js'],
    'public/js/scripts.js')
    .styles(['resources/sass/app.css',
        'resources/sass/slider.css'],
        'public/css/styles.css');

Run npm run dev

In your HTML head

For scripts:

<script src="{{ asset('js/scripts.js') }}" defer></script>

And styles

<link href="{{ asset('css/styles.css') }}" rel="stylesheet">
Activity icon

Replied to Laravel Mix Problem - Can Not Combine Scripts & Styles

@scotalia also tried with (almost) empty files?

Example:

mix.scripts(['public/js/empty_1.js',
        'public/js/empty_2.js'],
    'public/js/eurotripr.js')
    .styles(['public/css/empty_1.css',
        'public/css/empty_2.css'],
        'public/css/eurotripr.css');

empty_1.js

console.log('empty 1');

empty_2.js

alert('empty 2');

empty_1.css

body {
    background: red;
    color: white;
}

empty_2.css

a {
    color: yellow;
}