Extending Doorstep

Templates

One of the first things you'll want to extend and overwrite in Doorstep is the frontend views and templates, making up the HTML that is sent to the browser.

Doorstep is set up with some core templates and views as part of the framework. By default these are not included in your application, but you can view these in the folder vendor/doorstep/framework/resources/views. Any files that exist in your application's own resources/views directory are used before looking inside the framework.

To copy the Doorstep views run the command (within your main directory)

php artisan doorstep:views

Or manually copy over only the files you want to override (using the same directory structure) and Doorstep will use them instead.

For more information, see Templates.

Configuration

Like any project, Doorstep uses configuration files to change certain behaviour or store settings that you might want to update.

When you install Doorstep, any configuration files we use will be copied in your config directory. This is your local copy, so you can update the values in these files to suit your application.

The list of configuration files we use for Doorstep 1.0 is:

  • attributes.php
  • media.php
  • property.php
  • upload.php
  • user.php
  • feed.php
  • permissions.php
  • site.php
  • url.php

Anything

As a Laravel application, Doorstep uses the built-in service container to manage class injection, dependencies and resolution.

In your own app/Providers/AppServiceProvider.php file, you could bind your own implementation of any of Doorstep's core classes, overwriting the entire class or extending with your own code.

For a simple example, let's say you wanted to overwrite the Pages controller with your own class.

1) Create your own class, extending the core Doorstep class if you want to inherit the original methods, for instance app/Http/Controllers/Pages.php

<?php 

namespace App\Http\Controllers;

use Doorstep\Http\Controllers\Front\Pages as DoorstepPages;

class Pages extends DoorstepPages {

    public function getHome()
    {
        // change this method however you wish.
        // for instance pass the featured properties to use in a slider.

        $repository = app('Doorstep\Properties\PropertyRepository');

        return view('pages.home')
                    ->with('properties', $repository->getFeatured());
    }

}

2) You need to tell Laravel's container to use your class over Doorstep's core class.

In your AppServiceProvider class' register method, use the following code:

$this->app->bind('Doorstep\Http\Controllers\Front\Pages', 'App\Http\Controllers\Pages');

3) In your resources/views/pages/home.blade.php you can display the featured properties using the $properties variable.