codestudiohq / laravel-totem

Manage Your Laravel Schedule From A Web Dashboard
MIT License
1.78k stars 224 forks source link

Error when viewing tasks #52

Closed alexstone closed 6 years ago

alexstone commented 6 years ago

Not sure what could be the issue and I've exhausted myself so here I am :)

When trying to view a task in Totem, I get the following error:

Trying to get property of non-object (View: /home/vagrant/Code/comiccartel/vendor/studio/laravel-totem/resources/views/tasks/view.blade.php)

Here's the stack trace:

<?php $__env->startSection('title'); ?>
    <div class="uk-flex uk-flex-between uk-flex-middle">
        <h5 class="uk-card-title uk-margin-remove">Task Details</h5>
        <status-button :data-task="<?php echo e($task); ?>" :data-exists="<?php echo e($task->exists ? 'true' : 'false'); ?>" activate-url="<?php echo e(route('totem.task.activate')); ?>" deactivate-url="<?php echo e(route('totem.task.deactivate', $task)); ?>"></status-button>
    </div>
<?php $__env->stopSection(); ?>

Happens in production and in local but only on this particular project. Any ideas on what could be causing it?

For context: I'm on Forge, using Digital Ocean, PHP7.1, and Redis. And like I said, it works on other projects with the same set up, but not this one.

roshangautam commented 6 years ago

did you delete a task from database directly ? Try clearing the app cache using the following command:

php artisan clear:cache

and see what happens.

alexstone commented 6 years ago

This error was throwing since the first time I installed it. In an attempt to fix/"reset" things, I manually truncated the tables and cleared the cache, but the error persists. I can create a task no problem, I just can't edit or view it.

alexstone commented 6 years ago

Some more data if this helps. After studying the two environments very carefully, the only difference I found is that the project Totem has no issues on has a utf8mb4_unicode_ci encoded database and the one that breaks is utf8_unicode_ci encoded. Both are InnoDB

roshangautam commented 6 years ago

I am sorry this is taking this long. My schedule is crazy. I will take a look as soon as I get time.

jakub-klapka commented 6 years ago

Hello, I have same problem. It seems, that you are counting on implicit model binding with model name only.

In routes, you have: Route::get('{task}', 'TasksController@view')->name('totem.task.view');

and that view method does not has typehinted model: public function view($task)

Probably, this kind of model binding does not work in all cases. I believe, that Lara documentation also specifies, that you should use model class as typehint. When I add that like public function view( Task $task ), it works.

I'm using MS SQL and Doctrine as my ORM, but I didn't dig deep into how model binding works, so it might be related or not.

Thanks, Jakub

roshangautam commented 6 years ago

This should be working fine in the latest release