kima

kima

Member Since 1 Year Ago

Experience Points
2,730
Total
Experience

2,270 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
1
Lessons
Completed
Best Reply Awards
4
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 1
2,730 XP
Jul
24
3 months ago
Activity icon

Replied to Multiple Find Query In Single Database Connection

find function is able to receive an array in the $id argument:

$departments = Department::find([1, 2, 3, 4, 5, 6, 7])
Jul
23
3 months ago
Activity icon

Replied to Cannot Create A Simple Array

The chunk works with an anonymous function, thus the sitemap is not in your scope. you should declare $sitemap before the chunk function, and add it with a use to the anonymous function:

        $sitemap = [];

        Listing::where('Inactive', '=', 0)
            ->where('Status', '=', 'Active')
            ->chunk(200, function($listings) use ($sitemap) {
            foreach($listings as $listing) {
                $sitemap[] = array (
                    $cleanURL = "https://listingnaples.com/listing/" . $listing->MLSNumber . "/" . $listing->CleanAddressURL,
                    "loc" => $cleanURL,
                    "changefreq" => "daily",
                    "priority" => "0.90"
                );
            }
        });
Activity icon

Replied to Filter Model Entry Laravel Collection

I didn't understand your logic, but at notice that the where function is immutable, and you need to set the $allUsers as the result:

$allUsers = $allUsers->where($key, 1)

Activity icon

Replied to One To One Relationship From The Same Table

The save functions in add_spouse should get the member model and not the spouse id

public function add_spouse($spouse_id)
    {
        $spouse = Member::find($spouse_id);
        $this->spouse()->save($spouse);
        $spouse->spouse()->save($this);
    }
Jul
21
3 months ago
Activity icon

Replied to How To See Curl Output?

Please show your ApiRequest::curlRequest method

Jul
11
4 months ago
Activity icon

Replied to Find And Replace In Laravel Collection

@zaheer Please change the $rslt = DB::table('journal') to $rslt = YoutModelName::query()

When you are querying with DB::table, the records are returned as stdClass, with no Eloquent features.

Jun
27
4 months ago
Activity icon

Replied to How To Convert Following Sql Query To Laravel Query Buillder?

DB::raw has no $bindings parameter. please try this:

 $query  = DB::table('branch')
            ->select(['id', 'name'])
            ->selectRaw("( 3959 * acos ( cos ( radians(?) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(?) ) + sin ( radians(?) ) * sin( radians( latitude ) ) ) ) as distance", [$latitude, $longitude, $latitude])
            ->having("distance", "<", $request->distance)
            ->orderBy('distance', 'asc')
            ->offset(0)
            ->limit(20);

        $data = $query->get();
Activity icon

Replied to How To Convert Following Sql Query To Laravel Query Buillder?

@ssquare accourding to your updated code, your having should be removed from the ->select() clause, to a ->having() clause:

        $query  = DB::table('branch')
            ->select(
                'id',
                'name',
                \DB::raw('( 3959 * acos ( cos ( radians(?) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(?) ) + sin ( radians(?) ) * sin( radians( latitude ) ) ) ) as distance')
            )
            ->having("distance", "<", $request->distance)
            ->orderBy('distance', 'asc')
            ->offset(0)
            ->limit(20);

        $data = $query->get();
Jun
26
4 months ago
Activity icon

Replied to Call To A Member Function Save() On Array

It should work. please send here the current code and a JSON of $data

Activity icon

Replied to Call To A Member Function Save() On Array

$document var is actually not a model, but a models array. you should save the model in $document var, save it, and then add it to a $documents array

        // Before the foreach
        $documents = [];
        
        // Inside foreach
        $document = new Document(array(
            'user_id'=>$request->get('user_id'),
            'doc_type' => $files,
            'doc_path' => $picName,
        ));
        $document->save();
        $documents[] = $document;

another option is to use the tap() helper, like:

        $document[] = tap(new Document(array(
            'user_id'=>$request->get('user_id'),
            'doc_type' => $files,
            'doc_path' => $picName,
        )), function ($document) { $document->save(); });
Jun
18
4 months ago
Activity icon

Replied to Call To A Member Function ToArray() On Null

@SWIMMER - It depends on your implementation. how do you call it?

Are there situations when you have no Menu model for this $url? If no, do you check that the getAll() result is an array before you iterate it? if you iterate it at all

Jun
17
4 months ago
Activity icon

Replied to Unable To Do Php Artisan Migrate

I'm not familiar with the mysqlnd extension, but I check the php.net (https://www.php.net/manual/en/mysqlnd.install.php) page and noticed this:

The MySQL database extensions must be configured to use the MySQL Client Library. In order to use the MySQL Native Driver, PHP needs to be built specifying that the MySQL database extensions are compiled with MySQL Native Driver support. This is done through configuration options prior to building the PHP source code.

As I can see, you have no other DB extention, mysqli for example

Activity icon

Replied to Unable To Do Php Artisan Migrate

I noticed some issues in StackOF, all of them pointing to the mysqlnd extension. Please check your php-mysqlnd extension is updated to your php version, and loaded properly by Apache. Restart Apache if needed.

Activity icon

Replied to Unable To Do Php Artisan Migrate

Are you using a debugger?

Activity icon

Replied to Unable To Do Php Artisan Migrate

Please set the DB_CONNECTION value in your env file to lower case, as there is no 'MySql' key in your connections array

Activity icon

Replied to Call To A Member Function ToArray() On Null

You need to use ->first(), to actually fetch the record from the database, but with no ->toArray() function. Please try this:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class content extends Model
{
    static public function getAll($url){
        if($menu = Menu::where('url', '=', $url)->first()) {
            $content = Content::where('menu_id', '=',$menu->id)->get()->toArray();

            return $content;
        }
        
        return [];
    }
}
Activity icon

Replied to Call To A Member Function ToArray() On Null

I don't understand the logic here, but it seems like you try to do a Menu existing validation, but the validation breaks when there is no Menu and the first() function returns null. so please try to remove the first toArray()

Activity icon

Replied to Multiple Model Updating

@CHRISTOPHHARMS - @keizah Both databases should work with no backticks at all:

$neighbours = Category::where('left', '>', $category->right);

$neighbours->update([
    'left' => DB::raw('left+2'),
    'right' => DB::raw('right+2'),
]);

@ChristophHarms This is not a Collection, the $neighbours variable is still a QueryBuilder as it didn't use the get() method.

Jun
11
5 months ago
Activity icon

Replied to Query Builder To Collection Of Models.

why not using

ModelClass::query()->select

?

if you want to use the hydrate function you can use it like

ModelClass::hydrate($results->toArray())
Jun
10
5 months ago
Activity icon

Replied to Where Clause Depending On Column Value

the when clause is for PHP boolean and not being interpreted in SQL. Please try to set the DB::raw inside the the Join clause

->join("person_fields", function(\Illuminate\Database\Query\JoinClause $join){
                        $join->on('person_fields.name','Name')
                             ->where('person_fields.person_type','Family Member')
                             ->whereRaw('person_vatas.member_id IS NOT NULL');
                        });
May
15
6 months ago
Activity icon

Replied to Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message Why?

Did you make sure the routes files are not cached? Please run 'php artisan route:clear' and try again