KenoKokoro

KenoKokoro

Member Since 2 Years Ago

Skopje

Software Developer at Lenidium

Experience Points 51,760
Experience Level 11

3,240 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 442
Lessons
Completed
Best Reply Awards 12
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.

12 Nov
1 year ago

KenoKokoro left a reply on Spark And Existing Laravel Project

@ejdelmonico Yea, in theory I totally agree with you, in theory this all should be fine ( of course without touching the Spark code )

But my actual question was has actually anyone did it by now?

11 Nov
1 year ago

KenoKokoro started a new conversation Spark And Existing Laravel Project

I found out some tips about integrating Spark into existing Laravel project, but I never find out if someone has actually done it, and how difficult is it? As I can see in Taylor's series about Spark, it has totally different folder so in my opinion it shouldn't be issue to just copy - paste the spark folder into existing project and just tweak service providers or whatever. But in contrary I see that in the Spark's FAQs that it clearly states that the Spark is not designed to be integrated into existing projects.

So, is it doable, how hard is it, and has anyone actually did it? Cheers.

23 May
2 years ago

KenoKokoro left a reply on [Illuminate\Database\QueryException] SQLSTATE[HY000]: General Error: 1005 Can't Create Table `pgaiiis`.`#sql-8e8_1ab`

Your foreign key should be the same type as the key you are referencing. So if you are referencing the id on some table, your foreign column should be unsignedInteger not tinyInteger, or anything different than the key you are referencing.

Try changing :

$table->unsignedTinyInteger('section_id');

To:

$table->unsignedInteger('section_id');

KenoKokoro left a reply on Schedule Command Cron Is Not Working On Goaddy

What is your configuration it should be something like:

* * * * * php -q /home/username/public_html/sub_folder/project/ artisan schedule:run >> /dev/null 2>&1 

To execute it every single minute.

Also if you have ssh access, check the /var/log/syslog, cron is logging there.

18 May
2 years ago

KenoKokoro left a reply on Get Request To Laravel Api Route Not Working In Custom Package

What do you have in your api middleware? Also how is your routes.php file included?

Can you paste the RouteServiceProvider where the routes.php is registered, and the api middleware as well ?

KenoKokoro left a reply on Login Suddenly Returning "These Credentials Do Not Match Our Records."

Check if you have overwritten the username() method from AuthenticatesUser trait.

Also what I can think of is, maybe the user ID is not 'id' is changed or something?

KenoKokoro left a reply on Error Sending Email Using Smtp.google.com

@Ajo_doctorslink

Try chainging MAIL_DRIVER=mail

Don't forget to clear the config cache before testing it out.

php artisan config:clear

KenoKokoro left a reply on Custom Package's Dependency Not Installing

@RICUS I am no sure, but shouldn't your package be on your composer.json file on the require section? And from there you will have your psr-4 autoload in the package composer.json file

I believe this is how it should work..

25 Apr
2 years ago

KenoKokoro left a reply on Creating A Session

Yes you are right but as you can see:

               if(auth()->guard('customer_admin')->user()->is_activated == '0')
                {
                    $this->logout();
                    return back()->with('error', 'Please activate your account');
                }

Here it is where you call the logout. At this time the session is not set. Maybe what you can try is:

  1. Open tinker
  2. Session::put('car_session', 'test data');
  3. Try to login again, you should have something in this session key.
24 Apr
2 years ago

KenoKokoro left a reply on Login Landing Page

You have the files, you can do whatever you want with the views. They are located on resources/views/auth folder.

KenoKokoro left a reply on Creating A Session

As I can see, the cart_session is not set when you call the logout method. You try to access it before you set it.

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

@klaaz Did you found a way to fix this? What was the issue?

If not, maybe you have redirect to you en domain, and then middleware makes additional redirect to your locale or something like that. I am not sure about your structure.. just guessing..

21 Apr
2 years ago

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

I believe that you are making additional redirect or something that is clearing the flush messages.

Try something like, log every entry on your app in file using Log::info('entry') for example, and see what is going on.

I believe that index.php is the best place.

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);
Log::info('hit');

Line :55

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

Also, check if you are making additional redirect after the validation fails, because the flash errors from validation will be deleted on that redirect.

I hope this helps a bit.

I am running out of ideas.

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

Well, if so, I guess the issue is in the session, since the flash messages are from the session.

Try on your view where you login form is to dump and the the session. If the session is fine, you should see the flash messages there after the validation fails.

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

As I said, try dump and die the message bag in, or using postman, send post request and see if you get any output here regarding the validation.

Don't forget to set the Accept header to application/json

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

Also what I can think is try using

dd($validator->getMessageBag()); 

On the ValidatesRequest trait on :105 line, and see if there is any output here.

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

Are you using same routing file for both cases? Just changing the locale? Which laravel version?

My guess is that this seems to not go through the web middleware, and therefore no session is set.

Can you confirm this?

KenoKokoro left a reply on Empty Error (messagebag) After Switching Connection

There is no errors in the session?

I guess you need to have another folder with your locale located in resources/lang.

For example for validation you will need: resources/lang/de/validation.php

You need your translations here.

31 Mar
2 years ago

KenoKokoro left a reply on Laravel Mail

Check your .env file, you should change the QUEUE_DRIVER variable to not be sync anymore.

If this is not the solution, paste some code, and what queue driver do you use?

KenoKokoro left a reply on Calling A Route From Javascript

Are you using some package for returning the json data from laravel to client side?

If so, I often use this package: https://github.com/yajra/laravel-datatables

So I am able to generate the edit/delete/view buttons from backend. I want to have this stuff centralized on my backend, and this is where I put this kind of logic.

I am adding new column ( for example: actions ), and put all buttons here, you have here everything you need, access to the named routes, data needed. Check example from the docs here: https://yajrabox.com/docs/laravel-datatables/master/add-column

KenoKokoro left a reply on How Do You Retrieve The Last BelongsToMany Relationship For Two Models

I see now. You can't order using Eager Loading. Join the table you want to order.

KenoKokoro left a reply on How Do You Retrieve The Last BelongsToMany Relationship For Two Models

I believe that the datatables is making your ordering. Check there first.

30 Mar
2 years ago

KenoKokoro left a reply on Save A HasOne Relationship Change

Asuming we have something like this in our User.php :

public function image()
{
     return $this->hasOne(Image::class);
 }

Saving if you have the image instance

        $image = factory(Image::class)->create();
        $user = factory(User::class)->make();

        $user->image()->save($user);

Creating image for user from request

        $attributes = $request->all(); # Asuming this contains the image attributes
        $user = factory(User::class)->make();

        $user->image()->create($attributes);

Updating image for user from request

        $attributes = $request->all(); # Asuming this contains the image attributes
        $user = factory(User::class)->make();

        $user->image()->update($attributes);

If you need some modifications on the input data just call like you do, some method, and get needed data:

        $attributes = $this->imageAttributes($request->all);
        $user = factory(User::class)->make();

        $user->image()->create($attributes);
...

protected function imageAttributes(array $request) 
{
    # Doing needed logic, using if, switch etc.. whatever you need to set the $file varibale
    return [
        'file' => $file
        ];
}

Am I getting the point?

Hope this helps.

KenoKokoro left a reply on Save A HasOne Relationship Change

Why not:

# To create
$action->checklistItem()->create($attributes)
# To update
$action->checklistItem()->update($attributes)
# Or if you have the model instance
$action->checklistItem()->save($model)

Where $attributes is an array of already generated attributes

KenoKokoro left a reply on Calling Post Action | Response With 404

action('[email protected]')

Shouldn't this be namespaced?

KenoKokoro left a reply on API Auth

Is the token generated only once when the user gets created or does this token change?

  • The token will change, when it will expire ( if you are building web app )

So everytime somebody makes a request to my API he only sends the token instead of username and password?

  • This is correct. User should be authorized with the token provided

For managing the token try this package: https://github.com/tymondesigns/jwt-auth

You have middleware included, and helper methods that will do the trick on authenticating/retrieving the user

Also you will have to define your routes in the api.php instead of web.php, in order to avoid the web middleware.

Hope this helps.

KenoKokoro left a reply on Authenticating From A Custom Table - HOWTO With Laravel 5.3?

First of all, I don't see any reason why not to use the users table as your primary table. Maybe just add foreign key in your player table to point to the user table and add your player info here, and keep the user authentication info on users table ( This seems more suitable according to me )

But.... if you really need another table check this out:

You need to set new provider in config/auth.php file.

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],

Set your desired model here, and as I can see, your primary key is not 'id', you will also have to update:

    /**
     * The primary key for the model.
     *
     * @var string
     */
    protected $primaryKey = 'id';

In your model.

Also you Model would have to extend the Illuminate\Foundation\Auth\User class, in order to be authenticable.

I believe that you will have to make additional tweeks because of reset password table interactions with your new table ( also in the auth.php file ).

Search for usages of the User model class, you will most probably have to replace all instances with your current model.

KenoKokoro left a reply on Need Query

Use eloquent relations and maybe use:

Category::with(['Child.Child.Child'])->get()

Like this you can add as much as you want, and get the nested children categories.

KenoKokoro left a reply on Eloquent Query Not Working

@MrRobot21

In you sql query you use:

LIKE "A%"

But in the eloquent you use:

->where('first_name', 'like', '%'.$alphabet.'%')

That's why you have different results. $letter% means everything that starts with $letter. %$letter% means everything that contains $letter.

Hope this helps.

KenoKokoro left a reply on Eloquent Query Not Working

->limit(5)->offset($limit)

Are you sure this are correct?

13 Mar
2 years ago

KenoKokoro left a reply on QueryException In Connection.php Line 647:

Is event_id set in your model fillable array ?

KenoKokoro left a reply on Export Large Excel/CSV (10-20K Records)

Make chunks of the files. I have been using this to export over 100k rows from database into excel files

const MAX_CHUNK_ROWS = 2500;

...

while ($current < $backupRowsCount) {
            $next = $current + self::MAX_CHUNK_ROWS;
            if (is_array($this->exportData)) {
                $chunk = array_slice($this->exportData, $current, self::MAX_CHUNK_ROWS, true);
            }
            else {
               $chunk = $this->exportData->slice($current,self::MAX_CHUNK_ROWS, true);
            }
            $command->exportName .= "{$current}_{$next}";
            $command->exportData = $chunk;
            $command->exportFile();
            $current += self::MAX_CHUNK_ROWS;
            $percent = ($next / $backupRowsCount) * 100;
            $this->comment("{$next} rows exported to {$command->exportName} [{$percent}%]");
            $command->exportName = $oldExportName;
        }

KenoKokoro left a reply on Array Check Box Not Selected When Get Validate Fail

Try using in_array($key, old('country_id')) instead of array_has

KenoKokoro left a reply on Call Method From Another Component

Try using events to communicate between components. https://vuejs.org/v2/guide/components.html#Using-v-on-with-Custom-Events

https://laracasts.com/series/learn-vue-2-step-by-step/episodes/12 https://laracasts.com/series/learn-vue-2-step-by-step/episodes/13

The point is, you fire an event, and it will trigger only on the component that is listening to that event. You can call the method in your listener.

KenoKokoro left a reply on Route Group Returning 404 Error

Check if you have some other routes with wildcard parameter, that can overwrite the current route.

KenoKokoro left a reply on JWT Auth Not Expiring Token

Just copy the config.php from the package to jwt.php in your config folder. That's what worked for me.

KenoKokoro left a reply on Laravel Passport Client_credentials

@shintaro What usually works for me is :

Set body as raw and select on the dropdown JSON ( which will also provide formating and syntax on the input inside ), set the Accept header to application/json and Content-Type application json

10 Mar
2 years ago

KenoKokoro left a reply on Imput Type Number

I believe in this case it won't be handled by the html5 because it is not a form as I can see, he is not submitting anything, just redirecting to the url which is triggering the update, which is a really bad practice of course ( as you mention it ).

I believe that he is really a beginner so he have time to learn. He will learn from his mistakes. Just baby steps, no rush I would say. :)

KenoKokoro left a reply on Imput Type Number

$(".btn-update-item").on('click', function(e){
    e.preventDefault();
    
    var id = $(this).data('id');
    var href = $(this).data('href');
    var quantity = $("#product_" + id).val();

    if(quantity < 1 || quantity > 100 ) {
        // show some error using jquery
    } else {
        // do whatever you need to
    }

    window.location.href = href + "/" + quantity;
});

KenoKokoro left a reply on Pulling In A Vendor Package?

You can register the service provider on bootstrap/app.php, you have an example there.

Or in the providers folder, you can create your own ComposerServiceProvider that extends the illuminate Service provider, and just register them in the register method: $this->app->register(PackageServiceProvider::class);

Up to you.

KenoKokoro left a reply on Imput Type Number

Why you just don't check the quantity value on your click: Some thing like

if(quantity < 1 || quantity > 100 ) {
 // show some error using jquery
} else {
 // do whatever you need to
}

KenoKokoro left a reply on Trying To Clean Up A God Object And Failing

@jgravois Just checked the video.

You need to call the method with the string:

$co = Company::find($id);
return $co->updateQuantumWithFinalInfo()->update_quantum();

No need for __toString()

KenoKokoro left a reply on Trying To Clean Up A God Object And Failing

You need to imlpement __toString() method, in case to return the string.

The exeption says it for you. The Response content must be a string or object implementing __toString()

Or, double check the videos, maybe the QuantumPusher is extending some class that is already implementing the __toString() method.

KenoKokoro left a reply on Imput Type Number

Change

 $(".btn-update-item").ready(function(e){

To

 $(document).ready(function(e){

KenoKokoro left a reply on How To Increment Column On Record Save?

So if you change this: if (isset($location)){ if ($location->locatable_id = $device->id) { $location->count++; } } to: if (isset($location)){ if ($location->locatable_id = $device->id) { $location->increment('count'); } }

Doesn't work?

KenoKokoro left a reply on The Only Supported Ciphers Are AES-128-CBC And AES-256-CBC Error

In your config/app.php you should have something like : 'cipher' => 'AES-128-CBC'

and run php artisan key:generate, should do the trick.

Also try clearing the cache: php artisan cache:clear

KenoKokoro left a reply on Imput Type Number

You need to initialize the validation before the click event. Try wrapping it in $(document).ready(function() {// validation here})

Also, do you have single item here, since if your html is in iteration you won't be able to use the $item variable.