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.
Fucking laravel.io code format...
You can extend yours controllers using a base controller:
<?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
]);
}
}
<?php
namespace App\Controllers;
use View;
class Home extends Base {
{
public function home()
{
return View::make('home');
}
}
Regards, Lito.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community