rikw

Experience

1,200

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 6 Lessons Completed
  • 0 Favorites

9th August, 2017

rikw started a new conversation Creating Complex Layouts • 1 week ago

Hi all,

In my quest for dry templates and code I'm looking for some assistance. My application has different sections from the main menu. Within these sections I'm thinking of either submenu of tabs in the main screen. Of course, I'd like to show the active items in menu/submenu and tabs.

How would I go and approach this? Create separate blade includes for the different menus and tab lists? Is there a way to give the current and active (where subpage is current) states to such templates?

Thanks for your thoughts!

rikw left a reply on Code Structure Behind Controller • 1 week ago

@goatshark In my perception repositories are in the middle of data/models and the application to provide flexibility in the future.

@d3xt3r Thanks for your straight forward approach. This is non reusable code and only serves this function. Utility might be a good one too. I think this is the same as Helpers (I'm from the Magento world).

rikw started a new conversation Code Structure Behind Controller • 1 week ago

Hi all,

Please assist me with some guidance on structuring my code behind controllers. I try to only use resource controllers. This works well and makes for a clear structure. Now the controllers of course need to collect data and dispatch actions. But how do I structure this?

Example... We need data from an external API (Toggl). This is data about work logs on projects. This data needs to be transformed to fit our needs for a .csv file to import into another tool.

I created a ToggleApiService class to connect to Toggl and call certain endpoints and collect data. My controller now transforms the data to output a csv. This gives quite some code. What would be a good naming scheme/logic to seperate the tranformation from the controller?

Of course this is an example use case. Basically, how do you keep controllers as short as possible and put the logic somewhere else, which aren't models.

Thanks for your thoughts!

13th June, 2017

rikw left a reply on Writing Tests For SSH • 2 months ago

Nobody here that can help me out (just a little bump)?

9th June, 2017

rikw started a new conversation Writing Tests For SSH • 2 months ago

Hi all,

I'm trying to write an application that can perform some remote actions through SSH. The Laravel Collective Remote/SSH package works just fine. Now I'm also trying to write proper tests but have no clue how to approach this for SSH. Who can give a pointer?

8th June, 2017

rikw left a reply on How To Work With Fixed State/status/type Fields • 2 months ago

Hi @neilherbertuk the enum does limit the values in database but doesn't provide a way to select those options right? These need to be hardcoded somewhere.

From the docs I read: The following column types can not be "changed": char, double, enum, mediumInteger, timestamp, tinyInteger, ipAddress, json, jsonb, macAddress, mediumIncrements, morphs, nullableMorphs, nullableTimestamps, softDeletes, timeTz, timestampTz, timestamps, timestampsTz, unsignedMediumInteger, unsignedTinyInteger, uuid.

Does this mean I cannot add values to the enum?

Thank @Screenbeetle for your explanation. I think this will work. This allows future new types/statuses and a way to select them in templates. As for my cron functions I can select the right records based on hardcoded types in code, that link to new records in the type/status table.

7th June, 2017

rikw left a reply on How To Work With Fixed State/status/type Fields • 2 months ago

Thanks for the feedback. Hardcoding isn't preferred but isn't it the only way of knowing for sure in code? I saw the enumerated thing. That limits the values in database. But I need to be able to add values and use them in templates. Would it make sense to use a table with id, code and name fields? Code being a unique that I use in the code. This I can fill with a seeder.

rikw started a new conversation How To Work With Fixed State/status/type Fields • 2 months ago

Hi,

I want my records to have a status or type which I can act on. So basically open/closed or typeA/typeB/typeC. I want need to select records of a known type to do some repeating action. It doesn't seem right to use a o2m relation as it works on database id's, not so handy for code. What is better way to approach this in a Laravel way?

Cheers!

2nd August, 2016

rikw left a reply on Date Field Shown As -0001-11-30 00:00:00 • 1 year ago

Hi @selmonal, I had that. But submittting an empty field makes it store 0000-00-00 00:00:00 in stead of null. Is that to be expected?

The situation occures when I create a new record with only one field filled. Then the edit screen shows empty date fields. When I submit those fields things go wrong.

1st August, 2016

rikw started a new conversation Date Field Shown As -0001-11-30 00:00:00 • 1 year ago

Hi,

I have a model and form which I cannot get right. My database fields are of type date and datetime. Both fields are added to the dates array. When I save the form with empty values the database stores as 0000-00-00 00:00:00. But the edit form then shows -0001-11-30 00:00:00. I just cannot get it right. Who can help me?

Cheers! Rik

8th June, 2016

rikw left a reply on Seperate Logins On Same Email Address • 1 year ago

Sweet @martinbean, I can really work with this. Thanks for thinking with me and showing me a good solution.

7th June, 2016

rikw left a reply on Seperate Logins On Same Email Address • 1 year ago

Hi @martinbean and @Kemito that helps a lot. With both I think I can manage my challenge. Maybe not the easiest one while starting Laravel.

Maybe one last tip I could use. At what point should I find the current (sub)domain? The whitelabels use their own domain the they 'send' to our platform. Like: sub1.domain-a.tld, sub2.domain-b.tld.

These kind of questions might show I'm struggling a bit with this structure in Laravel.

rikw left a reply on Seperate Logins On Same Email Address • 1 year ago

Thanks @martinbean that sounds like a plan. That would mean a custom Guard for login/authentication am I right?

rikw left a reply on Seperate Logins On Same Email Address • 1 year ago

Thank you for thinking along. I'd like to keep it as simple as possible. Let me try to explain it a little.

Think of it as a SaaS platform on which users can register. But their account on client1.domain.tld isn't the same user as client2.domain.tld although their email address can be the same.

Our customer repairs devices and has an online platform to manage that proces. Customers can register their device for repair and create a login for that. Our customer wants to whitelabel the frontend part to other companies, but the devices need to go into the same platform to manage the repairs. A repair customer can have an account at multiple whitelabel without knowing it's actually the same platform.

I hope this clears up my situation...

6th June, 2016

rikw started a new conversation Seperate Logins On Same Email Address • 1 year ago

Hi,

In my project I have separate frontend sections for different clients, but also one for backend. Now I'm looking for a solution to use the same email address for separate users for the different sections. How can I achieve something like that?

As example:

  • domain.tld
  • client1.domain.tld
  • client2.domain.tld
  • backend.domain.tld or domain.tld/backend

The users for client1 & client2 should also have addition fields compare to he user of the main domain.

I'm looking forward to your thoughts. I can't really get my head around it.

6th May, 2016

rikw started a new conversation Protect Frontend Controller By Token • 1 year ago

Hi,

I'm looking for a way to protect a frontend controller by a token. We want to send customers an email that gives access to a particular record using that token. I saw information about custom guards. Is that the way to go? Or is there a easier way to solve this?

Cheers, Rik

30th April, 2016

rikw left a reply on Prefered Way To Update A Model • 1 year ago

Sweet, thank you both! Works like a charm.

rikw started a new conversation Prefered Way To Update A Model • 1 year ago

Dear all,

Being new to Laravel I'm stuggling with a few best practise kind of questions. This one is about the prefered way to update a model. I find myself having two different ways of working for the create and update functions. I expected a Eloquent way of updating. Thanks for looking and helping.

    public function store(Request $request, Offer $offer)
    {
        $this->validate($request, [
            'name' => 'required',
        ]);

        Offer::create([
            'name' => $request->name,
        ]);

        return redirect(route('backend.name.index'));
    }

    public function update(Request $request, Offer $offer)
    {
        $this->validate($request, [
            'name' => 'required',
        ]);

        $offer->name = $request->name;
        $offer->save();

        return redirect(route('backend.offer.index'));
    }

Or, should I do:

    public function update(Request $request, Offer $offer)
    {
        $this->validate($request, [
            'name' => 'required',
        ]);

        Offer::findOrFail($offer->id)->update([
            'name' => $request->name,
        ]);

        return redirect(route('backend.offer.index'));
    }
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.