class Test extends Model {
private static $_prefix = '_prefix';
public function __construct(array $attributes = array()) {
// parent::__construct($attributes);
self::$prefix = 'abc';
}
public static function custom_table(){ return self::$_prefix.'table_name'; }
}
Thanks ilinovster
But Constructor not work self::$prefix = 'abc'; When I call in public static function custom_table(){ return self::$_prefix.'table_name'; }
I define method setPrefix() and call self::setPrefix() // working
[php] class Test extends Model {
protected $table = 'lang_values';
// private static $_prefix = '';
/*
public function __construct(array $attributes = array()) {
self::$prefix = 'abc';
}
*/
public static function setPrefix() {
$prefix = config('app._prefix');
return $prefix[0];
}
public static function service_table(){
return self::setPrefix().'table_name';
}
public static function getAll()
{
echo $cont = self::service_table();
return DB::select("select * from $cont where avail = 1");
}
}
[php]
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community