Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show items count for each plan in list of plans #32

Closed
matthiku opened this issue Feb 19, 2016 · 2 comments
Closed

Show items count for each plan in list of plans #32

matthiku opened this issue Feb 19, 2016 · 2 comments
Assignees

Comments

@matthiku
Copy link
Owner

In order to see whether a plan has been expanded or worked on already.

Another feature could be to show the date of the last update of any item in the plan. At the moment, the 'last updated' only shows the date when the plan properties have been last changed.

@matthiku matthiku self-assigned this Feb 19, 2016
@matthiku
Copy link
Owner Author

Part 1 Implemented - Show items count

Files changed: plans.blade.php
  • Added header cell: <th class="hidden-sm-down center"># items</th>
  • added table cell: <td class="hidden-sm-down center">{{ $plan->items->count() }}</td>

TODO:

  • Show last change date of a plan and its items.

A more cpu-saving solution for the second suggestion is to always update the plan 'updated_at' field whenever an item of this plan was changed.

@matthiku
Copy link
Owner Author

Part 2 implemented - Show name of last changer

Files changed:
  • AppServiceProvider.php
    Added these lines into the boot() method:
        Item::updated( function ($item) {
            // when a user changes an item, we 
            // update the 'changer' field on the parent model (plan)
            $plan = Plan::find($item->plan_id);
            $plan->update(['changer' => Auth::user()->first_name]);
        });

  • Item.php (the model)
    added this line:
    protected $touches = ['plan'];

matthiku added a commit that referenced this issue Feb 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant