Support the ongoing development of Laravel.io →
Database Views Blade
Last updated 1 year ago.
0

You can extend yours controllers using a base controller:

  • app/controllers/base.php

    <?php namespace App\Controllers; use Controller, DB; class Base extends Controller { { public function __construct() { parent::__construct(); $user = DB::table('users')->first(); $user->points += 1; $user->save(); View::share([ 'points' => $user->points ]); } }
  • app/controllers/home.php

    <?php namespace App\Controllers; use View; class Home extends Base { { public function home() { return View::make('home'); } }

Regards, Lito.

Last updated 1 year ago.
0

Fucking laravel.io code format...

You can extend yours controllers using a base controller:

  • app/controllers/base.php

<?php
namespace App\Controllers;

use Controller, DB;

class Base extends Controller {
{
    public function __construct()
    {
        parent::__construct();

        $user = DB::table('users')->first();
        $user->points += 1;
        $user->save();

        View::share([
            'points' => $user->points
        ]);
    }
}

  • app/controllers/home.php

<?php
namespace App\Controllers;

use View;

class Home extends Base {
{
    public function home()
    {
        return View::make('home');
    }
}

Regards, Lito.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

DrummerSi drummersi Joined 27 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.