mvd

Member Since 3 Years Ago

Leusden

Experience Points 34,800
Experience Level 7

200 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 226
Lessons
Completed
Best Reply Awards 18
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.

14 Mar
1 week ago

mvd left a reply on Collection Property Get Issues!

Hi @sudhir1087

With ->first() you get just one item, not a collection. I think you will understand it with this example.

$data = Patiente::where('treatment_date', '>' ,date("Y/m/d"))->first();
dd($data);

and now with this example

$data = collect(['name' => "Anatolli", 'treatment_date' => "2019-03-12"]);
dd($data);
```
13 Mar
1 week ago

mvd left a reply on Cache Doubt

Hi @andersonmichel,

Using Cache::flush(); in a saving method, the cache will be deleted for all users of my site or only for me? For all the users

cache variables are stored in client or server? Server

But sometimes I may update records of "options" table in admin painel and I need to clean all cache and store the variables again. Why don't you update those cached items?

12 Mar
1 week ago

mvd left a reply on How To Use A Custom Form Validator In Laravel ?

@phoenix5 another option is to add the 'required' tag. This prevent to submit the form if there are empty required fields and shows a form browser error. See https://www.w3schools.com/tags/att_input_required.asp

<input type="text" name="field_name" required="required">
11 Mar
1 week ago

mvd left a reply on Truncate Table With Foreign Key

@stereoh yes thats a much better approach for only a update. And if only the order field needs a update

$buisnessModel = Buisness::find($buisness['id']);
$buisnessModel->order = $business['order'];
$buisnessModel->save();

mvd left a reply on Truncate Table With Foreign Key

@stereoh if only the order column needs to be changed, just do a update instead of the truncate and create what @ziben69 wrote.

mvd left a reply on Truncate Table With Foreign Key

Hi @ziben69,

I would not use a foreign key (when I see this code) I should reset the business_id, do a update on Photo model before the 'Business::truncate()'.

public function updateAll(Request $request)
    {
    Photo::update(['business_id' => 0]);
        Business::truncate();

mvd left a reply on Turning The Slot Default Nodes Into An Array Of The Original Html

Hi @dnabeast

Is this what you mean?

<mini-banner v-bind:banners="['img/pic_1.jpg', 'img/pic_.jpg', 'img/pic_2.jpg']"></mini-banner>

In your comonent

export default {
  props: ['banners']
}

In your template

<div v-for="banners in banner">
  <div><img src="{{ banner }}"></div>
</div>
08 Mar
2 weeks ago

mvd left a reply on SQL Query With Inner Join Of Select To Laravel Eloquent

@penaf

You can create joins in the model. https://laravel.com/docs/5.8/eloquent-relationships#one-to-many

Something like in your familias model

public function comments()
    {
        return $this->hasMany('App\Afirmacoes', 'idFam', 'id')-where('idStart', '<>', '');
    }

And your query.

$result = \App\familias->with('afirmacoes')

Not tested but hope you know how to make joins

07 Mar
2 weeks ago

mvd left a reply on Wrap Text In <span> After A Seperator

Hi @christopher,

In PHP?

 $text = 'sit amet | Lorem ipsum dolor sit amet, consectetuer adipiscing elit';
  $text = preg_replace('/\| /', '<span>', $text) . '</span>';
  dd($text);

mvd left a reply on Php Artisan Not Working

@davy_yg

if you run

<?php
phpinfo();
?>

You can find the php.ini file at 'Loaded Configuration File '

mvd left a reply on Move A File From Public/upload Folder To S3 Server

Hi @dinni,

Why do you save your database backup in de public folder, you don't want to access this backup for everyone u guess.

For copy the backup, try this

$contents = Storage::get('db_dump');
Storage::disk('s3')->put($newfile, $contents);
06 Mar
2 weeks ago

mvd left a reply on Laravel Update MySQL Table Failure

@phoenix5 Your id is not numeric.

Can you add 'public $incrementing = false;' to your demo model (in app/demo.php or if your models are in a folder app/models/demo.php) ? Something like

class Demo extends Model
{

public $incrementing = false;

  public function....

mvd left a reply on Laravel Update MySQL Table Failure

@PHOENIX5 - I don't know your database /table structure but the table needs to have a 'id' field. Can you post this output?

Route::get('test', function() {
dd(\App\Demo::find(YOUR_TEST_ID)->toArray());
});

mvd left a reply on How To Edit Laravel Field Validation Message ?

@phoenix5 i don't know if this is the case but if you want the change messages for your whole application you can also the messages in resources/lang/en/validation.php

mvd left a reply on Laravel Update MySQL Table Failure

@phoenix5 also checked the value for the ID?

$request->get('ID')

If you mannualy update the record for testing (in routes/web.php)?

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

$student = \App\Demo::find(YOUR_TEST_ID);
$student->reponse = 'YOUR RESPONSE VALUE'
$student->save();
});

mvd left a reply on Table Overlapping

You miss a > in the php closing

Date:<?php echo  date("j F, Y"); ?</th>
Date:<?php echo  date("j F, Y"); ?></th>

mvd left a reply on Laravel Update MySQL Table Failure

@phoenix5 at the moment i can't see a problem. Is the 'updated_at' field changed in the database after the update?

05 Mar
2 weeks ago

mvd left a reply on Laravel Update MySQL Table Failure

Hi @phoenix5

You are save a new 'student' with

$student->save();

For a update use

$student->update();
04 Mar
2 weeks ago

mvd left a reply on I Want To Block Multiple Users At The Same Time By Selecting Them Using Checkbox.

Hi @gurvindersingh,

I think you are looking for 'whereIn' Example

DB::table('users')
            ->whereIn('id', $request->checkOptions)
            ->update(['block' => 1]);

And in your checkbox

<input type="checkbox" name="checkOptions[]" value="{{ $user->id }}">
26 Feb
3 weeks ago

mvd left a reply on Email Attachment

Hi @giorg,

Your code lookes fine. Did you test this email in another email client or with an other attachment ?

mvd left a reply on Global Variable In Laravel

We can't help you with "Didn't work"

What is not working?

  • Are there errors
  • Is the random id still the same

Did you add

use Session;

On top where you want to flush the session?

mvd left a reply on Global Variable In Laravel

Why you don't you use the token system? https://laravel.com/docs/5.7/csrf

mvd left a reply on Form Generated By AJAX Post Does Not Get Styled.

Hi @shoken,

I think you need to render the form before the return.

 return view('back_end.selectorderform')->with('subcategories',$subcategories)->render();

mvd left a reply on Want Multiple 2 Digit In Jquery

<script>
    $(document).ready(function() {

        $('input[name="amount"], input[name="total"]').on('change', function() {
           var value = parseFloat($('input[name="amount"]').val()) + parseFloat($('input[name="total"]').val());
           $('input[name="field_3"]').val(value);
      alert('Total =  ' + value);   
        });
    });
</script>

mvd left a reply on Laravel Group By Count

Hi @thebigk,

Something like this?

DB::table('user_friends')
  ->select('user_id', \DB::raw('count(*) as total'))
  ->groupBy('user_id')
  ->orderBy('total', 'desc')
  ->get();

mvd left a reply on Problems With Subscribing/unsubscribing To List Of Mailchimp

Hi @petrogromovo,

Did you use the unsubscribe or delete method? From Github

Deleting is not the same as unsubscribing. Unlike unsubscribing, deleting a member will result in the loss of all history (add/opt-in/edits) as well as removing them from the list. In most cases you want to use unsubscribe instead of delete.

Here's how to perform a delete:

Newsletter::delete('[email protected]');

mvd left a reply on Want Multiple 2 Digit In Jquery

Hi @maung-c ,

Something like this?

<script>
    $(document).ready(function() {

        $('input[name="field_1"], input[name="field_2"]').on('change', function() {
           var value = parseFloat($('input[name="field_1"]').val()) + parseFloat($('input[name="field_2"]').val());
           $('input[name="field_3"]').val(value);
        });
    });
</script>

<input type="text" value="0" name="field_1" />
<input type="text" value="0" name="field_2" />
<input type="text" value="0" name="field_3" readonly />
```` ?
18 Feb
1 month ago

mvd left a reply on Twilio For Whats App

Hi @lawkunchi,

Thats almost the same questios as you asked in this post, https://laracasts.com/discuss/channels/laravel/twilio-for-sending-message-notifications

$products   = Product::where('status', 0)->where('created_at' < DATE_SUB(NOW(),INTERVAL 1 HOUR))get();

mvd left a reply on Twilio For Sending Message Notifications

Hi @lawkunchi,

Is there a date created field in the product table? If so, only get the products created created in the past - 3 hours ago. Something like

$products = Product::where->(['status', 0, 'created_at' >= DATE_SUB(NOW(),INTERVAL 3 HOUR)]);
06 Feb
1 month ago

mvd left a reply on Submitting Multiple Forms And Fields

Hi @virgiltu,

Give the form input values a name with brackets

<input type="text" name="fieldname[]" />

If you submit the form you can loop over the fields.

foreach($_POST['fieldname'] as $fieldName) {
print $fieldName;
}

To create / remove multiple form fiields watch this video for example, https://www.youtube.com/watch?v=rVmZXJj5lH0

mvd left a reply on Deployment

Hi PK_06,

You need to set your document_root in the vhost to the public folder. Now only the public file are accessible in the browser.

<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot "C:/wamp/htdocs/yourwebsites/htdocs/public"
    ServerName yourwebsite.com
.....
.....

This article shows how to setup vhosts in Wamp, https://john-dugan.com/wamp-vhost-setup/

05 Feb
1 month ago

mvd left a reply on Npm Run Watch Not Actually Watching Files

Hi @Hectix,

Just a question to confirm , did you include public/js/article.js in your template ? If so, do you see the changes if you run 'npm run dev' or 'npm run prod' in file public/js/article.js

mvd left a reply on Javascript To Change On Click Input Type

Hi

You could do something like this (not tested).

  • Create a file input file with id 'file_input'
  • Create a text field with id 'text_input'

Hide both field if the form is loaded.

#text_input, #file_input { display: none; }

If select is changed.

<script type="text/javascript">
    document.getElementsByClassName('select2').addEventListener("change", function() {
      if (this.options[this.selectedIndex].value == 'image') {
        // Show file input.
        document.getElementById('file_input').style.display = 'block';

        // Hide and clear text input
        document.getElementById('text_input').value = '';
        document.getElementById('text_input').style.display = 'none';
      }
      else {
        // Hide and clear file field.
        document.getElementById('file_input').style.display = 'none';
        document.getElementById('file_input').value = '';

        // Show text input field
        document.getElementById('text_input').style.display = 'block';
      }
    });
  </script>

Other option is doing a ajax request and load the fields in the onchange function.

04 Feb
1 month ago

mvd left a reply on Save Request $request To Different Records

Hi Finchy70,

Maybe create a answer_prefix_table and a answer_prefix_values table

For example:

In the answer_prefix_table:

id | answer_id| prefix 1 | 1 |oil_sample 2 | 1 |cb_timing prefix

answer_prefix_values: id | answer_prefix_table_id | reading_number |value 1 | 2 | 3 | 12 2 | 2 | 4 | 13 3 | 2 | 5 | 14 4 | 2 | 6 | 15

17 Jan
2 months ago

mvd left a reply on Some Issue In Core Php Code Of Imagettftext

And if you set

imagealphablending($rImg, false);

to

imagealphablending($rImg, true);

?

mvd left a reply on Some Issue In Core Php Code Of Imagettftext

Hmm :( Also tested with another font?

mvd left a reply on Get Cache By Pattern In Laravel

Hi @nadeemakhter

I should try something with tags, https://laravel.com/docs/5.7/cache#cache-tags

But in Laravel you can't use tags in file caching so try this package, https://github.com/Torann/taggable-file-cache

mvd left a reply on Some Issue In Core Php Code Of Imagettftext

Hi!

You could try to set the png quality.

imagepng($rImg,$filename, 9);

See the manual, http://php.net/manual/en/function.imagepng.php

08 Jan
2 months ago

mvd left a reply on Restricting Image For A User

Shameless copy/paste from https://laracasts.com/discuss/channels/general-discussion/how-to-protect-images-and-files

There are three approaches I can think of just now;

    You intercept all image and video requests with Laravel, then using the router, serve up the content that the user was after, provided they are authorised. THIS WILL BE SLOW!

    You rely on obscurity and put all that clients images, videos etc in a folder that has a long-unguessable random url. You can then link to the content in your code using the 'static' folder name. The customer's content will always be in that folder and accessible if they log in or not. The advantage of this compared to 1 is that your framework does not have to boot for every image or video.

    Have all the content hidden away - possibly in the storage folder. When the user logs in, create a temporary symbolic link between their public folder and their folder in storage. Keep a note of the link in the session. Use the link in all gallery etc rather than the static code used in (2) above. Once they log out the code will no longer be valid, and you can delete the symbolic link on logout or have a job to tidy it up periodically.

19 Nov
4 months ago

mvd left a reply on Sort A Collection According To An Array Of IDs In Laravel

Hi Ahmadbadpey,

You can sort the collection on the cat_id with something like this

  $x = $collection->toArray();
  usort($x, function($v1, $v2) {
    return strcmp($v1['cat_id'], $v2['cat_id']);
  });

  dd($x);
28 Aug
6 months ago

mvd left a reply on Table Data Filter In Laravel 5.6

No error messages (in your log) ?

21 Aug
7 months ago

mvd left a reply on Custom Login Attempts Message

Do you mean something like this?

@if (count($errors))
    @if (count($errors) == 1 &&  in_array(__('auth.throttle'), $errors->get('email')))
        <p>@lang('auth.throttle')</p>
            <button>Close</button>
            <button>Contact</button>
    @else
         <ul>
                @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                @endforeach
            </ul>
    @endif
@endif 

mvd left a reply on Checking Database Value And Echoing A String To Screen.

Hi Woxene,

You can create some kind of helper function/class, like this

<?php
$types = array('dt' => 'Duties & Taxes ', 'transport ' => 'Transport ');
?>
{{ $types[$transportDTAccount->type] ))

mvd left a reply on Custom Login Attempts Message

@hades300 np, can you show us this code?

mvd left a reply on Custom Login Attempts Message

@hades300 it work and it's the same as $errors->has('email') if you got too many attempts.

Did you change the variable throttle in auth.php to 'Too many login attempts' (because there is a placeholder in it) and test my code?

mvd left a reply on Custom Login Attempts Message

You can change the message in resources/lang/en/auth.php, the throttle variable. Change it to 'Too many login attempts' for example.

In your blade template.

@if (in_array(__('auth.throttle'), $errors->get('email')))
<p>@lang('auth.throttle')</p>
        <button>Close</button>
        <button>Contact</button>
@endif