kima

kima

Member Since 1 Year Ago

Experience Points 980
Experience Level 1

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

18 Jun
17 hours ago

kima left a reply on 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

17 Jun
1 day ago

kima left a reply on Unable To Do Php Artisan Migrate

I'm not familiar with the mysqlnd extension, but I check the php.net 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

kima left a reply on 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.

kima left a reply on Unable To Do Php Artisan Migrate

Are you using a debugger?

kima left a reply on 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

kima left a reply on 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 [];
    }
}

kima left a reply on 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()

kima left a reply on 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.

11 Jun
1 week ago

kima left a reply on Query Builder To Collection Of Models.

why not using

ModelClass::query()->select

?

10 Jun
1 week ago

kima left a reply on 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');
                        });
15 May
1 month ago

kima left a reply on Undefined Index

please fix the 'id_skill' to 'is_skill' in the validator

kima left a reply on 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

05 May
1 month ago

kima left a reply on Merging Two Queries With Eloquent

You have 2 options.

You can set a variable that will reference to the QueryBuilder, do your logic and then apply more clauses on the variable and get the result

$builder = Ad::query()
            ->whereHas('book', function (\Illuminate\Database\Eloquent\Builder $query) use ($book_id) {
                $query->where('book_id', $book_id);
            });
        
        if (true) {
            $builder->whereHas('authors', function (\Illuminate\Database\Eloquent\Builder $query) use ($checkbox) {
                $query->whereIn('ad_service.author_id', $checkbox);
            });
        }
        
        $result = $builder->get();

Another option is to use the when function

            ->whereHas('book', function (\Illuminate\Database\Eloquent\Builder $query) use ($book_id) {
                $query->where('book_id', $book_id);
            })->when("some condition", function (\Illuminate\Database\Eloquent\Builder $query) use ($checkbox) {
                $query->whereHas('authors', function (\Illuminate\Database\Eloquent\Builder $query) use ($checkbox) {
                    $query->whereIn('ad_service.author_id', $checkbox);
                });
            })->get();```
12 Feb
4 months ago

kima left a reply on Automatic Injection On Anonymous Functions?

how does $factory getting instantiated?

It uses Laravel dependency injection. It is important to read this article to understand: https://laravel.com/docs/5.7/container

Faker\Generator and Eloquent\Factory have to be constructed with required parameters, and Laravel doing this for you in a singleton pattern. When you just use 'new Faker()' you are not set these parameters!

Laravel registers (instantiated) the Faker\Generator and Eloquent\Factory in DatabaseServiceProvider::registerEloquentFactory() function. Whenever the application needs a Faker\Generator, it would inject the instance that was set.

How does the closure getting called?

As you see, the $factory->define() function saving the $attributes (actually an anonymous function) in the singleton under 'definitions' member (and already has 'faker' member)

When you using the factory() helper, it uses the Illuminate/Database/Eloquent\Factory::of() function. in the end, it is calling Illuminate/Database/Eloquent/FactoryBuilder::getRawAttributes(). this function calls your anonymous function with the 'faker' member, which is the Faker\Generator singleton

kima left a reply on Automatic Injection On Anonymous Functions?

It is not an Automatic Injection

The $factory is an Eloquent\Factory class, that has a 'faker' member that was set in the constructor. When your app is trying to resolve the defined class, it injects the 'faker' member to the anonymous function.

The default faker is set in DatabaseServiceProvider

If you just want a faker instance, you can use app(\Faker\Generator::class);

24 Dec
5 months ago

kima left a reply on Database Tables Created Without Migration

Receive the Model table name by $table member with fallback by the class name:

with(new static)->getTable() When static is a Model

17 Dec
6 months ago

kima left a reply on Filesystem Disk Per User

@MOENCHFRACHT - I don't see it part of a service provider and not using guards to detect the user, as I assume that the system admin should reach this storage although he is not logged in to the specific user, or using multiple user's storage paths in one session

in this case, I would just add it in the User class or creating a factory for this.

public function getStorageInstance()
    {
        $dir = storage_path('app/public/'.$this->name.'/');
        // Make sure the storage path exists and writeable
        if (!is_writable($dir)) {
            mkdir($dir, 0777, true);
        }

        return Storage::createLocalDriver(["root" => $dir]);
    }

kima left a reply on Filesystem Disk Per User

I prefer to not use variables in the config files as I cache them in Production environments.

Try using Storage::createLocalDriver(["root" => storage_path('app/public/'.\App\Auth::user()->name.'/')]);

You might create a function that returns you a storage instance for a user. the function can handle the directory creation and directory permissions also.