You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tables:
CREATE TABLE font_awesome_categories (
`id` binary(26) NOT NULL,
`name` varchar(50) NOT NULL,
);
CREATE TABLE font_awesome_icons (
`id` binary(26) NOT NULL,
`type` varchar(10) NOT NULL,
`prefix` varchar(3) NOT NULL,
`icon` varchar(50) NOT NULL,
`unicode` varchar(10) NOT NULL,
);
CREATE TABLE font_awesome_icon_categories (
`id` binary(26) NOT NULL,
`category_id` binary(26) NOT NULL,
`icon_id` binary(26) NOT NULL,
);
SQL:
select fai.id, fac.category_id, type, prefix, icon, unicode
from font_awesome_icons fai
left join font_awesome_icon_categories fac on fac.icon_id = fai.id
order by icon asc;
Model:
class FontAwesomeIcon extends Model
{
public function categories()
{
return $this->hasManyThrough(
'App\Models\ContentEditor\FontAwesomeCategory',
'App\Models\ContentEditor\FontAwesomeIconCategory',
'icon_id', // Foreign key on faIconCategory table...
'id', // Foreign key on faCategory table...
'id', // Local key on faIcon table...
'category_id' // Local key on faIconCategory table...
);
}
}
Query:
$result = FontAwesomeIcon::leftJoin('font_awesome_icon_categories', 'font_awesome_icon_categories.icon_id', '=', 'font_awesome_icons.id')
->with('categories')
->orderBy('icon')
->get();
Thanks for the library!
I have the following:
The id field is null:
Although I can resolve it for now, by adding a select to the query:
The text was updated successfully, but these errors were encountered: