RuRu

RuRu

Software Developer at Kofoed & Co

Member Since 4 Years Ago

Experience Points
4,840
Total
Experience

160 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
61
Lessons
Completed
Best Reply Awards
0
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
4,840 XP
07 Mar
2 years ago

RuRu left a reply on React Not Transpiling Under Larave-mix

Worked as intended, thanks for the assistance @ejdelmonico, appreciated! :) Much better to write your own one, then rely on libraries to handle everything for you.

02 Mar
2 years ago

RuRu left a reply on React Not Transpiling Under Larave-mix

I have tried adding .babelrc and updating to the latest version, but it didnt do anything. Maybe I am doing something wrong, but I find it confusing.

Could you share your webpack.config.js on setting up react?

01 Mar
2 years ago

RuRu left a reply on What Frontend Framework Would You Choose For A Slick Web App?

I would say it really depends on your existing knowledge and expertise with JavaScript.

In my company we use Angular, but having many issues with it. It is not very easy to manage when the complexity of the application gets bigger. Also it is a constant battle with keeping it to the latest best practices, in case we decide to move to Angular 2. For a new app I would not recommend Angular, and the new way of building client side is to take the component based approach.

In my personal experience, React does it very well, and is much lighter then Angular 2, and can be plugged in with Redux which is great.

I think it is simple to start and get going with React, there is good material for learning it as well, and complexity shouldn't be anything near to Angular.

RuRu started a new conversation React Not Transpiling Under Larave-mix

Hey guys, how do I laravel-mix to compile jsx/js special syntax like

return {...state, all: action.payload.data};

this is what I have in my webpack

 mix.react('resources/assets/js/react-app/index.jsx', 'public/react-app/js')
       .sass('resources/assets/sass/app.scss', 'public/css');

What am I missing to get it to transpile properly?

28 Feb
2 years ago

RuRu left a reply on Laravel Mix And React Js

I have done what was suggested by @JeffreyWay and for me it blows up on this like when it tries to parse my react files.

return {...state, all: action.payload.data};

I suspect that it does like ...state? But how do I get laravel-mix to handle this?

26 Feb
2 years ago

RuRu started a new conversation Setting Up React With Laravel

Hi people, I am curious to find out how people set up react with Laravel. What is interesting is how people use Laravel and react in production. So far I am having trouble setting both up, and the question that comes up is what is the best approach for it?

One way is to use React with blade.php and rely on third party libraries to get things done. In this case, is this the right way to go? Would then we use react routes or stick to Laravel routes?

Other option is to use react as a stand alone front end client and have Laravel as an REST API. This approach seems more easier to set up. But how would one distingiush routes and end points? Like /client and /api? In a Java world, like we would define a web.xml file for a servlet to handle requests. How can I set this up in Laravel?

25 Aug
4 years ago

RuRu started a new conversation Restricting List/collection In Has-Many Relationship

I want to find out on how to implement a validation rule were I can define a limit to how many relationships this entity can have.

For instance, let say we have a team and we want to associate employees with that team. But we don't want to keep adding new employees to that team and have it overflowing. Adding a limit of 8 employees per team would be feasible.

Currently, I don't know how to implement that in laravel with php. How would someone go about it?

RuRu left a reply on Similar Framework To Laravel But Must Be Java Based.

@aliqsyed Play Framework is definitely good and I enjoy using it. But when it comes to the job marker, spring is the leader. Also when you compare these two frameworks, they different in how they work and perform. Play Framework is a lot slower then Spring. Which is also something to take into consideration.

Nonetheless, I would suggest looking into Spring Boot. That is definitely a step forward for Java, and Grails 3.0 utilizes it quite well.

20 Aug
4 years ago

RuRu left a reply on Form Model Binding Relations - How To Bind/populate Relations In A Form?

This is not something I thought would be uncommon. At my job we use more then one model or three models in a form, and as I can see that with the complexity of the websites raising, it would make sense.

The easiest, less stressful solution is to make more partials and forget about "dry" principle for this part, as it's not something I am able to figure out or implement with my lack of skills and experience.

@ShaunL Not a bad proposal, but it's much worse were I have to deal with returning a collection of skills under one table. It makes a query a lot more mess and harder to write. Otherwise it would definitely work in a bit similar use cases, and a bit more validation when saving/updating.

19 Aug
4 years ago

RuRu started a new conversation Form Model Binding Relations - How To Bind/populate Relations In A Form?

I have a form extracted in a partial which is dealing with three different models. Employee, Address and Skills. I can save all three and thats fine. The issue is editing.

I model bind the employee on my edit page and it populates only the employee fields, leaving the rest blank.

{!! Form::model($employee, ['method' => 'PATCH', 'action' => ['EmployeeController@update', $employee->id]]) !!}

I have to do custom logic to get the skills bound. It works fine within edit and create page. But to bind Address I have to do it manually, and it breaks my create page. Where the goal is to reuse the forms partials.

Simple solutions is to make few more partials and deal it manually. But there has to be a way to automate this, which would prevent boiler plate code which we all dont want to write.

So what am I missing and how can I do what I am attempting to do?

Here is what I have

Form

<fieldset>
    <legend>Employee Details</legend>
    <div class="col-md-6">
        <div class="form-group">
            {!! Form::label('first_name', 'First Name:', ['class' => 'col-md-3 control-label']) !!}
            {!! Form::text('first_name', null, ['class' => 'form-control']) !!}
        </div>

        <!-- Last Name Form Input -->
        <div class="form-group">
            {!! Form::label('last_name', 'Last Name:', ['class' => 'col-md-3 control-label']) !!}
            {!! Form::text('last_name', null, ['class' => 'form-control']) !!}
        </div>


        <div class="col-md-6 col-md-offset-2">

            <label>Select your competences</label>

            <div class="form-group">
                @foreach($skills as $skill)
                    <br/>
                    {!! Form::label('skill', $skill->skill, ['class' => 'col-md-10 control-label']) !!}
                    @if(isset($employee))
                        {!! Form::checkbox('skill[]', $skill->id, $employee->hasSkill($skill->id)) !!}
                    @else
                        {!! Form::checkbox('skill[]', $skill->id) !!}
                    @endif

                    {{--<input type="checkbox" name="skill[]" id="{{$skill->id}}" value="{{$skill->id}}" @if($employee->hasSkill($skill->id) checked @endif>--}}
                @endforeach
            </div>
        </div>
    </div>
    <br/>

    <legend>Address Details</legend>
 
        <div class="col-md-6">
            <!-- Street Form Input -->
            <div class="form-group">
                {!! Form::label('street', 'Street:', ['class' => 'col-md-3 control-label']) !!}
                {!! Form::text('street', null, ['class' => 'form-control']) !!}
            </div>

            <!-- House Number or Name Form Input -->
            <div class="form-group">
                {!! Form::label('house_id', 'House Number or Name:', ['class' => 'col-md-3 control-label']) !!}
                {!! Form::text('house_id', null, ['class' => 'form-control']) !!}
            </div>

            <!-- City Form Input -->
            <div class="form-group">
                {!! Form::label('city', 'City:', ['class' => 'col-md-3 control-label']) !!}
                {!! Form::text('city', null, ['class' => 'form-control']) !!}
            </div>

            <!-- Post code Form Input -->
            <div class="form-group">
                {!! Form::label('post_code', 'Post code:', ['class' => 'col-md-3 control-label']) !!}
                {!! Form::text('post_code', null, ['class' => 'form-control']) !!}

            </div>

            <div class="form-group">
                {!! Form::submit($submitButton, ['class' => 'btn btn-primary form-control']) !!}
            </div>
        </div>

</fieldset>

And my controller

  public function edit(Employee $employee)
    {
        $skills = Skill::all();
        return view('employee.edit', compact('employee', 'skills'));
    }
17 Aug
4 years ago

RuRu left a reply on Error Saving Many To Many Revelations

Thanks @bobbybouwmann it worked. I remember trying it previously, but it didn't work as intendant. Maybe it was different variable that I passed that wasn't an array of ints but something else.

RuRu left a reply on Error Saving Many To Many Revelations

Yes it is an array of ids that has been selected through the checkboxes [ "1", "2", "3" ]

Because they are surrounded with "" it gives me an error "SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list'"

I have no idea why, but that what it is. If I do $employee->skills()->sync([1, 2, 3], false); it will save without any issues.

RuRu started a new conversation Error Saving Many To Many Revelations

I have an issue when saving many to many using a sync method.

The error I am getting is "column doesn't exist" and it's true, it doesn't. I have found out why I get this error, and it's because the ids in the array are in "". When I try to input hard coded id's it's works fine. But when I get it from my form, it gives an error.

here is my code

public function save(AddressRequest $addressRequest, EmployeeRequest $employeeRequest)
    {
        $skills = Input::get('skill');

        $address = Address::create($addressRequest->all());

        $employee = Employee::create(
            ['first_name' => $employeeRequest['first_name'],
             'last_name'  => $employeeRequest['last_name'],
             'address_id' => $address['id']
            ]);

        $employee->address()->save($address);
        $employee->skills()->sync([$skills], false);

        return redirect('employee/list');
    }

How can I save this relations, without getting an error? I have tried removing the " from the array, but I wasn't able to. What am I missing, and how can I get the input array from the $_POST to work properly with the sync method?

16 Feb
4 years ago

RuRu left a reply on Using Relationships

@pmall @deringer Thanks ppl, and yeah I have it sorted, my foreign keys aren't a problem, I know about database and such, but I am prone to making easy mistakes in code which I honestly shouldn't, being with a Bsc degree in Computer Science (only graduated last September, so no industry experience yet, studying for Msc), and it seems like I make a lot. But it's only been a week of me plating with laravel and PHP in general. I touched it college once, but was put of it due to a bad a teacher. But with time I will get a hang of it, my mind is changing a bout PHP, especially when using good framework behind it :)

14 Feb
4 years ago

RuRu left a reply on Using Relationships

@JarekTkaczyk I have fixed my model so it have a semantic meaning, but now I have an error that I dont quite understand

FatalErrorException in cfd3a5f35c8fcdb2be21702310f46b7f line 9: Cannot access empty property

This happens when I try to display categories and products in the view

 @foreach($categories as $category)
                        <li>
                            <dt>{!! $category->name !!}</dt>
                            @foreach ($categories->$products as $product)
                                <ul>
                                    <li> {!! $product->name !!} </li>
                                </ul>
                            @endforeach
                        </li>
                    @endforeach

This happens specially with this like

@foreach ($categories->$products as $product)
                                <ul>
                                    <li> {!! $product->name !!} </li>
                                </ul>
@endforeach

The property is not null as it is seeded in the database, and I done test and my json object looks correct when I return just the veritable in the controller. Am I missing something?

RuRu left a reply on Using Relationships

Also why I cant just do

$model = Category;
$category = $model->product->all()

I have this method, but it's not being used directly?

RuRu left a reply on Using Relationships

@JarekTkaczyk @deringer @pmall Sorry guys, my logic was messed up and I did know that, but I wanted to test the actual code before making changes. But I have fixed the relations so it's now makes some scene..

This is my model classes

class Product extends Model {

    public function categories() {

        return $this->belongsTo('\App\Category');
    }
}   

class Category extends Model {

    public function product()
    {
        return $this->hasMany('\App\Product');
    }
}

In the controller I am doing as suggested by @deringer

$model = new Category();
$category = $model->with('products')->all();    

return view('products.products_retail', compact('category'));

However I still get issues in the view

  @foreach($categories as $category)
                        <li>
                            <dt>{!! $category->name !!}</dt>
                            @foreach ($category->products as $category)
                                <ul>
                                    <li> {!! $category->name !!} </li>
                                </ul>
                            @endforeach
                        </li>
                    @endforeach

I only need 1 to many relationship. So products can only belong to 1 category, but of course category has many products. I want to list all the products under a category

RuRu started a new conversation Using Relationships

I am pretty new to Laravel and trying to figure out how to use relationships and display them in a view accordingly. I am familiar how MVC pattern works and worked with .NET, but there differences with Laravel.

So, I have this DB were I have Categories and Products. Each one of them has a related model, were I can define relationships

Category belongTo Product. Product hadMany Category

I have a foreign key in the categories table to identify were which part of product it's from.

With SQL I can use a INNER JOIN and do something like that

SELECT categories.category_name, products.name, products.id as ProductID
FROM categories
INNER JOIN products
ON categories.product_id=products.id

But how do I do this with Laravel? I cant quite figure it out, and it shouldn't be difficult really.

Also, once I get this data, how would I display it in the view? Thinking of using foreach loop to into a product and then display all categories with the product_id or 1 and then 2 and so on.

Would like some explanation on how this works

12 Feb
4 years ago

RuRu left a reply on Laravel 4 Or 5

@toniperic Thanks for the input,. I will carry on with the L5 implementation of the website. So far there are few changes that I can see from L4 and L5 screencasts, which means I can adapt to the changes without a major issue. I do understand that L4 wont fade away any time soon, which isn't a problem.

I will get cracking with my website :)

RuRu started a new conversation Laravel 4 Or 5

I am new to this community and to laravel as well. Not so much experience with php either, mostly come from a .NET background.

But I want to try it out and got a client who wants a website. So far I really enjoying laravel framework. All though for this job, I dont know what to start with, how much of a difference is there between laravel 4 and 5? Should I stick to 4? I see most posts are about laravel 4. Does this mean laravel 5 is not stable, or what are the reasons?

RuRu left a reply on Article Seeder

Normally do you use seed class to populate real data? For instance I was asked to make a web site, and they give me a list of products, items and what not to be in the db. Would you use a seed class to get the data up and running on db? Otherwise, what is the best options to go about this? Make the owner/client do it by providing forms? Please point me to a right direction!