Answer the question
In order to leave comments, you need to log in
How to correctly transfer from one model to another Laravel?
Now there is middleware
public function handle($request, Closure $next)
{
$storeId = Store::id();
if (empty($storeId)) {
abort(404);
}
return $next($request);
}
static function id(){
$domain = $_SERVER['SERVER_NAME'];
if (!empty(Store::select('*')->where('domain', $domain)->first())) {
$store = Store::select(['id'])->where('domain', $domain)->first()->toArray();
return $store['id'];
} else {
return false;
}
}
public function __construct(array $attributes = [])
{
$stoteId = Store::id();
$this->table = $stoteId . '_category';
parent::__construct($attributes);
}
Answer the question
In order to leave comments, you need to log in
Indeed, why just write store_id in the category table. Let's spawn dozens of tables for each virtual store! Uhhh, how great it will be when there are under 100 stores in the database. Just a couple of thousand tables, spit it out. This will be easy to figure out!
Now, no sarcasm.
Urgently remake the structure of your database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question