luceos

luceos

Member Since 5 Years Ago

developer at Netherlands

Experience Points 16,395
Experience Level 4

3,605 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 38
Lessons
Completed
Best Reply Awards 10
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.

23 Sep
9 months ago

luceos left a reply on Multi Tenant Packages

@cheetooh books? No; but you can take a look at the (slightly) outdated tutorial by @ashokgelal@gmail.com ; an updated version is in the makes by a community member:

https://medium.com/@ashokgelal/a-full-featured-multi-tenant-app-with-laravel-part-1-4049a3cc229d

12 Apr
1 year ago

luceos left a reply on Saas Tutorial?

Check https://laravel-tenancy.com, it offers a tutorial as well by Ashok Gelal over at Medium. The hyn/multi-tenant package is great for scaffolding a multi tenant saas app easily.

disclaimer; the author

luceos left a reply on Multi Tenant Packages

It's been ages I posted here, but the website lists all current versions (currently 5.x for Laravel 5.5 and up):

https://laravel-tenancy.com

13 Feb
1 year ago

luceos left a reply on Multisite CMS, One Backend, Same Server, Folders, Assets & General Structure Concerns

As traffic is still coming in from this page; here's the direct link to the package @londoh mentions:

https://laravel-tenancy.com

14 Nov
1 year ago

luceos left a reply on Multi Tenant Pattern

@JulioGa1011 yes check https://laravel-tenancy.com and join our discord server, the community is growing and people are helping each other build amazing apps!

10 Oct
1 year ago

luceos left a reply on Const Stupid?

I recommend this article which explains a lot about const.

Please understand that also var and let cannot be redeclared as opposed to what @dev.kobus says above.

Now, we need to know you can only declare a variable inside of its scope once.

11 May
2 years ago

luceos left a reply on Multi Tenant Packages

Version 3.x is upcoming, is a complete rewrite and is meant to be compatible with Laravel 5.3 and up. In addition it supports mariadb and postgresql, read more about it:

http://createsend.com/t/i-6EA49ACAA0279784

luceos left a reply on Multi Tenant Pattern

I'm the maintainer of hyn/multi-tenant and the upcoming version 3 has support for postgresql and mariadb, is compatible with Laravel 5.3 and up and can work with database division using prefixes or separate databases. I'd love to consider using a different schema now that you mention it.

Hyn also integrates into your webserver ;)

01 Mar
2 years ago

luceos left a reply on Fat Controller And Helper Functions, Where To Move?

Are you generating the whole html (tables, widgets, doughnuts) inside php?

13 Jan
2 years ago

luceos left a reply on Is Session::save() Required Each Time I Write To Session?

Under normal circumstances session persistence is arranged by Laravel itself. There could be reasons however why it might no longer work.

  • Amongst others unexpectedly quitting the application (I think dd for instance does that) can be a reason for this behaviour.
  • Another reason can be a misconfigured session driver.

Could you give us more information on your current environment?

04 Jan
2 years ago

luceos left a reply on Two Websites With Single Login.

A third option would be the so called "single sign-on". In general it works like this:

  • No matter which site the user hits, once clicking register or signup it redirects to the main domain, x1.com in your example.
  • Login or registration happens and when successful the user is redirected back to the site using some kind of redirect-back value the SSO page received.

Some concerns you have to take into consideration:

  • SSO is easiest when using one primary domain, because you would only need to set the authenticative cookie. The primary domain is allowed to set cookies for any and all subdomains.
  • In case you want to support other domains, you'd have to use some kind of token that will validate the user on the site. This is comparable to Oauth or JWT.
21 Dec
2 years ago

luceos left a reply on NameSpace Are Not Working In Laravel 4.2

If you're blindly assuming that the App\ namespace will work, you're wrong. The app directory and its namespace were introduced in Laravel 5. If you're adding your own code in separate directories, you might have to update the composer.json file to add your autoloading information.

https://github.com/laravel/laravel/blob/v4.2.11/composer.json

luceos left a reply on Multi Tenant Separation Of Assets

@umefarooq sure, here it is for apache:

alias "/media" "/full/path/to/tenant/media/directory"
19 Dec
2 years ago

luceos left a reply on Many Checks With Loop If Data In Database Is Available

Also with 5k rows, you might want to use chunking.

luceos left a reply on Many Checks With Loop If Data In Database Is Available

I'd suggest you look at firstOrCreate:

https://laravel.com/docs/5.3/eloquent#other-creation-methods

// Retrieve the flight by the attributes, or create it if it doesn't exist...
$flight = App\Flight::firstOrCreate(['name' => 'Flight 10']);

In your situation:

ServiceTitle::firstOrCreate(['title' => $title->title, 'service_id => $item['service_id']);

Please watch for guarded properties, you might need to call: ServiceTitle::unguard(); before the loop to make mass filling possible.

30 Nov
2 years ago

luceos left a reply on Please Help, I'm Currently Running My Website On Production

Did you configure your pool correctly to allow for sufficient connections?

29 Nov
2 years ago

luceos left a reply on Fetching Data From Two Different Database

You can easily set up multiple database connections, the documentation mentions it also.

luceos left a reply on How Do You Test Remote APIs In Application Testing?

Hi @tzurbaev , what I recently did is create a trait that I attached to any Test Class and then at the beginning of each method that would call on the remote API I'd specifically overrule the responses. The below code was used for that, please note this requires you to add the Guzzle client to IoC (hence the extend call):

<?php

namespace Testing\Mocks;

use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Stream\Stream;
use GuzzleHttp\Subscriber\History;
use GuzzleHttp\Subscriber\Mock;

trait GuzzleMocked
{
    protected $guzzleHistory;

    protected function mockNextGuzzleRequest(Response $response)
    {
        $this->mockNextGuzzleRequests([$response]);
    }

    protected function mockNextGuzzleRequests(array $responses)
    {
        foreach ($responses as $response) {
            if (!($response instanceof Response)) {
                throw new \RuntimeException("Response type incorrect.");
            }
        }

        $client = new Client;

        $mock = new Mock($responses);

        $client->getEmitter()->attach($mock);

        $this->guzzleHistory = new History();

        $client->getEmitter()->attach($this->guzzleHistory);

        $this->app->extend(Client::class, function () use ($client) {
            return $client;
        });
    }
}

This logic uses a mock subscriber, which attaches to the Guzzle client. We implement a history middleware that tells Guzzle we expect certain responses. The responses can be anything as long as you use the GuzzleHttp\Message\Response object.

The following local API call would trigger a remote API, which I mocked with a simple status 200 response:

    public function testFullStore()
    {
        $this->mockNextGuzzleRequest(
            new Response(200)
        );
        $this->uri = 'account';
        $this->method = "POST";
        $this->parameters = array(
            'name' => 'Donald Duck',
            // .. more
        );
        $this->callResource();
        $this->assertResponseOk();
        // .. more asserts
    }

Hope this helps.

23 Nov
2 years ago

luceos left a reply on Couple Of Coding Questions

Aside from the replies above what I can recommend is getting involved with open source by contributing. Once you've gained some experience in programming getting a regular pull request done helps you get feedback from (possibly very) experienced developers.

Another piece of advice might be to get in touch with (or join a company that has) experienced developers. Getting some intimate coaching helps you to new levels very soon, this can also be the case by asking for code reviews though.

Something I have been doing for a few months in the past is trying to answer as many questions as possible on the #questions channel over at larachat.co - the official slack for Laravel. Even if you do not know the answer, investigating how to solve questions you didn't ask, adds a ton of experience in an otherwise wild spot of your potential.

The last thing I can advice to do is writing a package and maintaining it. Especially that last part requires you to continuously put in effort to keep it up to date and grow your stargazers count.

Also, don't be afraid of the code you write now. Every developer looks back at his or her code written months (or years) ago and feels disgusted, but also motivated to do better; especially in your early days.

luceos left a reply on Follow/Favorite A Forum Thread

@jeffreyway in the new design the only way to add a thread to your favorites is going back to the first page and clicking the (miniature lol) star. Would it be possible to have an additional button next to "post your reply" or somewhere.

17 Nov
2 years ago

luceos left a reply on Should I Be Using Design Patterns?

public function getLabelType()
{
    $labelSize = Item::where('item_code', '=', $this->item_code)->firstOrFail()->label_size_id;

    return LabelType::where('label_size_id', '=', $labelSize)
        ->where('product_type', '=', $this->getProductType())
        ->firstOrFail()->id;
}

I've added some firstOrFail statements that will simply trigger an error. You could handle it manually depending on how your application works. I see in the snippet you posted a lot of variables that are only used once, you could simply remove them. For instance the above could also be written so:

public function getLabelType()
{
    return LabelType::where('label_size_id', '=', Item::where('item_code', '=', $this->item_code)->firstOrFail()->label_size_id)
        ->where('product_type', '=', $this->getProductType())
        ->firstOrFail()->id;
}
16 Nov
2 years ago

luceos left a reply on Migrations Work With MySQL DB However Passing Data Using DB Gives Me An Error.

Read the note about connecting Laravel to the database, it mentions that Laravel should connect using the normal port 3306. Only from outside your vagrant machine do you need to use the alternative port 33060, so your sequel pro configuration is fine.

Link: https://laravel.com/docs/5.3/homestead#connecting-to-databases

luceos left a reply on Should I Be Using Design Patterns?

Ah right get on a DB query object returns an array. Well you can always use collect() first.

luceos left a reply on Special Characters In Request?

I'm not sure why urldecode is advised. You are adding an url segment to the request, so you should use urlencode to make the character name safe for the url. Did you try that?

Even so, you might need to check what the api actually does with characters like these, perhaps they normalize them..

luceos left a reply on Service Provider V Helper Class In Refactoring L4.2 App

Logic like that most definitely should be moved into a Repository.

The reason for this is that it's very closely related to a Model, but the logic actually is like "processing". One could question whether to use repositories for simple saving, loading, deleting etc, but for cases where the heavy gets thick and has a tight relation to a Model, the best thing to do is to move it into a repository.

luceos left a reply on Self-hosted Realtime Notification

An alternative for pusher would be slanger, it's based on ruby. I've had it running in production for quite a while, in the end we switched over to pusher nevertheless due to the need of maintenance.

https://github.com/stevegraham/slanger

Using slanger you can simply use the pusher notification package and set your custom hostname.

luceos left a reply on Should I Be Using Design Patterns?

Also you might want to look at all functionality available in the framework before looking at design patterns. Quite often the framework allows you to simplify a lot of logic you would have liked to write in "bare" php, for instance your index method:


/**
 *
 * Check permissions and show the view
 *
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
 */
public function index()
{
    $query = DB::table('printers')
        ->join('locations', 'locations.user_id', '=', 'printers.location_id')
        ->select('printers.id', 'printers.description')
        ->where('deleted_at', null);

    //if we are a manager we can print anywhere
    if (!Auth::user()->is('labelling_manager')) {
        $query->where('locations.user_id', Auth::user()->id);
    }

    $printers = $query->get()->keyBy('id')->map(function($printer) {
        return $printer->description;
    });

    return view('text_label.list', compact('printers'));
}

The ->get() method will return a Collection, something which has great power. Just look at Adam Wathan with his "curing the loop", it's more like a testimonial of the prowess of Laravel: https://www.youtube.com/watch?v=crSUWtRYw-M

13 Oct
2 years ago

luceos left a reply on [question] Realtime Folder Checking

Hello Wouter,

If you are not the party handling the uploads I would most likely create a cron that polls for new files and triggers an event. Through an event listener you can then listen on these event, update a persisted count (database or redis or something) and on every N, you trigger a queue job to start processing the batch of files. If you are unaware about the filenames I'd suggest adding the filename to the event and persisting them to the database. After they have been processed you can then set a processed_at date flag.

Hope this helps!

17 Aug
2 years ago

luceos left a reply on Multi Tenant Packages

Version 2 of hyn/multi-tenant is now supporting 5.2 and will support 5.3 as soon as it's released, see the newsletter at:

http://createsend.com/t/i-9450F3A5DF9E2007

@gabrelbuzzi please let me know on github as issue if you encounter any problems installing this on Laravel 5.2. Make sure you use the 2.0.0-beta.3 version!

22 May
3 years ago

luceos left a reply on [L5.2] Queued Events Causing 404 Error

This is in fact happening because you are using an event listener that listens to events fired within a transaction. Events like these are fired before the actual data is persisted to the database, so once the listeners tries to use the data, it cannot because it has not yet been committed. Best thing to do is to move the triggering of events outside the transaction.

I know this because our L 4.2 app leans heavily on Model observers, where all post-committing events (saved, updated, deleted) within a transaction always are fired within the transaction, not after.

luceos left a reply on Sessions In Multi Tennant App

Why don't you modify the session.prefix during runtime, eg in a middleware that also identifies the tenancy environment? If these session values have to remain seperated this might be easiest. Do know that switching tenants while remaining logged in will possibly not work.

29 Apr
3 years ago

luceos left a reply on I Know This Problem Is Common Now, But I Don't Know Where I Am Getting This Error, Some Time It Works Perfect Sometimes Gives Error, I Tried All The Things Available On Internet, Laracast, Stackoverflow, But Didn't Find Any Solution1/1 MethodNotAllowedHtt

Use tripple backticks around your code. (```).

From what I can interpret from the mess you posted it seems you are trying to submit a form with method get to the named route test. This route is defined as allowing only post methods. You either have to change the named route test to allow for get to or change the method to post in your form.

10 Mar
3 years ago

luceos left a reply on Measure Website Performance

Cpu usage can be measured using the php function sys_getloadavg. Returns an array with three samples (last 1, 5 and 15 minutes).

Regarding the first. I'd simply use curl or a curl wrapper like the well-known guzzle client. You can easily check for resources using a dom crawler like the one from symfony: http://symfony.com/doc/current/components/dom_crawler.html

23 Dec
3 years ago

luceos left a reply on Events Are "handled" Twice

I have no idea actually. Maybe you could start logging to a seperate file to find the exact cause. Log that an object is saved, log that an event is fired, log that the listener is handling the called event, log that the email is send..

22 Dec
3 years ago

luceos left a reply on Events Are "handled" Twice

Could you give more insight into your setup? What events are you hooking into? Do you provide return codes while the events are fired or throw exceptions? Are the events triggered while the model(s) are saved within a transaction? Did you add any failsafes?

17 Dec
3 years ago

luceos left a reply on Extremely Frustrated. Please Help!

The middleware should do what you need. Question is, what is the exact behavior. What if you remove the caching, is the behavior as expected?

Can you tell me:

  • what happens now
  • what did you expect

luceos left a reply on Extremely Frustrated. Please Help!

Maybe you can pick up some inspiration from my package; you can also ask questions on gitter. What you are trying to do shouldn't be too hard, I'd love to hear about your setup and think along.

08 Dec
3 years ago

luceos left a reply on Multi Tenant Packages

Tonight, after seven months of hard work I finally tagged version 1.0.0. As a result this is now a stable multi tenancy solution for Laravel 5.1 LTS.

Read more in the december update.

luceos left a reply on Multi Tenant Separation Of Assets

Seeing this question wasn't answered. I solved this issue in my package by using alias functions in both nginx and apache configurations. Using alias you can link a subfolder (for instance media) with any path of your installation per hostname. So website2.com/media would point to the img folder of website2.

27 Nov
3 years ago

luceos left a reply on Error "preg_replace(): Parameter Mismatch" Inserting Multiple Checkbox Into Multiple Row

Shouldn't the insert of feature_id not be an ID (int); you are defaulting to an [] array.

luceos left a reply on Artisan Customize

In your app directory create a ArtisanServiceProvider.php in the Providers directory. You will then create a class like:

namespace App\Providers;

use Illuminate\Foundation\Providers\ArtisanServiceProvider as IlluminateProvider;

class ArtisanServiceProvider extends IlluminateProvider {
// overrule whatever you want
}

Now in your config/app.php change the Illuminate\Foundation\Providers\ArtisanServiceProvider to App\Providers\ArtisanServiceProvider.

25 Nov
3 years ago

luceos left a reply on Multi Tenant Packages

  • @peter I have been adding the functionality to separate tenant databases using prefix only.
  • @larsn Hoped you would be able to tell me whether I have been able to stick to your requirement of keeping features to a bare minimum.
  • @samsoft @jartaud hyn/multi-tenant should now be stable enough for you to use in production environments; if you encounter issues please do let me know so I can assist in getting you along ASAP.
20 Nov
3 years ago

luceos left a reply on Multi Tenant Packages

Version 0.8.0+ has been announced in the latest newsletter. Version 1.0.0 is expected before 2016. The current version is not backward compatible due to a final namespace change to Hyn.

02 Oct
3 years ago

luceos left a reply on Multi Tenant Packages

This morning I've send out a newsletter announcing the release of beta 3, which includes an installer script, which allows the installation of a multi-tenant Laravel 5.1 with all requirements needed for proper functioning of the application.

30 Sep
3 years ago

luceos left a reply on Multi Tenant Packages

Hello @peter at this time my package does not support this. The base idea behind the package is the concept of SAAS, the requirement of being secure and unobtrusive. As such I am unsure whether sharing one database between tenants is a strategic direction I'm willing to move into with this. There are however alternatives I've listed in the readme of my project that do use a shared database.

On a general note my apologies for the silence here, I have been busy working on these packages, while supporting the open source community in other ways as well.

A new newsletter is around the corner, in which I discuss an automatic installer and a probable stable release.

03 Sep
3 years ago

luceos left a reply on Laravel Forum Software

flarum released its first beta and announced a second beta for this week

30 Aug
3 years ago

luceos left a reply on Multi Tenant Packages

Latest Stable Version License Build Status Code Coverage StyleCI

The latest newsletter explains how to use the package as a developer and gives insight into the near future for this multi tenancy solution. See: http://createsend.com/t/i-DF339390B176E076

14 Aug
3 years ago

luceos left a reply on Save() Inside A Loop Leaks Memory

Could you try the following:

foreach($files as $f) {
                    echo $f." : ".memory_get_usage()."\n";
                    $contents = file_get_contents($f);
                    $new_document = new \App\document();
                    $new_document->email_id = $document->email_id;
                    $new_document->directory = 'in';
                    $new_document->filename = $document->classified_as.time().'.pdf';
                    $new_document->ocr_task_status = 'Unknown';
                    $new_document->key = str_random(32);
                    $new_document->authority_id = $document->authority_id;
                    $new_document->pages = 1;
                    $new_document->step = 'email';
                    $new_document->classified_as = $document->classified_as;
                    $new_document->classified_score = $document->classified_score;
                    $new_document->identified = Carbon::now()->toDateTimeString();
                    $new_document->classified = Carbon::now()->toDateTimeString();
                    $new_document->save();

                    $res = Storage::disk('s3')->put('in/' . $new_document->id, $contents);
                    unlink($f);
                    unset($res, $new_document, $contents);
                }

This will clean up as much memory as possible within the single iteration.

13 Aug
3 years ago

luceos left a reply on Laravel Installation In Cpanel

do everything over ssh, you can use composer for single-user as well, not only global (root); see the composer documentation for info

04 Aug
3 years ago

luceos left a reply on White Space Between @include() In Blade

Between the li you have an a. I'm not sure why that would be a white space? Please explain your question.