Skip to content

Extending tutorial

Eugene Min edited this page Feb 15, 2016 · 1 revision

Extending Mconsole Page section

Before you start this tutorial you need to install package and add Mconsole middleware first.

Routing

Start with overwriting Mconsole routes:

# app/Http/routes.php
Route::group(['prefix' => 'mconsole', 'middleware' => ['web', 'mconsole']], function () {
Route::resource('/pages', 'PagesController');
});

You can see all mconsole routes by executing artisan command: php artisan route:list --path=mconsole.

Controller

Create a new controller:

$ php artisan make:controller PageController --resource

Extend it with PageController from Mconsole package:

# app/Http/Controllers/PageController.phpuseMilax\Mconsole\Http\Controllers\PageControllerasBasePageController;
class PageController extends BasePageController
{
/** * Your custom index method. */publicfunctionindex()
{
// This will load view from resources/views/mconsole/pages/ in APP, not from package$this->view('mconsole.pages.list');
// To load view from Mconsole package, use $this->view('mconsole::mconsole.pages.list');
}
}

View

Create a view file in resources/views/mconsole/pages/list.blade.php:

@extends('mconsole::app')
@section('title', 'Pages | Mconsole')
@section('content')
<div>Your custom page content</div>
@endsection

That's it!

You can also create new sections, without extending existing.

Clone this wiki locally