03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

API 136<br />

.<br />

This was extracted from app/models/Event.php.<br />

Here we’ve created two new accessors which check the count for categories and sponsors. We’ve<br />

also added those two attributes to the $appends array so they are returned when we list (index) all<br />

events or specific (show) events.<br />

.<br />

You can find out more about attribute accessor and mutators at: http://laravel.com/docs/eloquent#accessorsand-mutators.<br />

Using Cache<br />

Laravel 4 provides a great cache mechanism. It’s configured in the same was as the database:<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!