в базе данных у меня есть несколько таблиц:
tblcustomfieldsvalues
select * from tblcustomfieldsvalues limit 22;
+-----+---------+-------+----------------------+---------------------+---------------------+
| id | fieldid | relid | value | created_at | updated_at |
+-----+---------+-------+----------------------+---------------------+---------------------+
| 32 | 1 | 22 | Windows2008 | 2018-08-14 20:18:45 | 2018-08-14 20:18:45 |
| 33 | 2 | 22 | | 2018-08-14 20:18:45 | 2018-08-14 20:18:45 |
| 36 | 1 | 24 | Windows2008 | 2018-08-18 01:50:15 | 2018-08-18 01:50:15 |
| 37 | 2 | 24 | | 2018-08-18 01:50:15 | 2018-08-18 01:50:15 |
fieldid
относится к таблице tblcustomfields
, relid
являетсяотносится к таблице tblhosting
.
tblcustomfields
:
mysql> select * from tblcustomfields limit 22;
+----+---------+-------+-----------------------------+-----------+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+-----------+----------+-----------+-------------+-----------+---------------------+---------------------+
| id | type | relid | fieldname | fieldtype | description | fieldoptions | regexpr | adminonly | required | showorder | showinvoice | sortorder | created_at | updated_at |
+----+---------+-------+-----------------------------+-----------+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+-----------+----------+-----------+-------------+-----------+---------------------+---------------------+
| 1 | product | 1 | operating_system | dropdown | Operating system | Windows2008,Windows2012,Windows2016,Windows2019CentOS6.5,CentOS6.9,CentOS7.0,CentOS7.2.,CentOS7.4,,CentOS7.5,CentOS7.6,Ubuntu14.04,Ubuntu16.04,,Ubuntu18.04 | | | on | on | on | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
| 2 | product | 1 | Other systems please note 1 | text | Other systems please note | Windows2008,Windows2012,Windows2016,Windows2019CentOS6.5,CentOS6.9,CentOS7.0,CentOS7.2.,CentOS7.4,,CentOS7.5,CentOS7.6,Ubuntu14.04,Ubuntu16.04,,Ubuntu18.04 | | | | on | on | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
| 3 | product | 2 | Operating system | dropdown | | Windows2008,Windows2012,Windows2016,Windows2019CentOS6.5,CentOS6.9,CentOS7.0,CentOS7.2.,CentOS7.4,,CentOS7.5,CentOS7.6,Ubuntu14.04,Ubuntu16.04,Ubuntu18.04 | | | | on | on | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
3. tblhosting
:
---+--------+---------+-----------+--------+------------+-------------------------------------------------+---------------+--------------------+--------+--------------+-------------+-----------------+------------------+----------------+--------------+----------+------------------------------+----------------------------------------------------------------------------------------------------+----------------+---------+---------------+--------------------+---------------------+------------------+------------------------------------------------------------------------+-----+-----+-----------+-----------+---------+---------+---------------------+---------------------+---------------------+
| id | userid | orderid | packageid | server | regdate | domain | paymentmethod | firstpaymentamount | amount | billingcycle | nextduedate | nextinvoicedate | termination_date | completed_date | domainstatus | username | password | notes | subscriptionid | promoid | suspendreason | overideautosuspend | overidesuspenduntil | dedicatedip | assignedips | ns1 | ns2 | diskusage | disklimit | bwusage | bwlimit | lastupdate | created_at | updated_at |
+----+--------+---------+-----------+--------+------------+-------------------------------------------------+---------------+--------------------+--------+--------------+-------------+-----------------+------------------+----------------+--------------+----------+------------------------------+----------------------------------------------------------------------------------------------------+----------------+---------+---------------+--------------------+---------------------+------------------+------------------------------------------------------------------------+-----+-----+-----------+-----------+---------+---------+---------------------+---------------------+---------------------+
| 22 | 6 | 21 | 1 | 0 | 2018-08-14 | L03-C7 | paypal | 60.00 | 60.00 | Monthly | 2019-09-14 | 2019-09-14 | 2019-09-11 | 0000-00-00 | Cancelled | | /zDhhj6VB5tidajPpP| | | 0 | | 0 | 0000-00-00 | 14.12.4.113-117 |
| | | 0 | 0 | 0 | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
+----+--------+---------+-----------+--------+------------+-------------------------------------------------+---------------+--------------------+--------+--------------+-------------+-----------------+------------------+----------------+--------------+----------+------------------------------+----------------------------------------------------------------------------------------------------+----------------+---------+---------------+--------------------+---------------------+------------------+------------------------------------------------------------------------+-----+-----+-----------+-----------+---------+---------+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)
Я использую Capule
для менеджера баз данных:
use Illuminate\Database\Capsule\Manager as Capsule;
Я могу только запросить базу данных следующим образом:
$products = Capsule::table('tblhosting')->where('domainstatus', 'Active')->where('bwlimit', '!=', null)->get();
Но я хочу запросить $products
, какой элемент содержит customfields
.
Например, $product
как элемент $products
, он может использовать как $product->operating_system
для получения своего пользовательского поля.