9 Best Reply Awards

  • Member Since 2 Years Ago
  • 305 Lessons Completed
  • 0 Favorites

14th July, 2017

Pendo left a reply on Find Unused Methods/Routes/Views • 2 months ago

I'm after the same thing. A long running project is about to go live (well.. it'll still take a while) and it needs a major cleaning since a lot has been refactored and I'm pretty sure some methods, routes and views are left unused.

6th July, 2017

Pendo left a reply on Npm Run / Gulp Not Working • 2 months ago

Did you do npm install first before running npm run watch?

21st April, 2017

Pendo left a reply on Mails Sent Using Mail::queue Won't Apear In Mailgun Logs • 4 months ago

Nope, sorry. Didn't look into it, just kept using SMTP access instead of the API to send e-mails.

9th February, 2017

Pendo left a reply on Add New Payment Method In Spark • 7 months ago

Stripe is now supported in the Netherlands, however I've found out Spark is build for just credit card support so it would need some editting to get it running. Stripe offers recurring payments via bank accounts now (as does Mollie by the way). Not sure when, but I'm going to see what the best way is to get a payment method for the Dutch market connected.

1st December, 2016

Pendo left a reply on Should I Use An Admin Template Such As JoshAdmin? • 9 months ago

@mjoc1985: in most cases it's most important that code works.. I'd like to have clean code in every project as wel, but let's be honest: if it doens't pay to refactor or build something from the ground up, but it works? Just leave it like that.

Pendo left a reply on Laravel + WYSIWYG Security • 9 months ago

@semperfoo: and what you decide to give users other permission for showing data on your website? For instance, you'd like to allow links which you didn't before.

As far as I'm concerned, store data as you get it (perhaps basic filtering for javascript etc. is smart) and then clean the output when displaying. But opinions are different on that subject :)

30th November, 2016

Pendo left a reply on Createing Cron Running Log • 9 months ago

@dynamiccarrots: sorry it took so long. Didn't have any time to look into it. I created the package and tested it locally to validate it works. You can find the package below:

What it does is pretty simple: it replace Schedule interface that is used when running schedule:run. My interface automatically binds the before() and after() methods (as shown in my 3rd post). Obviously, there are much easier ways (only using a model and the before/after hooks), but this is an all-in-one automated solution.

I've added a check that only logs the execution times when in local or staging environment (see the modification of app/Console/Kernel.php on Github). If you want to log the production, just modify this piece of code.

There's an example included to display the execution time of the jobs that have been executed. I guess this is all you need...

It was at least worth looking into this for me to learn more about the framework, so don't feel bad if you don't use the code!

17th November, 2016

Pendo left a reply on Createing Cron Running Log • 10 months ago

So, I've been busy all day trying to figure out how to create a package for this. Not because it's so super usefull, just because I get triggered by things I think I can't do ????

So far I've come up with a Schedule class to extend Laravel's and a custom Event class that extends Laravel's aswel. The idea is pretty simple, the Schedule class (I called it LogSchedule) dispatches an LogEvent and this LogEvent class adds the before() and after() closures by default.

These closures then call a singleton from within the IoC container and save the start and end date when firing a command via the scheduler. Hardest thing so far was figuring out how to replace the Schedule/Event classes because I was getting a lot of errors.

For now it works, have to fine tune some things a bit. I'm not sure if this is production ready since there are far more easier ways (like the one above) to do stuff like this. But hey, I might get some tips and might learn some new tricks while trying to get it to work this way.

I'm going to try and finish this setup somewhere next week. I'll get back here with the solution.

Pendo left a reply on Determining Available Time Slots(for Scheduling) • 10 months ago

@Eddie212: there is more to it than just that conditional:

if($from->between($eventStart, $eventEnd) || $to->between($eventStart, $eventEnd) || ($eventStart->between($from, $to) && $eventEnd->between($from, $to))) {
    return false;

That's what I have been using. Your conditional will fail on some points. Besides that, I subtracted 1 second off of the $to-time so the appointment of 13:30 till 14:00 doesn't overlap the 14:00 - 14:30 while checking.

Pendo left a reply on Createing Cron Running Log • 10 months ago

Maybe this is what you're looking for:

         ->before(function () {
         ->after(function () {

Pendo left a reply on Createing Cron Running Log • 10 months ago

You mean like some kind of observer that watches for commands being ran and logging start/end by itself? If so.. that goes beyond what I know about Laravel so far.

Pendo left a reply on DB::query Not Working Laravel 5.3 • 10 months ago

DB::query("SELECT * FROM users")->get();

You're nog getting anything yet.

Pendo left a reply on Createing Cron Running Log • 10 months ago

If I was to build a functionality like this I'd create some kind of CronLogger class that you can use within the commands that you are running. Each cron would get it's own key and all I would do was:


// Your cron working


When reading the data from your database if the start timestamp is greater than the end timestamp you can assume it's running (or even failed if it stays that way).

Just aproach this as simple as possibe.

Pendo left a reply on Should I Use An Admin Template Such As JoshAdmin? • 10 months ago

Honestly I think stripping down takes far less time than designing an admin theme, converting it to HTML, adding scripts for what you use, etc.

In my past experiences all the admin themes I've used so far saved me so much time compared to building one myself (which I've done 1 time and never ever again after that first time).

On the other hand, if you want a fully unique design for your web app: just go for it. It'll take time but you'll be more happy with the result in the end. It also depends on the amount of time you have to create the theme I guess.

What template you use doesn't really mather, most of them are good and it's all based on personal taste of the design. So as far as I'm concerned: admin templates save you a ton of time and if you're no designer you'd better be spending all that time on building your project instead.

17th October, 2016

Pendo left a reply on Artisan Fails In Staging/productions - Works Local • 11 months ago

As usual.. few hours of bugfixing won't lead to the solution. But after posting the question you find the solution.

There was one little difference between local & staging/production: on vendor's files weren't published locally and that single config file contained a reference to the url() helper method.

Pendo started a new conversation Artisan Fails In Staging/productions - Works Local • 11 months ago

Hi all,

been looking at this issue for some time now and none of the suggested things I came across on the forum or Google lead me to solving this issue for me. Below is the error I get when trying to run ANY artisan command:

PHP Catchable fatal error:  Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in /home/*/domains/*.nl/public_html/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php on line 62 and defined in /home/*/domains/*.nl/public_html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 102

Catchable fatal error: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in /home/*/domains/*.nl/public_html/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php on line 62 and defined in /home/*/domains/*.nl/public_html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 102

What I came across so far was that having helper functions such as url() and asset() in the config files caused this issue. I double checked but there aren't any of these present in any of the configuration files. Besides, I guess the error should occure local aswel if this was the case.

I tried to clear the composer cache, dump-autoload, clear the cache folders of laravel (permissions are correct rwxrwxr-x). I also tried setting the staging environment variable to "local", but the issue persists. PHP versions are 5.6.13 local and 5.6.26 on the server I'm working on. Then there was a Middleware that forced a redirect.. thought that might be an issue, but disabling the middleware didn't solve anything.

That's what I've tried so far to solve the issue, without any luck.

15th August, 2016

Pendo left a reply on Speed Up Ajax Request • 1 year ago

Just pushed the changes to the staging server, looks like it's all just in the development stack. On the live server the response went down from 700ms to ~250ms. Thanks for thinking along!

Pendo left a reply on Speed Up Ajax Request • 1 year ago

@ohffs: let me check what is happening, will come back at that in a few minutes. @toniperic: it's just a search in a varchar(155) field actually.

I may be able to replace the 'search' function with a datasource for the autocomplete to filter by itself. Thanks so far.

Pendo started a new conversation Speed Up Ajax Request • 1 year ago

Hi all,

I'm developing an autocomplete function on a set of 60 categories in one of the projects I'm doing. I noticed the ajax requests are pretty slow (about 700ms per request) when I hadn't added any caching. But after adding caching, the responses still are between 200 and 700ms.

The cache driver is file-based, the code I use is below:

        // Set or Get cached value (12 hours)
        if(Cache::has($cachekey)) {
            $matches = Cache::get($cachekey);
        } else {
            $matches = CompanyCategory::where('name', 'LIKE', '%'.$keyword.'%')->where('parent_id', '!=', 0)->with('parent')->get();
            Cache::put($cachekey, $matches, (60 * 12));

        return response()->json($result);

(1) User types in a value in an input field (2) AJAX request fires to a route (3) A controller method (above) is executed and returns json result (4) Results are displayed as autocomplete to the input

Is there any way to speed up this proces? I can't believe that these simple requests, especially when cached, need to take 700ms.

5th August, 2016

Pendo left a reply on When Would You Update The Laravel Framework In A Project? • 1 year ago

Right, I guess I'm on the same page as most of you. For my own CMS I would maintain and update the source better en quicker because it's going to be used on multiple projects. Custom projects like the ones I mentioned need to work. Too bad I'm just starting to get into TDD (or at least into writing tests), so for the past few projects it will be a lot harder to test and check all code after an update.

Laravel 5.1.* will be good enough for the near future anyway.. based on the opinions/experiences you guys have I don't think I should think about it too much. Thanks all :)

4th August, 2016

Pendo left a reply on When Would You Update The Laravel Framework In A Project? • 1 year ago

My biggest issue is what @zachleigh said: future maintenance and being able to spread the work for updating the project over multiple months/years instead of having to rewrite a large piece of your software 3 years further down the road.

The projects I started in 5.1.x all make use of an external permission/roles package, while 5.2 comes with it's own, I'm kind of curious to see how much work it takes to update to L5.2 or even L5.3 in a few days/weeks when it's released. Laravel Shift seemed like a good starting place, it automatically updates the framework code and creates a seperate Git branch. I think I'm going to test the effort it takes to update the code in a few weeks after the storm settles (the storm being clients that are pushing ;)) just to get some experience in it.

I even have had procedural PHP projects from 5/6 years ago that I'd wish I had updated at least a little bit to the most recent changes of their CMS basis that I'm using in projects I started later on. Old code is a bitch.. definitly if you get used to the newer code.

3rd August, 2016

Pendo left a reply on When Would You Update The Laravel Framework In A Project? • 1 year ago

So, when using 5.1 that would be an update to whatever latest version 5.1.* is? That's what I was thinking about aswel, why bother to upgrade to a newer version if the functionality added by the update isn't used because the application is running correctly.

However, there must be people that update from 5.1 to 5.2 to 5.3, kind of curious to their thoughts and why one would do this.

Just came across Laravel Shift - this automates the update proces of the laravel core if I understand correctly and you can focus on updating the custom code (controllers, models, etc) yourself. Right?

Pendo started a new conversation When Would You Update The Laravel Framework In A Project? • 1 year ago

Been thinking about this for a while, I've got a few project running on Laravel 5.1, some development projects on 5.2 and probably my next on is going to be on 5.3. But when would one decide to update the framework version to the latest? The 5.1 projects had been started while 5.2 was already released, but chosen due to being a LTS release.

I can imagine you won't update it to each latest version (at least,.. I can't see myself doing that or my clients paying for that every time), but there comes a time when an update is inevitable (or even when it's too late already). So,.. what guidlines do you guys follow when it comes to updating the core framework of your projects and maybe more important: how do you handle the update and testing?

2nd August, 2016

Pendo started a new conversation Let Users Manage The Website Menu(s) - Best Practice? • 1 year ago

Hi all,

last couple of months I've been figuring out a lot about Laravel and I can't even describe how much I regret not starting sooner! Just after a few projects and a bunch of books and blogs I've came to the conclusion that my CMS needs a major re-do using Laravel. I've created a few topics in the past with questions / topics that I needed some information one, mainly because I work by myself and sometimes you just hit a brick wall when trying to figure stuff out. This is one of those cases.

Where I think I have figured out most parts of the CMS, the setup, the functions, the modules, etc. there is still one part that I'm not feeling completely sure about: the (admin) module that allows the website owner/manager to create menus for different places on the website. Of course there are some obvious things, such as: we must be able to create different kind of menus with (unlimited?) multiply layers for subnavigation. But here's the thing:

How would you make this manageable? The CMS is going to be modular, each module has it's own configuration file/manifest, so I would be able to store menu specific data in one of these files. My plan is on using names routes with optional paramenters, so I won't be storing the actual links (to prevent 404's). So far so good, but where I can't seem to get my head wrapped around is this:

I don't want to display just the "general" links, like "Blog Entrance" and "Blog Archive", but I'd also like to give the user the ability to link directly to a page "Blog Article". For a blog we'd be using an ID field and a Title field, but this might be different if we are creating a link to a profile page (ID, Firstname, Lastname). How would I get my "MenuManager" to understand how to build a correct link / display the correct data.

This is what I'm after so far: create an interface "MenuBuilder" that has a few methods that each module must implement, most important one would be "getLinks" which gets all the links and "getItems" which would return an array of all rows for the resource. Then the module configuration/manifest would state that the module is linkable and what class should be used. For example: ProfileMenuBuilder. Then, foreach active module the MenuBuilder would be used to call the method that returns all available links.

Is this anywhere near best practice (or perhaps good practice) or is this perhaps the worst possible idea to get this all to work? Thanks a bunch for thinking along.

3rd July, 2016

Pendo left a reply on Laravel Route In <a> Tag • 1 year ago

@tylernathanreed: way too much effort for a developer of his type.

2nd July, 2016

Pendo left a reply on Laravel Route In <a> Tag • 1 year ago

Not trying to be a d*ck or anything, but I get the idea your trying to get help the easy way without spending any time on finding a solution yourself. That error has no relation with the initial question and besides that it explains what the problem is right in the error message. Check your Request-file or your validation rules in the method.

Use the documentation and you'll be a wise man in no time:

Pendo left a reply on Moving From Windows To Mac • 1 year ago

I think none of us can really decide for you what to do. I switched from Windows to Mac about 3 years ago, coming from +- 15 years of windows usage. It was strange at first but if you're used to working with computers you'll get the hang of it soon enough.

Basic tasks repeat theirself every day (installation of tools, usage of windows, basic shortcuts and mouse actions). I think it took me about a week or two to get used to the basic things of a mac.

Learning the programs took me from a few minutes to a few hours each, but as with everything: if you use it on a regular basis you'll get to know the ins and outs easily. As long as you can accept that you've got to change the way you work and are eager to learn I see no issues. Google is your friend, there hasn't been a single problem I ran in to that didn't have a solution posted on the net further than 3 mouse clicks away ;)

Good luck!

Pendo left a reply on Redirect->intended() Not Working After Login • 1 year ago

@aabraham: as far as I remember using both auth and role middleware fixed my problem good enough

Pendo left a reply on Determining Available Time Slots(for Scheduling) • 1 year ago

@tjphippen: sure, if I can be of any help let me know! I'm just taking a break from setting op a helper class that handles all checks for my application. I took a lot of code from your example and added some extra things to it to fit my needs, for example:

(1) A day can have multiple timeIntervals (eg. 8.00-12.00 & 13.00-18.00), so I'd have to loop the function for each interval (2) I have a function that returns availability per day (1 free spot? day available, 0 free spots? unavailable) instead of a full list of slots (3) A day can be closed (which would return false on that given day)

Besides that my application is setup a little bit diferent ofcourse, but I'd be happy to share what I made of it.

13th June, 2016

Pendo left a reply on Validator - Ignoring Field If Value Is 0 For Exists Rule. • 1 year ago

@pmall, thanks! Why didn't I think of that, much better to have the language in the view indeed.

But in my case, what you're using prepends this value (I tried multiple things but it always kept assigning a 0-value).

<option value="0">Please select a category</option>

And the exists validation rule then tries to find a record with ID=0 (which fails). I'm using Laravel 5.1.37 (LTS). Do you have similar behaviour?

Pendo left a reply on Validator - Ignoring Field If Value Is 0 For Exists Rule. • 1 year ago

I came across the same issue myself yesterday and my solution wasn't perfect for this. I was using the following to prepent my select list with a default value:

        $category_list = CompanyCategory::withParent(0)->lists('name', 'id');
        $category_list->prepend('Please select a category'); // this results in <option value="0">Please select a category</option>

This resulted in 0 being sent as value instead of "" or null. Therefore, I added a new validation rule, might come in handy for others:

 * Validate ExistsInDatabase or 0/null
    function ($attribute, $value, $parameters)
        if($value == 0 || is_null($value)) {
            return true;
        } else {
            $validator = Validator::make([$attribute => $value], [
                $attribute => 'exists:' . implode(",", $parameters)
            return !$validator->fails();

You would put this in the boot() method of the AppServiceProvider. I'm including a file containing all custom rules like so:

public function boot()
        require_once app_path() . '/Http/validator.php';

After adding this you can use the validation rule like this:

'parent_id' => 'sometimes|exists_or_null:company_categories,id'

What it simply does is check for the value to be either 0 or null, if so it passes the validation. Otherwise it does an exists validation using the same parameters.

29th May, 2016

Pendo left a reply on Mails Sent Using Mail::queue Won't Apear In Mailgun Logs • 1 year ago

Nope, haven't sorted this yet.. used SMTP Login for the time being which works for me and the client. Don't have that much time to dig in deeper.

Pendo left a reply on Determining Available Time Slots(for Scheduling) • 1 year ago

@tjphippen: I'm currently creating a plan for a similar project, been thinking about this for the past few weeks (I've had the time to think things thru) and came up with the following:

(1) We have a user that manages or multiple calenders and that manages it's own services (let's say "Wash hands, 10 minutes").

(2) Each calendar has an availability set, these are one or multiple timespans per given date. If the user is available each monday to friday between 13:00 and 18:00 for a whole year, that results in 52 * 5 = 260 records for availability. This is too much so I'm going to have each calender have it's default settings for monday to friday (multiple slots per day) and then another table containing the availability that overwrites the default settings (other times, closed days, etc). This keeps the table with the default times as little as possible (7 days x 2 timespans (if a lunchbreak is present in the day for example) per calender). Having 30 days that aren't according the default plan that reduces the amount of availability-records from 260 to about 50.

(3) Then there's the appointment table containing all appointments (like your events).

At first: thanks for pointing me out to DatePeriod, that'll take on headache away from defining the available slots in the calendar. Huge help, thanks!

Second: my biggest issue before, and still, is how to determine if a date is fully booked. I want to reduce the amount of queries needed as much as possible, but my first guess would be to do a calculation for each day in the calender, much alike finding a free slot on a day. But that would be a huge proces to calculate 31 days ahead.

What I'm leaning to is to have the script take the service that takes the least amount of time and perform an availability check on that day. Then, if there's no spot, an extra record should be generated in a table that locks out the date. Down side to this is that the day would stay available even if a user selects the service with the highest amount of time needed.

Can't really get my mind wrapped about the fatest (performance-wise) way to achieve this.

18th May, 2016

Pendo left a reply on Laravel Installer Use 5.1.* Instead Of Latest Version • 1 year ago

Yeah, I'm aware of the composer function, but since Laravel Installer grab a few packages when creating a new projects I was hoping to have the ability to select a version in the installer as well. But I guess the installer doesn't support any other version but the latest.

Pendo started a new conversation Laravel Installer Use 5.1.* Instead Of Latest Version • 1 year ago

Hi all,

can't seem to find anything but, is there an option to use the LTS version of Laravel when using the Laravel Installer?


12th May, 2016

Pendo started a new conversation Mails Sent Using Mail::queue Won't Apear In Mailgun Logs • 1 year ago

Hi all,

I've got some pretty strange (at least,.. I think so) issues with my Laravel setup and Mailgun. I think the issues are related, but correct me if I'm wrong about that.

The configuration I setup my .env file to specify the driver as mailgun and set the API key in the config/services.php file, I also setup all variables in the config/mail.php file:

return [
    'driver' => env('MAIL_DRIVER'),
    'host' => env('MAIL_HOST'),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => env('MAIL_FROM'), 'name' => env('MAIL_NAME')],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => env('MAIL_PRETEND', false),
    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
[email protected]

[email protected]
[email protected]

The From/To Address For an unknown reason, all mails are being send to and from [email protected], the [email protected] address is never user. I tripple checked the Mailgun configuration and search in all files from my project, but there is absolutely no place where [email protected] is used. Because of this issue we made an alias [email protected] -> [email protected] - but that's the only occurance of that e-mailaddress in the full project.

Mailgun Logs empty When using Mail::send the e-mail shows up in the Mailgun logs, when using Mail::queue however, the e-mail is delivered (I've added myself as BCC to check) but there is no reference of the e-mail in the Mailgun logs.

API vs SMTP When using the API all e-mail, even while specifying [email protected] as sender, are delivered from the default [email protected] account. When using the SMTP settings (MAIL_DRIVER=smtp) then the sender is correct: [email protected]

I'm confused.. more than that. I can't seem to figure out two things:

(1) Where the hell does the [email protected] address comes from (2) Why do mails via Mail::queue don't show in my Mailgun logs

Any help is greatly appreciated, I am willing to pay for help if that's needed. The project is live already and this is a big pain in the youknowwhat.

Thanks in advance.

4th May, 2016

Pendo left a reply on ModelIdentifier Returned Instead Of The Model In Listener • 1 year ago

Thanks! I'll give that a try just to see what it does.

30th April, 2016

Pendo left a reply on What's The Right Way To Save HTML In Database? • 1 year ago

Thanks, at least that's an answer after 4 months, haha!

28th April, 2016

Pendo left a reply on ModelIdentifier Returned Instead Of The Model In Listener • 1 year ago

Alright, so I found out it worked when implementing ShouldQueue and it also works when removing the SerializesModel treat. Can someone explain me what the difference is? Because a other Listeners I have work without any problems, the only difference is this piece of code:

        $groupname = '';
        if(intval($event->user->group_choice) > 0) {
            $group = Group::find($event->user->group_choice);
            if(!is_null($group)) {
                $groupname = $group->name;

So my guess is that the Mail::queue and Mail::send functions know how to handle the model identifier and the piece of code above does not. But when am I supposed to use the SerializesModel treat and when not?

Pendo started a new conversation ModelIdentifier Returned Instead Of The Model In Listener • 1 year ago

Hey all,

just ran into an issue, I've got this Event:


namespace App\Events;

use App\User;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;

class UserRegistered extends Event
    use SerializesModels;

    public $user;

     * UserRegistered constructor.
     * @param User $user
    public function __construct(User $user)
        $this->user = $user;

     * Get the channels the event should be broadcast on.
     * @return array
    public function broadcastOn()
        return [];

and this Listener:


namespace App\Listeners;

use Mail;
use App\Group;
use Illuminate\Mail\Mailer;
use App\Events\UserRegistered;

class EmailCopyToAdministrator
    public $mail;

     * EmailCopyToAdministrator constructor.
    public function __construct(Mailer $mailer)
        $this->mail = $mailer;

     * Handle the event.
     * @param  UserRegistered  $event
     * @return void
    public function handle(UserRegistered $event)
        $groupname = '';
        if(intval($event->user->group_choice) > 0) {
            $group = Group::find($event->user->group_choice);
            if(!is_null($group)) {
                $groupname = $group->name;

        $this->mail->queue('emails.auth.copy', ['member' => $event->user, 'groupname' => $groupname], function($message) use ($event)
            $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
            $message->to(env('MAIL_FROM'), env('MAIL_NAME'));
            $message->subject('Nieuwe registratie Rumbold!');

If I die-and-dump the $user variable from the Event constructor I get the model with accessible properties like $user->full_name, $user->email etc. However, when firing the event the Listener gives me this response:

ErrorException in EmailCopyToAdministrator.php line 31: Undefined property: Illuminate\Contracts\Database\ModelIdentifier::$group_choice

I can't seem to figure out where the problem lies. I noticed that it works when implement 'ShouldQueue', but since I'm using $this->mailer->queue I don't think I need that at all..

Any ideas?

16th March, 2016

Pendo left a reply on When To Use Middleware. • 1 year ago

Middleware is executed before a request, the manual says it all:

If you were to add auth middleware to a user profile route, an unauthenticated user would not see anything at all. Preventing a guest from seeing parts of a view can be done using Blade directives @can for example.

8th March, 2016

Pendo left a reply on Best Practice: Crud Pages On Both Front And Back-end • 1 year ago

Doh, I feel a bit stupid right now.. I can even use a shared base controller using the Gate facade. Thanks.

Pendo started a new conversation Best Practice: Crud Pages On Both Front And Back-end • 1 year ago

Hi all,

as I'm getting deeping into a project, there are a few things that I'm seeking the best practice for. Most of these things I'll figure out myself, but I'd like to know how you guys tackle this particular problem.


I'm working on an Agenda module for a website, in the back-end the administrator kan view, edit, create or delete all records in the database. On the front-end however, users can create items and edit their own. How would I structure the code so that both codes can use functions that are no different at all. Right now I have 2 controllers:

App\AgendaController.php App\Admin\AgendaController.php

As far as I can see right now, the create and edit methods are exactly the same, also the methods to upload or remove an image that is connected to an item won't change at all. The only thing different will be the views they're calling.

I was thinking of one extending the other, but the fact that views aren't shared makes that not work. Should I accept the fact that I'm having duplicate code in this case? Or is there anything I haven't thought of?

28th February, 2016

Pendo left a reply on Put *everything* In Controllers? • 1 year ago

I can imagine you using example #1, but #2 and #3 are really bad options I think..

For example 2 I'd say something like:

return view('bars')->with([
    'locations' => $queryResult

And then have the bars.blade.tpl extend a master template containining the header and footer. And the same goes for #3, why not just return home.blade.php which extends a master with header/footer. In the end it's all up to you, but it definitly ain't clean code and it doesn't make that much sense. The routes file is about routing (duh..) and in my opinion it should never or at least not very often contain anything of your applications functionallity.

27th February, 2016

Pendo left a reply on Input Old And Array • 1 year ago

That's a typo in the sample, I did it in my native language while testing. It should be field[]

Pendo left a reply on Input Old And Array • 1 year ago

Did a test, and the dot notation works.

{{ var_dump(old('field.0')) }}
<form method="post" action="fields">
    {!! csrf_field() !!}
    <input type="text" name="veldnaam[]" value="{{ old('field.0') }}" />
    <input type="text" name="veldnaam[]" value="{{ old('field.1') }}" />
    <input type="text" name="veldnaam[]" value="{{ old('field.2') }}" />
    <input type="submit" name="submit" value="test" />

field.0 returns anything you entered in the first input field.

Pendo left a reply on Input Old And Array • 1 year ago

Doesn't the dot notation work? Like

{{ old('field.0') }}

if not, that would be a good addition to Laravel I guess.

26th February, 2016

Pendo left a reply on Run Laravel And Forum On Same Server • 1 year ago

Symlinks are just shortcuts on the server. You could add the forum software outside your Laravel project, create a forum directory inside laravel/public and symlink that to the folder where the software sits. That separates both packages completely.

Pendo left a reply on Run Laravel And Forum On Same Server • 1 year ago

Symlinks an option?

25th February, 2016

Pendo left a reply on Inject Class Based On Route Parameters • 1 year ago

I think you can do this in the RouteServiceProvider:

$router->bind('post_type', function($value) {
    // return anything, $value is what {post_type} holds as value

You could simply return a concrete "return App\PostType" or you can add the switch in the route service provider. Or any other code that eventually returns the right class.

Edit Your Profile

Want to change your profile photo? We pull from