dianikol85

dianikol85

Member Since 5 Years Ago

Experience Points 8,225
Experience Level 2

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

03 Mar
4 years ago

dianikol85 started a new conversation Inserts And Updates From Large Xml File

Hi to all :)

The use case is this. Every morning I need to insert or update if the row exists according to a xml which is around 100mb - 200mb. Currently i have a cron job to hit a request.

I use the XMLReader library to parse the xml since it is more efficient than simplexml.

Nevertheless those are a lot of data to get imported all at one request since even 256mb of memory is not enough.

Can you give me any direction about how I should do this?

Here is a code snipet:

$reader = new \XMLReader();
        $reader->open('largeXML.xml');
       // find the <product></product> item tag
        while ($reader->read() && $reader->name !== 'product');
        while($reader->localName === 'product'){
            $node = new \SimpleXMLElement($reader->readOuterXML());
        // Call the insertProduct() method from my model
        $this->product->insertProduct($node);
            $reader->next('product');
        }

Thank you in advance

17 Feb
4 years ago

dianikol85 left a reply on FirstOrNew With Query Builder

@JarekTkaczyk Ok i,see. I'll try something like your example

Thank you

dianikol85 started a new conversation FirstOrNew With Query Builder

Hello to all geeks :)

is there a method like firstOrNew in eloquent but to use it with query builder instead of eloquent. The reason is i have some meta data tables where i don't need to set relationships and stuff

Thank you

17 Oct
4 years ago

dianikol85 left a reply on Use Eloqiunt Scopes In Repositories

@keevitaja I have the same feeling about this after a lot of research. At least for data storage system repos seems a little overkill.

As @mantasmo said if for some reason you need to swap eloquent you need to write all the code about data saving, retrieving and such

More convenient usage of repos is for example swapping billing or mailing services.

Maybe I miss something...

09 Oct
4 years ago

dianikol85 left a reply on Use Eloqiunt Scopes In Repositories

Some times or most of the times you don't know if your app is going to need a different data storage implementation. So we start using a repo in order to be future proof.

So a lot of eloquent cool features like chaining using scopes is useful only when we use eloquent itself so no repos required at all. :(

dianikol85 left a reply on Use Eloqiunt Scopes In Repositories

@pmall I agree with that, but like @RayRutjes said some method could end up really ugly. That way using a repo seems to loose some cool stuff like chaining methods

dianikol85 left a reply on Use Eloqiunt Scopes In Repositories

@RayRutjes thank you for the article.

I still don't understand chaining the methods is a bad idea. Even if I change the eloquent to mongoDB for example i could with that repository as well.

I don't say what id is the right way but i don't understand why is wrong. :) I mean the chaining

08 Oct
4 years ago

dianikol85 left a reply on Use Eloqiunt Scopes In Repositories

@Valorin Thank you for your replies.

I see your point there but what if you want a slightly different results? Should i write a method that almost returns the same results? Like your example lets say we need the products on sale for the current week

Wouldn't be better to filter the results according to a change - products on sale this week for this case. I imagine it like that:

In my controller

// It returns all products that are on sale
return $repo->productsOnSale->get(); 

// It returns all products that are on sale this week
return $repo->productsOnSale->currentWeek()->get();

// It returns all products that are on sale today and cost under 10 dollars
return $repo->productsOnSale->addedToday()->whereCostUnder(10)->get();

That way i only have to implement the method that adds a condition and not write the same thing again again.

It looks more readable and flexible that way. At least to me.

dianikol85 left a reply on Use Eloqiunt Scopes In Repositories

I just use it as an abstraction layer for one of my models

dianikol85 started a new conversation Use Eloqiunt Scopes In Repositories

What is the proper way to use eloquent scopes in a repository?

Thank you

04 Oct
4 years ago

dianikol85 left a reply on Send Email From Gmail Account

Did you check in the "laravel.log" file if it has any errors?

02 Oct
4 years ago

dianikol85 left a reply on Laravel 4 Or Laravel 5?

You won't face any serious probs. The existing tutorials are applicable. In fact I re-done the almost all of them without any problem.

The folder structure i think is even more flexible than before and you have some great new features like form validation, so you don't need to implement a sophisticated approach all by yourself.

Since you want to build an api for iOS app try to do the "Incremental APIs" series using the L5 version to see what changes. Not that much i guess.

30 Sep
4 years ago

dianikol85 left a reply on Debug Eloquent Queries

Put this in routes.php

Event::listen('illuminate.query',function($query){
    var_dump($query)
});
27 Sep
4 years ago

dianikol85 left a reply on Laravel 5 Relationships

Nop it will not work because you are not using it in the task model/entity. Only when you declare the relationship in order to eloquent know how to instate it behind the scenes

26 Sep
4 years ago

dianikol85 left a reply on Laravel 5 Relationships

In the controller it is pretty much obvious that you need the namespace for it to work.

the difference between L4 and L5 is that you need use the namespace in the relationship too like that

class Task extends Model {

 protected $fillable = ['title','body','user_id','completed'];

    public function user() {
        return $this->belongsTo('App\User');
    }
}

Unless i miss something else

dianikol85 left a reply on Laravel 5 Relationships

Yes, you are right. It needs to add the namespace instead of the just the class name.

dianikol85 left a reply on Laravel 5 Relationships

The 'User' class is the default model. It initiated behind the scenes by eloquent i guess

dianikol85 started a new conversation Laravel 5 Relationships

I'm trying to reproduce the "Digging in" series using laravel 5 but having issues with relationships

class User extends Model implements UserContract, RemindableContract {

    use UserTrait, RemindableTrait;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password', 'remember_token'];

    protected $fillable = ['username','email','password'];

    public function tasks() {
        return $this->hasMany('Task');
    }

}

class Task extends Model {

    protected $fillable = ['title','body','user_id','completed'];

    public function user() {
        return $this->belongsTo('User');
    }
}

 public function show($id)
    {

        try {
            $task = $this->tasks->findOrFail($id);

            return $task->user;
        } catch (ModelNotFoundException $e) {
            return ':(';
        }
    }

It gives me that error

Class 'User' not found
24 Sep
4 years ago

dianikol85 left a reply on Laravel 4 Or Laravel 5?

Yes , i just missed a few...

dianikol85 left a reply on Laravel 4 Or Laravel 5?

Yes I just read about it. No reason to stick to l4 folder structure I guess. L5 is cleaner and more consistent.

Jeffrey should create a more dedicated vid about service providers since l5 heavily uses them :)

23 Sep
4 years ago

dianikol85 left a reply on Laravel 4 Or Laravel 5?

Thanks for the quick reply Jeffrey. I was thinking the same. I don't mind the different folder structure anyway. It looks more clear and makes it more framework agnostic to me at least.

dianikol85 started a new conversation Laravel 4 Or Laravel 5?

Hey to all!!

I think many people are in this situation ,me included, where browsing around laracasts for the last one or two months studying laravel 4 but not build something for production market.

We just try to learn all these modern techniques like interfaces and such using laravel 4. Laracasts videos are for the 4 version.

Me for example i'm learning laravel 4. Should i drop it until 5 is out??

You get the dilemma :)

01 Sep
4 years ago

dianikol85 left a reply on About The Iterate Anything Lesson. Why All Those Interfaces??

Thank for your responses guys!

I think i see the bigger picture now. I think the biggest benefit is that it ensures things will work as expected by adding an interface to your class and maybe the same interface to another class.

The other benefit is of course, swap up implementations without breaking code in other places within your app.

31 Aug
4 years ago

dianikol85 left a reply on About The Iterate Anything Lesson. Why All Those Interfaces??

So, you mean that interfaces in this case also play the role of a guide in order to inform another user what he/she want to swap up that class

dianikol85 started a new conversation About The Iterate Anything Lesson. Why All Those Interfaces??

I still not quite get why did you use all these interfaces. After all we could achieve the same goal without these contracts.

For a example: the Collection class implements JsonableInterface in order to force me to write the toJson() method. I already know i want the Collection class to provide that functionality.

It's not like i am going to swap the Collection class with a mine one so the need of implementing these interfaces is mandatory.