mvd

Member Since 3 Years Ago

Leusden

Experience Points 47,440
Experience Level 10

2,560 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 301
Lessons
Completed
Best Reply Awards 26
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

23 May
1 day ago

mvd left a reply on Translate A Text Paragraph From English To Vietnamese

Hi @khatran,

The error is clear, you are not add a valid key when you do a request.

Did you create service account key?

22 May
2 days ago

mvd left a reply on DNS Nameservers

Interesting questions and surprises it can work. Check this answer https://serverfault.com/a/744148

mvd left a reply on How To Mantain The Session When User Travels From Laravel Website To Angular 2 Website

Hi @napster21

I think you are looking for SSO (Single sign-on).

Single sign-on (SSO) is a property of access control of multiple related, yet independent, software systems. With this property, a user logs in with a single ID and password to gain access to any of several related systems

More info: https://en.wikipedia.org/wiki/Single_sign-on

I'm not familiar with SSO and Laravel but there are some solutions such as https://github.com/ramdannur/laravel-sso-passport

mvd left a reply on Validation Request Question

Hi @chrisgrim.

Not tested but does this work?

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{

  $rules = [
    'title' => 'required|unique:posts,id'.$this->id,
    'content' => 'required',
    'seo_meta' => 'required',
  ];

  if (!is_numeric($this->id)) {
    $rules['header-image'] = 'required';
  }

  return $rules;
}
21 May
3 days ago

mvd left a reply on Caching External Images Local

@chim0r

You can also build this

  • Create a table (example 'cached_images'), with a varchar for the image name and timestamp when created.
  • Upload the image and add a record in this database table with the imagename
  • Create a cron job every hour to check if there are images in this database table are older then a hour. If so delete the image and the record from the database table.
20 May
4 days ago

mvd left a reply on Issues With Sending An Email With A Pdf Attachment

@shiva hard to say because you dumped the $order->user->name and you saw the output ('Test')

When you did the dump, there were no errors?

mvd left a reply on Issues With Sending An Email With A Pdf Attachment

@shiva

Thanks, so the problem is not in ?

It refers to this line $user_name = $order->user->name;

mvd left a reply on How To Show Array As Separated Fields In Laravel Resource Api

Hi @farshadf

Not tested but does this work?

public function toArray($request)
{

  $output = array();
  foreach ($this->hasroom as $index => $room) {

    $output[] = array(
      'hasroom' => $room,
      'hasdate' => $this->hasdate[$index]
    );
  }
  
  return $output;

}

mvd left a reply on Issues With Sending An Email With A Pdf Attachment

@shiva thanks! And var_dump($order->user->name); in the foreach loop?

mvd left a reply on Issues With Sending An Email With A Pdf Attachment

@shiva can you give us the output from $order->user in the foreach loop?

var_dump($order->user);

mvd left a reply on Issues With Sending An Email With A Pdf Attachment

You only do a query if the order exists, not a check.

$exists = Order::find($order->id)->where('user_id', $user_id)->latest()->first();
$exists->status = 'success';

$exists->save();

$invoice_number = Session::get('invoice_number');

$order_number = Order::where('invoice_number', $invoice_number)->get();

$user_name = $order->user->name;
....
....

Change to

$exists = Order::find($order->id)->where('user_id', $user_id)->latest()->first();
if ($exists) {
$exists->status = 'success';

$exists->save();

$invoice_number = Session::get('invoice_number');

$order_number = Order::where('invoice_number', $invoice_number)->get();

$user_name = $order->user->name;
....
....
}
else {
    // order does not exist, do something else
}
15 May
1 week ago

mvd left a reply on AOS With Jquery.easing.min.js Not Working

I don't know because i dont have all the code, but i would use one version for Jquery. Test if this work, else start debugging (Google on the errors / search for solutions etc.)

In this article you can start learn how to debug javascript. https://codeburst.io/learn-how-to-debug-javascript-with-chrome-devtools-9514c58479db

mvd left a reply on AOS With Jquery.easing.min.js Not Working

@irankhosravi 'scrollspy' try to fix the errors, is not a function.

Also you load multiple versions for Jquery, this can also cause problems.

mvd left a reply on AOS With Jquery.easing.min.js Not Working

Hi @irankhosravi,

Are there errors in your browser console?

14 May
1 week ago

mvd left a reply on Trying To Get Property 'id' Of Non-object

In previous versions of Laravel, you could access session variables or the authenticated user in your controller's constructor. This was never intended to be an explicit feature of the framework. In Laravel 5.3, you can't access the session or authenticated user in your controller's constructor because the middleware has not run yet.

https://laravel.com/docs/5.3/upgrade#5.3-session-in-constructors

Try this in your construct method

$this->middleware(function ($request, $next) {
            $this->currentuser = Auth::user()->id;

            return $next($request);
        });
09 May
2 weeks ago

mvd left a reply on Create A Services Checkbox

Hi @zfdeveloper,

I think your are looking for a pivot table. For example a table with 2 columns user_id | service_id

If a service is anabled for a user, add this service to this table. If a service is disbaled, don't add (or remove) this service to this table.

For the filter, use the join / relationship functionality. https://laravel.com/docs/5.8/eloquent-relationships

mvd left a reply on Select Data Which Created_at Today Error

@emfinanga yes, at this name to your select

->select('sales.created_at', 'addressitems.clientName','sales.address_id'

You can access the created_at now in your query result.

mvd left a reply on Select Data Which Created_at Today Error

Hi @emfinanga,

You created a query with a join. The query does not know from which table 'created_at' is. So change

->whereRaw('date(created_at) = ?', [Carbon::today()])

to

->whereRaw('date(sales.created_at) = ?', [Carbon::today()])

mvd left a reply on Override Sections With Defaults

np :) also see the docs for more info/help https://laravel.com/docs/5.8/blade#template-inheritance

The @yield directive also accepts a default value as its second parameter. This value will be rendered if the section being yielded is undefined:

08 May
2 weeks ago

mvd left a reply on Override Sections With Defaults

Hi,

Looks fine but you can also add a default value or view in the yield tag.

@yield('default_header', View::make('default_header'))

mvd left a reply on Want To Update Only Those Columns In The Db That Are Null Or Empty.

Hi @gaan10,

Does this work?

$model = ProcedureBooking::where('booking_id', '=', $inputs['booking_id'])- where('document_'.''.$x, '<>', '')-                >update(['document_'.''.$x => $myArray[$i]]);

mvd left a reply on Load Data For Month Selected

Hi @ladydeathkzn,

With this query you can get the months from the database to an array.

  $months = DB::table("your_table_name_with_the_financial_records")
    ->select(DB::raw('monthname(created_at) AS month'))
    ->orderBy('created_at')
    ->groupBy(DB::raw('month'))
    ->get()
    ->toArray();
dd($months);
02 May
3 weeks ago

mvd left a reply on Laravel Cache Issue In 5.8

Hi @hariprasanth what you can do is set the cache driver to 'array' in development.

In your .env file

CACHE_DRIVER=array
01 May
3 weeks ago

mvd left a reply on The Right Way Formatimg The JS Code

Hi @johnef_sh

Try it with backticks, replace

 newdiv.innerHTML = '<div class="col-md-12 col-md-pull-1"><div class="col-md-6">{!! Form::text("measurements[' + (counter + 1) + '][width]", null, ["class"=>"form-control", "placeholder" => trans("interface.width")]) !!}</div>';

To

newdiv.innerHTML = `<div class="col-md-12 col-md-pull-1"><div class="col-md-6">{!! Form::text("measurements[` + (counter + 1) + `][width]", null, ["class"=>"form-control", "placeholder" => trans("interface.width")]) !!}</div>`;

mvd left a reply on Dividing Columns With Barryvdh/laravel-dompdf Laravel

@abdulbazith probably a collection i gues. Can you change

$pursSplit = array_chunk($purs , round(count($purs) / 2));

to

$pursSplit = $purs->chunk(round($purs->count() / 2));
29 Apr
3 weeks ago

mvd left a reply on A Where Like Relationship

@dde-matt

I think i don't get it but i give it a try :p

  $sources = \App\Source::whereHas('emails', function($query) {
    $query->where('job_title', 'LIKE', "%Maths%");
  })->whereHas('segment', function($query) {
    $query->where('id', 1);
  })->get();

mvd left a reply on A Where Like Relationship

Hi @dde-matt

Not tested but hope you get the idea.

 App\Segment::where('name', 'maths')->whereHas('emails', function($query) {
    $query->where('ob_title', 'maths teacher');
  })->get();

Change the the current emails relation in your segment model to something like this.

public function emails() {
    return $this->belongsToMany('App\Email');
}
28 Apr
3 weeks ago

mvd left a reply on Specify Keys Or Properties On A Return Type .

Hi @lacasera

No because in a interface there is no logica. Compare it as a index of a book. I suggest to use extend a helper class so you don't have to do the validation in every class that uses interface Foo.

class validation {

    public function validateArray($input) {
        if (!isset($input['key'])) {
            Throw new Exception('Array key does not extsist');
        }
        elseif (!isset($input['key_2'])) {
            Throw new Exception('Array key_2 does not extsist');
        }
        return true;

    }
}

interface Foo {

    public function bar($input);
}


class testClass extends validation implements Foo {
    
   public function bar($input) {
       $this->validateArray($input);
   }
}

class testClass2 extends validation implements Foo {

    public function bar($input) {
        $this->validateArray($input);
    }
}

$test = new testClass();
$test->bar(array('key' => 'Test key', 'key_2' => 'Test key 2'));

$test2 = new testClass2();
$test2->bar(array('key' => 'Test key')); //<-- Error because array 'key_2' does not exists.
27 Apr
3 weeks ago

mvd left a reply on Dividing Columns With Barryvdh/laravel-dompdf Laravel

Hi @abdulbazith,

I'm not 100% sure but is this what you want?

<?php
$pursSplit = array_chunk($purs , round(count($purs) / 2));
?>
<table width="100%;border:0;">
    <tr>
        <td>
            <table id="design">

                <thead>
                <tr>

                    <th>Date</th>
                    <th>Time</th>
                    <th>R/L</th>
                    <th>No.of.Lit(Lt)</th>
                    <th>Total(Rs)</th>
                    <th>Note</th>
                </tr>
                </thead>

                <tbody>
                @foreach($pursSplit[0] as $pur)
                    <tr>

                        <td>{{ $pur->date->format('d-m-y') }}</td>
                        <td>{{ $pur->time }}</td>
                        <td>{{ $pur->rate_per_litre }}</td>
                        <td align="right">{{ $pur->no_of_litre }}</td>
                        <td align="right">{{ $pur->total }}</td>
                        <td>{{ $pur->note }}</td>
                    </tr>
                @endforeach

                </tbody>
            </table>
        </td>
        <td>
            <table id="design">

                <thead>
                <tr>

                    <th>Date</th>
                    <th>Time</th>
                    <th>R/L</th>
                    <th>No.of.Lit(Lt)</th>
                    <th>Total(Rs)</th>
                    <th>Note</th>
                </tr>
                </thead>

                <tbody>
                @foreach($pursSplit[1] as $pur)
                    <tr>

                        <td>{{ $pur->date->format('d-m-y') }}</td>
                        <td>{{ $pur->time }}</td>
                        <td>{{ $pur->rate_per_litre }}</td>
                        <td align="right">{{ $pur->no_of_litre }}</td>
                        <td align="right">{{ $pur->total }}</td>
                        <td>{{ $pur->note }}</td>
                    </tr>
                @endforeach

                </tbody>
            </table>
        </td>
    </tr>
</table>
26 Apr
4 weeks ago

mvd left a reply on Odd Image Upload Issue

@mattb can you check de image filenames? Because some images does work well so i think the problem is not in de code.

mvd left a reply on Property [id] Does Not Exist On This Collection Instance

@talentedaamer it's because in $grades there are (or there can be) mutliple items

What you can do is

class GradeCollection extends ResourceCollection
{
    public function toArray($request)
    {
       // return parent::toArray($request);
    $grades = array();
    foreach ($this->resource as $grade) {
        $grades[] = array(
            'id' => $this->id,
            'name' => $this->grade_name,
            'section' => $this->grade_section
        );
    }
    return $grades;
    }
}

But if you want the grades just in a array format you can also do this in your controller

return Grade::select('id', 'name', 'section')->get()->toArray();

mvd left a reply on How To Download A File If I Only Have The Content Stored In The BD?

@sndytj if you don't want to store the file you could do something like this

yourControllerMethod() {
    header('Content-type: text/plain');
    header('Content-Disposition: attachment; filename="manifesto.txt"');
        
    $manifesto = \App\ManifestoTableModel::where('id', 1)->pluck('manifesto')->first();
    print $manifesto;
    exit;
}
25 Apr
4 weeks ago

mvd left a reply on Issue Installing Mailgun\Bogardo Package With Composer In Laravel

@gabotronix good question, i think you need to install the package for this feature. Try @bobbybouwmann solution.

mvd left a reply on Sending Mail Blade Template With Variables Through Mailgun Php SDK.

Hi @gabotronix,

Change your maildriver to Mailgun, it is already installed in Laravel (see config/mail.php) Now you can use the default mail functionlity from Laravel

mvd left a reply on Issue Installing Mailgun\Bogardo Package With Composer In Laravel

Hi @gabotronix

You don't need to install Mailgun, it's already installed in Laravel. Just set the MAIL_DRIVER variabele to 'mailgun'

See config/mail.php

 /*
    |--------------------------------------------------------------------------
    | Mail Driver
    |--------------------------------------------------------------------------
    |
    | Laravel supports both SMTP and PHP's "mail" function as drivers for the
    | sending of e-mail. You may specify which one you're using throughout
    | your application here. By default, Laravel is setup for SMTP mail.
    |
    | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
    |            "sparkpost", "postmark", "log", "array"
    |
    */

    'driver' => env('MAIL_DRIVER', 'smtp'),
```

mvd left a reply on Error Exception Array To String Conversion In Curl

@kuns25

Clear, i think the problem is more releated to Hubtel. Did you do all the steps from the admin in this post https://developers.hubtel.com/discuss/5ca594484ce2e10555ee980d ?

mvd left a reply on Tawk.to(chat Tool) Integration To Laravel Project

Hi @shivaprakash

Can you see the Tawk.to code in your browser source code?

Another option is to past the snippet widget code from Tawk.to in your master blade template just before the closing body tag (offcourse replace xxxxx with you id).

<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/xxxxxxxxxxxxx/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
</body>
</html>

It this is not working, check your browser console for javascript errors

mvd left a reply on Error Exception Array To String Conversion In Curl

Hi @kuns25,

You need to use http_build_query.

CURLOPT_POSTFIELDS => http_build_query($invoice),

Did you not to forget to execute the api request?

curl_exec($curl)

And did you add your ip-address to the whitelist? https://developers.hubtel.com/discuss/5c8c19ba743a5201a9761ab2

mvd left a reply on Can I Pass Variable Into Setbody Attribute In Mail ?

Hi @van1310

I can't see what is wrong in this part of your code. I think you error is somewhere else in your code.

Just a note You already set a body (template) so you dont use the $message->setBody($amount) If you want to use setBody, change your code to.

Mail::send(array(), ["name" => "demo"], function($message) use($mail,$amount){
                
    $message->to($mail)->subject('Payment Confirmed');
                
    $message->setbody($amount);
            
});
23 Apr
1 month ago

mvd left a reply on Creating A Contact Form Without Controllers And Migrations

Why don't you want to use a controller? A migration is not necessary (only if you want to log the message for example).

mvd left a reply on My Add Group Member Button Not Fuctioning (javascript)

@ain

$ is not defined Try to fix this one because your are user $ in your script ($('#add').click(function(){....)

mvd left a reply on My Add Group Member Button Not Fuctioning (javascript)

This is not the answer but set the script before the closing body tag.

</div>
@yield('script')
</body>
</html>

Are there errors in your browser console?

mvd left a reply on How To Compress Image Size Using Intervention

Hi @dev0ps,

What kind of image extension do you use (png/jpg)?

Define optionally the quality of the image. It is normalized for all file types to a range from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. The default value is 90.

15 Apr
1 month ago

mvd left a reply on Pluck Only Name From A Nested Array

Hi @mykelcodex ,

$tran['data']['metadata']['product_name']['name']

?

mvd left a reply on What's The Recommended Way To Build Form?

And use some (live) templates to create html form fields to speed up the process For PHPStorm, https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/7