From db1b417049de4ba64969a2222ca8508b67a021a0 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Sat, 16 Jul 2016 22:04:36 +0100 Subject: [PATCH] Add configuration section to readme --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index 810af90..50a8d20 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,9 @@ $feed->markAsRead($notification); ## Navigation - [Installation](#installation) +- [Configuration](#configuration) + - [Changing the Notification Model](#changing-the-notification-model) + - [Adding a Driver](#adding-a-driver) - [Using the Feed](#using-the-feed) - [Setting Up Notifiable Models](#setting-up-notifiable-models) - [Notifiable Groups](#notifiable-groups) @@ -79,6 +82,44 @@ The package comes with a default migration to create the database structure for The package comes with `feed.php` config file. This allows you to customise the database driver you are using with the package. At present only eloquent is supported, but we are working on a laravel db driver currently. +### Changing the Notification Model + +From time to time you may need to add additional methods or properties to the notification model, for example you might want to add an additional relationship to the notification model. + +This can be done very simply by changing the notification model in the config file as shown below. + +```php +'drivers' => [ + 'eloquent' => [ + 'model' => 'Path\To\Notification', // Update this to your notification model. + ], +] +``` + +The default notification model implements a couple of interfaces that are required by this package. If you need to make changes to the model I recommend extending the default model, otherwise make sure you implement the interfaces. + +```php +// Example of extending the model +class Notification extends \Michaeljennings\Feed\Store\Eloquent\Notification +{ + public function foo() + { + // + } +} + +// Example of just implementing the interfaces +class Notification implements \Michaeljennings\Feed\Contracts\Notification, \Michaeljennings\Feed\Contracts\Store +{ + public function bar() + { + // + } +} +``` + +### Adding a Driver + You may require another driver, i.e. you're using a data store not supported by laravel. If this is the case you can add a driver to the system verify simply as shown below. ```php