mbo

Member Since 1 Year Ago

Experience Points
8,090
Total
Experience

1,910 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
42
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

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

Level 2
8,090 XP
Apr
03
1 week ago
Activity icon

Started a new Conversation Replace Within A Collection

I'm trying to do the following:

I'm running a query and getting a collection. See below:

\MacBook-Pro:ligplaats $ php artisan Update:AutoTextDps
Illuminate\Database\Eloquent\Collection {#41546
  #items: array:1 [
    5 => App\service {#16047
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:11 [
        "id" => 3
        "service_parent_id" => 2
        "service_status_id" => 1
        "service_object" => 1
        "service_name" => "AAA"
        "service_discription" => ""
        "service_value" => "1.00"
        "service_weighting" => "1.00"
        "service_ranking" => "1.00"
        "created_at" => null
        "updated_at" => null
      ]

No i want to replace the "service_name" - AAA with BBB

How can i best do this?

I tried to do this by:

     $value = $dp->services->whereIN('id',[5,3,9,10,11])->implode('service_name',', ');

And than:

 $kind = str_replace($value,'AAA'  , 'BBB');

This works. But i want to be able to replace more values ($value contains of more values that have to be replaced)

How can i best solve this?

thanks for the help.

Mar
31
1 week ago
Activity icon

Replied to Replace Value Directly In Mysql Database

thanks for the reply. In this case "sql tutorial" is fixed. How do you deal with 50.000 rows where each time the value wherein you want to replace something changes?

In this example: colom latitude?

thanks for the reaction

Activity icon

Started a new Conversation Replace Value Directly In Mysql Database

good day,

I'm trying to replace something directly in my mysql database (5.7.28)

Using the following code:

SELECT latitude
FROM postcodes
REPLACE (latitude,',','.')

it gives a error. But i don't understand.

ou have an error in your SQL syntax; 

Thanks for the help1

Activity icon

Started a new Conversation Selecting Location Within Range

Goodday,

I'm trying to do the following:

Search locations within a range of a certain point based on latitude and longitude. I got this working going through the list of points and calculate the distance to the point. Then i filter them by distance to find the locations within the range.

part of the script:

  $lat1 = deg2rad($postcode->latitude);
                        $lon1 = deg2rad($postcode->longitude);
                        $lat2 = deg2rad(floatval($latitude));
                        $lon2 = deg2rad(floatval($longitude));
    
                        $delta_lat = $lat2 - $lat1;
                        $delta_lng = $lon2 - $lon1;
    
                        $hav_lat = (sin($delta_lat / 2))**2;
                        $hav_lng = (sin($delta_lng / 2))**2;
    
                        $distance = 2 * asin(sqrt($hav_lat + cos($lat1) * cos($lat2) * $hav_lng));
    
                        $earth_radius_km = 6371.009;
    
                        $actual_distance = $earth_radius_km * $distance;


But now i want to find the zip codes near a point. Also based on latitude and longitude. But now we got almost 50.000 zip codes. I don't want to use the method above because i then have to go through all zip codes and calculate the distance. A process whats costs a lot of serverpower.

I'am wondering if there is way to pre select zipcodes who could be in the range. So i can first select the zipcodes where i can be useful to calculate the distance. Then i can run those zip codes through the way i described above.

Anyone any tips for this?

thanks in advance.

Mar
28
2 weeks ago
Activity icon

Replied to How To Reach Helper Functions In Command

Thanks for the reply,

i can access the function in my controllers etc. but not in my helper. About auto-loading: if set it up as follows:

composer.json

under files:

files": [
        "app/helpers/xxxx.php",
        "app/helpers/xxx.php"
        
    ]

Is there something wrong?

I also fond this post: https://laracasts.com/discuss/channels/laravel/laravel-global-helper-functions-not-working

thanks for the help.

Activity icon

Started a new Conversation How To Reach Helper Functions In Command

I'm trying to reach my function that are specified in a helper function. But i can't reach them. Is there a way to solve this?

some background: the script i created works fine in a controller. There the public functions in the helper work fine.

Thanks for the tips.

Mar
25
2 weeks ago
Activity icon

Replied to Getting Data From A Collection

i found my mistake: i ended with a where statement. But should have ended with pluck. Thanks for the help

Activity icon

Started a new Conversation Getting Data From A Collection

Good day,

I try to get only the region_names out of this collection.

This is the collection:

Collection {#1874 ▼
  #items: array:4 [▼
    7 => Region {#1882 ▼
      #table: "regions"
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 935
        "region_name" => "Friesland"
        "region_name_slug" => "friesland"
        "region_discription" => null
        "region_ranking" => 1
        "region_show1" => 1
        "region_show2" => 1
        "region_show3" => 1
        "region_status_id" => 1
        "region_latitude" => 53.164164
        "region_longitude" => 5.781754
        "region_range" => 30
        "created_at" => "2019-07-08 14:13:07"
        "updated_at" => "2020-05-13 17:20:47"
        "dp_distance" => 24.687351101903
        "within_range" => "within"
        "distance_value" => 1
      ]
      #original: array:14 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▶]
    }
    24 => Region {#1899 ▶}
    30 => Region {#1905 ▶}
    210 => Region {#2085 ▶}
  ]
}


I want to get back only the region_names, This can be done with a loop. But can it also be done with something else? Like "pluck" from laravel?

Thanks for the help!

Mar
24
2 weeks ago
Activity icon

Replied to Automatic Creat A Text

Thanks all for the answers!

Mar
23
3 weeks ago
Activity icon

Started a new Conversation Automatic Creat A Text

good day,

I have the following case:

  • company will fill in form with all kind of information.
  • i create random sentences

Based on that information + sentences, i want to automatically write a text.

What is the best practice:

  1. Using laravel collections?
($collection->random() )
  1. using default php
array_rand($a,1)

Thanks for the advice.

Mar
15
4 weeks ago
Activity icon

Replied to Creating Model

Thanks for the reply. Indeed that will work. But it works with lazy loading. By doing so it creates a lot of queries. Any idea how i tackle this in de model?

Activity icon

Started a new Conversation Creating Model

Good day,

i like to create a model that get the right data directly.

Background: the database structure is as follows:

USER hasmany DPS

DPS hasmany USERS

USER has a CONVERSATION

CONVERSATION hasmany MESSAGES

CONVERSATION is linked to DPS with CONVERSATION_DP_ID

MESSAGE is linked to CONVERSATION with MESSAGE_CONVERSATION_ID

My current dp model I'm able to get all the conversations by the dps:

  public function dps_conversations() {

    return $this->hasMany('App\Conversation','conversation_dp_id')->orderBy('updated_at', 'dsc');
  }

But how do i get my messages in the function?

Lazy loading does the following:

select * from `messages` where `messages`.`message_conversation_id` = '3334' and `messages`.`message_conversation_id` is not null

Thanks for the help!

Mar
12
1 month ago
Activity icon

Started a new Conversation Basic Foreach Question

Good day,

Im taking up the programming again. I running in a simple issue. But trying to understand why it is not working:

The case is as follows:

dd($dp->users)

gives back

User {#1557 ▼
  #fillable: array:20 [▶]
  #hidden: array:2 [▶]
  #connection: "mysql"
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:24 [▶]
  #original: array:24 [▶]
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #visible: []
  #guarded: array:1 [▶]
  #rememberTokenName: "remember_token"

Foreach on the users:

  @foreach ($dp->users as $user)
dd($user)

"dd" in this foreach gives back "true".

The following

  @foreach ($dp->users as $user)
     
              {{ $user->id}}) 

gives the following error

Trying to get property 'id' of non-object

any idea what i'm doing wrong?

Mar
11
1 month ago
Activity icon

Replied to Create Internal Links On Website

Thanks for the reply. My plan is to build it. The question i have: where to catch the text? In the controller or somewhere else in the laravel platform? Like the build in optie for translations?

What do you think is the best route?

Activity icon

Started a new Conversation Create Internal Links On Website

good day,

In wordpress there are some plugin that make able to ad some internal links in je your text. The original text is not affected by these links.

What do i want:

i want to create something similar in laravel. What is the best way to do this? In the controller? or somewhere else in laravel?

are there any packages which can use as example?

Thanks for the help!

br

maarten

An example:

https://codecanyon.net/item/interlinks-manager/13486900

Mar
10
1 month ago
Activity icon

Started a new Conversation How To Set Custom Validation Per Form

Good day,

I want to achieve the following:

  • Show custom validation message
  • on 1 specific form
  • Keep it the same for all other forms.

Currently i'm using it like this:

controller:

$this->validate($request, [

    'dp_department_name' => 'required',


  ]);

I'm using the default built in solution where the name of the variable i used.

I expect the method below to replace it i all instance. Not only one form.


/*
    |--------------------------------------------------------------------------
    | Custom Validation Language Lines
    |--------------------------------------------------------------------------
    |
    | Here you may specify custom validation messages for attributes using the
    | convention "attribute.rule" to name the lines. This makes it quick to
    | specify a specific custom language line for a given attribute rule.
    |
    */

    'custom' => [
        'attribute-name' => [
            'rule-name' => 'custom-message',
        ],
    ],

It there a way to create a custom message per form?

thanks for the reaction.

br

Maarten

Mar
07
1 month ago
Activity icon

Started a new Conversation Best Laravel Forum Package

Good day,

I have a question about forum packages: any tips what is currently the best and of which you can expect it will be maintained in the future?

Thanks for the tips!

br

maarten