mvd

Member Since 4 Years Ago

Leusden

Experience Points
83,840
Total
Experience

1,160 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
439
Lessons
Completed
Best Reply Awards
62
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 17
83,840 XP
Apr
04
1 day ago
Activity icon

Replied to Laravel: Undefined Variable (Beginner)

Hi @yema

Its better to show us some code so we can see where the problem is.

Mar
05
1 month ago
Activity icon

Replied to How To Upload The Pdf/doc File In Laravel Through Validation

Hi @pathsush

And what if you remove this line (you dont check if the validation passed/fails here)

Validator::make($request->all(),['paper'=>"required|string|mimes:pdf,zip"])->validate();

And change

$request->validate([
        'title'=>'required',
         'paper'=>'required'
 ]);

To

$request->validate([
        'title'=>'required',
         'paper'=>'nullable|mimes:pdf,zip'
 ]);

And remove the 'require' from your form field.

<input type="file" class="form-control" name="paper" >

Now the paper file is optional (paper file is not required), if there is a file there is validation to check it's a pdf or zip.

Not sure if the paper file always must be required. But if this is the case change nullable to required off course

Feb
11
1 month ago
Activity icon

Awarded Best Reply on How To Pass Array Of Dates In Dynamic Input Fields

Hi @noblemfd

public function store(StoreGoalRequest $request)
{
  $startDate = Carbon::parse($request->start_date);

$request->start_date is an array because you use brackets in your form field name="start_date[]"

What if you change

foreach ( $request->activity as $key => $activity){
       $goaldetail = new AppraisalGoalDetail();
       $goaldetail->kpi_description            = $request->kpi_description[$key];
       $goaldetail->appraisal_doc              = $request->application_doc[$key];
       $goaldetail->activity                   = $request->activity[$key];
       $goaldetail->start_date                 = $startDate[$key];
       $goaldetail->end_date                   = $endDate[$key];       
......

to

foreach ( $request->activity as $key => $activity){

    $startDate = Carbon::parse($request->start_date[$key]);
    $endDate = Carbon::parse($request->end_date[$key]);

       $goaldetail = new AppraisalGoalDetail();
       $goaldetail->kpi_description            = $request->kpi_description[$key];
       $goaldetail->appraisal_doc              = $request->application_doc[$key];
       $goaldetail->activity                   = $request->activity[$key];
       $goaldetail->start_date                 = $startDate->toDateTimeString();
       $goaldetail->end_date                   = $endDate->toDateTimeString();       
.....

In your store method?

Activity icon

Replied to How To Pass Array Of Dates In Dynamic Input Fields

@noblemfd you need to sort the start/end arrays first Something like this

//$start_date = array('2020-01-01', '2021-03-05', '2019-01-01', '2018-03-11', '2020-01-02');
$start_date = $request->start_date;
function date_sort($a, $b) {
  return strtotime($a) - strtotime($b);
}
usort($start_date, "date_sort");
var_dump($start_date[0]);       // least
var_dump(end($start_date));     // highest
Activity icon

Replied to How To Pass Array Of Dates In Dynamic Input Fields

Hi @noblemfd

public function store(StoreGoalRequest $request)
{
  $startDate = Carbon::parse($request->start_date);

$request->start_date is an array because you use brackets in your form field name="start_date[]"

What if you change

foreach ( $request->activity as $key => $activity){
       $goaldetail = new AppraisalGoalDetail();
       $goaldetail->kpi_description            = $request->kpi_description[$key];
       $goaldetail->appraisal_doc              = $request->application_doc[$key];
       $goaldetail->activity                   = $request->activity[$key];
       $goaldetail->start_date                 = $startDate[$key];
       $goaldetail->end_date                   = $endDate[$key];       
......

to

foreach ( $request->activity as $key => $activity){

    $startDate = Carbon::parse($request->start_date[$key]);
    $endDate = Carbon::parse($request->end_date[$key]);

       $goaldetail = new AppraisalGoalDetail();
       $goaldetail->kpi_description            = $request->kpi_description[$key];
       $goaldetail->appraisal_doc              = $request->application_doc[$key];
       $goaldetail->activity                   = $request->activity[$key];
       $goaldetail->start_date                 = $startDate->toDateTimeString();
       $goaldetail->end_date                   = $endDate->toDateTimeString();       
.....

In your store method?

Activity icon

Replied to Laravel Data Mismatch Error While Using \PDO::ATTR_EMULATE_PREPARES => True

Hi @nileshsinh

So I have made changes in the connection.php file, located in "\vendor\laravel\framework\src\Illuminate\Database"

It's better to do another approach because your lost your changes after an update or if you setup this project on another machine.

Try to cast the value to a boolean in your Eloquent model https://laravel.com/docs/master/eloquent-mutators#attribute-casting

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class YourModelName extends Model
{
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'revoked' => 'boolean',
    ];
}
Feb
05
2 months ago
Activity icon

Replied to How To Validate Field With Existing Data In Table?

Hi @skns

If you mean form validation you can use the 'after:date' validation

'start_date' => 'required|date|after:tomorrow'

Instead of passing a date string to be evaluated by strtotime, you may specify another field to compare against the date

'to_date => 'required|date|after:from_date'

https://laravel.com/docs/6.x/validation#rule-after

Jan
31
2 months ago
Activity icon

Awarded Best Reply on Cookies Across Sub Domains

Hi @abhijeet9920

In the clear method you set->withCookie($cookies); but the variable $cookies does not exist, you need to use->withCookie($all);

If this still not working, can you try Cookie::queue('Bar_Application', null, -1, '.example.com');

Jan
29
2 months ago
Activity icon

Replied to Clear SessionStorage Or LocalStorage After Form Submit Not Working

@sin2san hard to say without knowing youre code.

Activity icon

Replied to Uploading Pdf File In Laravel Vuejs Axios

No, just wanted to know if you can upload an image with this code? Did you test with other files (file formats)?

Also checked you Apache server / PHP logs?

Jan
27
2 months ago
Activity icon

Replied to Uploading Pdf File In Laravel Vuejs Axios

@usmanbasharal

I can upload image but for pdf I face may problems

And if you upload an image with this code it works?

Jan
25
2 months ago
Activity icon

Replied to Uploading Pdf File In Laravel Vuejs Axios

@usmanbasharal an image is also a file ;)

Is your pdf to large? Did you watched in your server (error) logs?

Activity icon

Replied to Uploading Pdf File In Laravel Vuejs Axios

Hi @usmanbasharal,

$file->move this will copy an existing file on your server to another location on your server. You can use the $file->store() or $file->storeAs() function.

I think this tutorial will help you, https://medium.com/@jagadeshanh/image-upload-and-validation-using-laravel-and-vuejs-e71e0f094fbb

Jan
17
2 months ago
Activity icon

Replied to I Need Help In Laravel Packages

Hi @mindorodev

Don't have experience with this package but what if you visit, https://yourwebsite.com/admin/polls ?

See the route file for this package, https://github.com/akiyamaSM/larapoll/blob/master/src/Http/routes.php

Jan
15
2 months ago
Activity icon

Awarded Best Reply on What's Wrong With My Sql Query?

@uksarkar

You are almost there, there is a little typo in your code. Change NOT EXIST to NOT EXISTS (you forgot the 'S').

Activity icon

Replied to What's Wrong With My Sql Query?

@uksarkar

You are almost there, there is a little typo in your code. Change NOT EXIST to NOT EXISTS (you forgot the 'S').

Jan
14
2 months ago
Activity icon

Replied to What's Wrong With My Sql Query?

@uksarkar and if you first do the JOIN before the WHERE statement?

SELECT  *  FROM `reservation_nights`
JOIN `reservations` ON `reservation_nights`.`reservation_id` = `reservations`.`id`
WHERE  `rooms`.`id` = `reservation_nights`.`room_id` AND `reservations`.`status` NOT IN ('CANCEL')
Dec
11
3 months ago
Activity icon

Replied to Need Laravel Advise To Render Information To The Landing Page.

@masumluf So i must query a lot of times will it effect page loading performance ?

Thats why I suggest the cach function (save/store the results from the queries for example) if you notice a high page load.

Activity icon

Replied to Datepicker Using JQuery And Bootstrap

Hi @islandman

It sounds like the bootstrap-datetimepicker css file is missing / not loaded. Can you check if this file is loaded, and if not inlcude this to your website?

Activity icon

Replied to Need Laravel Advise To Render Information To The Landing Page.

@masumluf

using a function and query for each category and store it multiple value and send it to blade page ?

That is an option, to load the information in separated variables and pass it to the view Example

$news = News::where('status', 1)->get();
$jobs = Jobs::where('status', 1)->get();
return view('landingpage', compact('news', 'jobs');

In your landingpage view you can create/include view partials, example

@include('view.jobs', ['jobs' => $jobs])

If the page is loading slow, create some kind of cach functionlity to store (a part of) the content (and rebuild this after someting is changed).

Dec
10
3 months ago
Activity icon

Replied to Object Of Class Illuminate\Database\Eloquent\Collection Could Not Be Converted To Int

@kanchan186, use the dd() function,

$mechanic=Mechanic::where(['mechanics.mechanic_id', '=', $mechanic_id])->where('active_status',1)

         ->join('countries','mechanics.mech_country','=','countries.country_id')
         ->join('states','mechanics.mech_state','=','states.state_id')
         ->join('cities','mechanics.mech_city','=','cities.city_id')
         ->get();
dd($mechanic);
Activity icon

Replied to Object Of Class Illuminate\Database\Eloquent\Collection Could Not Be Converted To Int

@kanchan186 did you also remove

if($active_status==1){

and the closing } for this statement?

Dec
09
3 months ago
Activity icon

Awarded Best Reply on How To Work With Database For Subscription

Hi @jonjie,

Increase the timestamp for subscription_ends_at ? Example:

// Load subscription and add 5 days to the current timestamp.
$subscription->subscription_ends_at ->addDays('5'));
// Update subscription
Activity icon

Replied to How To Work With Database For Subscription

@jonjie If you get the subscription with Eloquent, timestamps are in the Carbon format. Carbon is class with some nice functionalities to deal with dates in PHP. Carbon docs, https://carbon.nesbot.com/docs/

Activity icon

Replied to Object Of Class Illuminate\Database\Eloquent\Collection Could Not Be Converted To Int

Hi @kanchan186,

$active_status=MechBrand::get();
      
      if($active_status==1){

$active_status is the collection, not a integer.

You can test this to write dd($active_status);

Remove the above code (and the closing if statement) and change

$mechanic=Mechanic::where('mechanics.mechanic_id',$mechanic_id)

To

$mechanic=Mechanic::where(['mechanics.mechanic_id', '=', $mechanic_id], ['active_status', '=', 1])
Activity icon

Replied to How To Work With Database For Subscription

Hi @jonjie,

Increase the timestamp for subscription_ends_at ? Example:

// Load subscription and add 5 days to the current timestamp.
$subscription->subscription_ends_at ->addDays('5'));
// Update subscription
Dec
06
3 months ago
Activity icon

Replied to Checkbox Validation Error Message Displaying Wrongly

@rider can you upload the image to a (free) tool like https://imgur.com/ ?

Activity icon

Replied to Checkbox Validation Error Message Displaying Wrongly

hi @rider

Do you have a screenshot from this situation?

Is it a browser validation message, default Laravel error message or do you use a tool to show the errors?

Activity icon

Replied to 419 Page Expired

hi @pipariyah1

You get a 419 status code, if an (external) script tries to post to your Laravel application, without the o-so-needed CSRF token.

First option is to change in App\Http\Middleware\VerifyCsrfToken: protected $except = [ /, ]; (or maybe something more specific and a little more safe, like /myapiurl/,)

Second option is to put the route in api.php instead of web.php, but that implies prefixing all your routes with /api/

https://markohoven.com/2018/01/23/419-http-status-code/

Already see/ tried this?

Dec
05
4 months ago
Activity icon

Replied to Tooltip Display And Copy

@deepu07 but you said

below is code working for copy and but not showing the tooltip when mouse hover on a button

Copy function does work, see https://jsfiddle.net/mvd81/84motv67/28/

Dec
04
4 months ago
Activity icon

Replied to Having Problem With Cached Collection!

Hi @dgvai

->latest() instead of ->first() ?

Activity icon

Replied to Use Find() And With() Together In Laravel Query

Hi @afoysal

Edit: @sinnbeck was faster :D

Try this

Employee::with('employees.employee_locations')->find(1);
Activity icon

Replied to Tooltip Display And Copy

Hi @deepu07

$('button').tooltip({
            trigger: 'click',
            placement: 'bottom'
        });

You trigger the tooltip with a click event. You can remove the trigger or set it to 'hover'

$('button').tooltip({
            placement: 'bottom'
        });
Activity icon

Replied to Cookies Across Sub Domains

Hi @abhijeet9920

In the clear method you set->withCookie($cookies); but the variable $cookies does not exist, you need to use->withCookie($all);

If this still not working, can you try Cookie::queue('Bar_Application', null, -1, '.example.com');

Nov
26
4 months ago
Activity icon

Replied to JQuery Validator

Hi @paduraruionutandrei

I think because event.preventDefault();

What if you move event.preventDefault(); below

if($('#category-form').validate().checkForm()) {
                    $.ajax({
                        type: 'post',
                        url: '{{ route('categories.store') }}',
                        data: $('#category-form').serialize(),
                        success: function (data) {
                            console.log(data)
                        },
                    });
                }
Nov
25
4 months ago
Activity icon

Awarded Best Reply on Delete Row & All It's Relations From Db

Hi @tobyreed

You must first delete the relation and then you can call $obj->delete()

Another option is to use Foreign Key Constraints, onDelete('cascade') https://laravel.com/docs/5.8/migrations#foreign-key-constraints

Nov
21
4 months ago
Activity icon

Replied to Laravel/Lumen Logging

Hi @jayadevan

With APP_DEBUGyou show the errors on your browser screen.

If you do not want debug logs you must set the 'log level'

When using Monolog, log messages may have different levels of severity. By default, Laravel writes all log levels to storage. However, in your production environment, you may wish to configure the minimum severity that should be logged by adding the log_level option to your app.php configuration file.

Once this option has been configured, Laravel will log all levels greater than or equal to the specified severity. For example, a default log_level of error will log error, critical, alert, and emergency messages

Monolog recognizes the following severity levels - from least severe to most severe: debug, info, notice, warning, error, critical, alert, emergency.

https://laravel.com/docs/5.3/errors#log-severity-levels

Nov
20
4 months ago
Activity icon

Replied to Delete Row & All It's Relations From Db

Hi @tobyreed

You must first delete the relation and then you can call $obj->delete()

Another option is to use Foreign Key Constraints, onDelete('cascade') https://laravel.com/docs/5.8/migrations#foreign-key-constraints

Nov
19
4 months ago
Activity icon

Awarded Best Reply on Did Laravel Carbon And Eloquent Has Or Do Like Subtime() In Mysql

Hi @chalahed

In Eloquent you can use the raw functionlity

$total = "49:00:00";
  $foo = "09:00:00";
  $users = DB::table('users')
    ->select(DB::raw('SUBTIME("' . $total . '", "' . $foo . '")'))
    ->get();

In Carbon, check the 'Addition and Subtraction' section https://carbon.nesbot.com/docs/#api-addsub