Randy_Johnson
2 months ago
5921
3
General

Variable cannot be found in parent controller php

Posted 2 months ago by Randy_Johnson
<?php

namespace App\Http\Controllers\Customer;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class BaseController extends Controller
{
    protected $table;       // Database table name
    protected $p;           // Page
    protected $sf;          // Search functionality 

    public function __construct() {
        
    }

    public function index()
    {
        return view($this->p);
    }

    public function search()
    {
        return view($this->sf);
    }
}
<?php

namespace App\Http\Controllers\Customer;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ProductController extends BaseController
{
    public function __construct() { 
        parent::__construct();
        $this->$table = "products";       
        $this->$p = "user/products";  
        echo "I am here!";          
    }
}

Please sign in or create an account to participate in this conversation.