Package Data | |
---|---|
Maintainer Username: | neilcrookes |
Maintainer Contact: | neil.crookes@fivebyfiveuk.com (Neil Crookes) |
Package Create Date: | 2014-03-05 |
Package Last Update: | 2014-04-15 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:04:53 |
Package Statistics | |
---|---|
Total Downloads: | 509 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 3 |
Total Forks: | 1 |
Total Open Issues: | 0 |
A Laravel 4 package for adding multiple, content managed, multiple-choice competitions to a website.
Add the following to you composer.json file (Recommend swapping "dev-master" for the latest release)
"fbf/laravel-competitions": "dev-master"
Run
composer update
Add the following to app/config/app.php
'Fbf\LaravelCompetitions\LaravelCompetitionsServiceProvider'
Run the package migration
php artisan migrate --package=fbf/laravel-competitions
Publish the config
php artisan config:publish fbf/laravel-competitions
Optionally tweak the settings in the many config files for your app
Optionally copy the administrator config file (src/config/administrator/competitions.php
) to your administrator model config directory.
Create the relevant image upload directories that you specify in your config, e.g.
public/uploads/packages/fbf/laravel-competitions/main_image/original
public/uploads/packages/fbf/laravel-competitions/main_image/thumbnail
public/uploads/packages/fbf/laravel-competitions/main_image/resized
The package comes with a seed that can populate the table with a whole bunch of sample posts. There are some configuration options for the seed in the config file. To run it:
php artisan db:seed --class="Fbf\LaravelCompetitions\FakeCompetitionsSeeder"
See the many configuration options in the files in the config directory
You can use the excellent Laravel Administrator package by FrozenNode to administer your competitions.
http://administrator.frozennode.com/docs/installation
A ready-to-use model config file for the Post model (competitions.php) is provided in the src/config/administrator directory of the package, which you can copy into the app/config/administrator directory (or whatever you set as the model_config_path in the administrator config file).
The package should work out the box (provided you have a master blade layout file, since the out-of-the-box views extend this) but if you want to add other content to the pages, such as your own header, logo, navigation, sidebar etc, you'll want to override the views provided.
The package views declare several sections that you may want to yield
in your app/views/layouts/master.blade.php
file, e.g.:
<!DOCTYPE html>
<html>
<head>
<title>@yield('title')</title>
<meta name="description" content="@yield('meta_description')">
<meta name="keywords" content="@yield('meta_keywords')">
</head>
<body>
<div class="content">
@yield('content')
</div>
</body>
</html>
The package's views are actually really simple, and most of the presentation is done in partials. This is deliberate so you can override the package's views in your own app, so you can include your own chrome, navigation and sidebars etc, yet you can also still make use of the partials provided, if you want to.
To override any view in your own app, just create the following directories and copy the file from the package into it, then hack away
app/views/packages/fbf/laravel-competitions/competitions
app/views/packages/fbf/laravel-competitions/partials
This can be done for the purposes of say, relating the Competition model to a Category model and allowing filtering by category, or relating the Competition model to a User model to add and Author to a Competition, or simply just for overriding the functionality in the bundled Competition model.
(See the example below for more specific information.)
To override the Competition
model in the package, create a model in you app/models directory that extends the package model.
Finally, update the IoC Container to inject an instance of your model into the Fbf\LaravelCompetitions\CompetitionsController
,
instead of the package's model, e.g. in app/start/global.php
App::bind('Fbf\LaravelCompetitions\CompetitionsController', function() {
return new Fbf\LaravelCompetitions\CompetitionsController(new Competition);
});