Pages

Pages Want custom page with your styles and methods ? Custom pages may be generated using the atomic:page Artisan command. By default, all new page will be placed in the atomic-components/pages directory of your application:

php artisan atomic:page Atomic/CustomPage
1

When generating a tool, Artisan will prompt you to update your application's composer.json file. All custom pages are registered with your application as a Composer "path" repository. page name Atomic/CustomPage must be like laravel packages name/packagename so you can upload and share it with other developers ♥.

The generated folder in atomic-components/pages directory will contain

  • routes.php Pages Routes
  • resources/views/index.blade.php for page index view
  • src/SimplePage.php Page Class
  • src/PageServiceProvider.php Page Service Provider
  • src/Http/Controllers/PageController.php Page Controller
  • src/Http/Controllers/BaseController.php Page Base Controller

routes.php

this contain page routes

<?php

Route::get('/','PageController@index')->name('index');
Route::get('/redirect','PageController@redirect')->name('redirect');
1
2
3
4

PageController.php

The Controller for Page routes

class PageController extends BaseController
{

    /**
     * Atomic page index view
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        return view($this->atomicView . '::index');
    }


    /**
      * simple redirect to page routes method
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
      */
     public function redirect()
     {
         return redirect(route($this->atomicPage::routePath('index')));
     }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

SimplePage.php

Page main class

class SimplePage extends AtomicPage
{

}
1
2
3
4

if you want to override any methods for the page.

PageServiceProvider.php

The main provider for the page to register routes and views , but the most important part in this file is:

 /**
  * @throws \ReflectionException
  */
 public function boot()
 {
     AtomicPanel::serving(function (ServingAtomic $event) {
         AtomicPanel::serveScripts([]);
         AtomicPanel::serveStyles([]);
     });
     parent::boot();
 }
1
2
3
4
5
6
7
8
9
10
11

you can use those methods

AtomicPanel::serveScripts([]);
AtomicPanel::serveStyles([]);
1
2

to register any styles or scripts for Atomic Panel layout