{"id":127650,"date":"2024-04-18T15:40:45","date_gmt":"2024-04-18T19:40:45","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/?p=127650"},"modified":"2024-05-10T09:55:43","modified_gmt":"2024-05-10T13:55:43","slug":"introduction-to-laravel-eloquent","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/","title":{"rendered":"Introduction to Laravel Eloquent"},"content":{"rendered":"<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent-1024x538.png\" alt=\"Introduction to Laravel Eloquent\" class=\"wp-image-127653\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent-1024x538.png 1024w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent-300x158.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent-768x403.png 768w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png 1200w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/\" target=\"_blank\" rel=\"noreferrer noopener\">Laravel<\/a> has consistently delivered robust tools for developers, enhancing productivity and simplifying common web development tasks. One of the standout components of Laravel is <a href=\"https:\/\/laravel.com\/docs\/11.x\/eloquent\" target=\"_blank\" rel=\"noreferrer noopener\">Eloquent<\/a>, its Object-Relational Mapping (ORM) system, designed to simplify database interactions using an active record implementation.<\/p>\n\n\n<div class=\"jumbotron\">\r\n<p>Boost your Laravel apps with our specialized <a href=\"https:\/\/www.inmotionhosting.com\/laravel-hosting\">Laravel Hosting<\/a>. Experience faster speeds for your Laravel applications and websites thanks to NVMe storage, server protection, dedicated resources, and optimization tools.<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>99.99% Uptime    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Free SSL    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Dedicated IP Address    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Developer Tools<\/p>\r\n<p><a class=\"btn btn-primary btn-lg\" href=\"https:\/\/www.inmotionhosting.com\/laravel-hosting\">Laravel Hosting<\/a><\/p>\r\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before diving into Eloquent, you must have Laravel installed. If you haven\u2019t already completed this step, please see our <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/how-to-install-laravel\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Install Laravel article<\/a>. A database must also be configured in the <code>.env<\/code> file at the root of your Laravel installation. See <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/how-to-configure-the-laravel-env-for-a-database\/\" target=\"_blank\" rel=\"noreferrer noopener\">How To Configure the Laravel .env for a Database<\/a> to help you with that step if you haven\u2019t done so already. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Eloquent Models<\/h2>\n\n\n\n<p>Eloquent models are central to Eloquent ORM, which stands for Object-Relational Mapping. An ORM is a technique that lets you query and manipulate data from a database using an object-oriented paradigm. Essentially, it creates a virtual object database that can be used from within a programming language to manipulate data. This means developers can work with data as if they were working with objects in their programming language rather than dealing with SQL queries directly.<\/p>\n\n\n\n<p>With Eloquent, each model you create in Laravel represents a specific table in your database and each instance of a model corresponds to a row in that table. This mapping of tables to models and rows to instances simplifies the CRUD (Create, Read, Update, Delete) operations in the database.<\/p>\n\n\n\n<p>Here\u2019s how you can create an Eloquent model:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"php artisan make:model Post\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #B392F0\">php<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">artisan<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">make:model<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">Post<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This command creates a <code>Post<\/code> model for a <code>posts<\/code> database table. By default, Laravel assumes the table name is the plural form of the model name unless explicitly specified otherwise. You can define relationships, specify the database connection, and customize table names directly within these model classes, harnessing the full power of object-oriented programming to manage your database.<\/p>\n\n\n\n<p>This abstraction allows developers to focus more on the application\u2019s functionality and less on the details of SQL syntax, leading to more robust and maintainable code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Retrieving Data<\/h2>\n\n\n\n<p>Eloquent simplifies data retrieval with several methods that cover common use cases:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>find($id)<\/code> retrieves a model by its primary key.<\/li>\n\n\n\n<li><code>all()<\/code> fetches all records from the model\u2019s database table.<\/li>\n\n\n\n<li><code>where('column', 'value')<\/code> allows condition-based queries.<\/li>\n\n\n\n<li><code>first()<\/code> returns the first record found in the query.<\/li>\n<\/ul>\n\n\n\n<p>Here\u2019s an example of using Eloquent to retrieve posts with a specific condition:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"$posts = Post::where('status', 'published')-&gt;get();\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">$posts <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">Post<\/span><span style=\"color: #F97583\">::<\/span><span style=\"color: #B392F0\">where<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">'status'<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">'published'<\/span><span style=\"color: #E1E4E8\">)<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #B392F0\">get<\/span><span style=\"color: #E1E4E8\">();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Inserting and Updating Data<\/h2>\n\n\n\n<p>To create a new record, you instantiate a new model instance, set attributes, and call the <code>save()<\/code> method:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"$post = new Post;\n$post-&gt;title = 'New Post Title';\n$post-&gt;content = 'Content of the post';\n$post-&gt;save();\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">$post <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">new<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">Post<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">$post<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #E1E4E8\">title <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">'New Post Title'<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">$post<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #E1E4E8\">content <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">'Content of the post'<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">$post<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #B392F0\">save<\/span><span style=\"color: #E1E4E8\">();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Updating data follows a similar pattern but starts with fetching a model instance:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"$post = Post::find(1);\n$post-&gt;title = 'Updated Title';\n$post-&gt;save();\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">$post <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">Post<\/span><span style=\"color: #F97583\">::<\/span><span style=\"color: #B392F0\">find<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">$post<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #E1E4E8\">title <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">'Updated Title'<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">$post<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #B392F0\">save<\/span><span style=\"color: #E1E4E8\">();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Deleting Data<\/h2>\n\n\n\n<p>Deleting data is straightforward with Eloquent. To delete a model:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"$post = Post::find(1);\n$post-&gt;delete();\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">$post <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">Post<\/span><span style=\"color: #F97583\">::<\/span><span style=\"color: #B392F0\">find<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">$post<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #B392F0\">delete<\/span><span style=\"color: #E1E4E8\">();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>For soft deletes, which allow records to be restored, enable them in your model by using the <code>SoftDeletes<\/code> trait:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"use Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass Post extends Model\n{\n    use SoftDeletes;\n}\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">use<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">Illuminate\\Database\\Eloquent\\SoftDeletes<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">class<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">Post<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">extends<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">Model<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">use<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">SoftDeletes<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Relationships in Eloquent<\/h2>\n\n\n\n<p>Eloquent supports several types of relationships:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>One-to-One<\/strong>: Each model holds a reference to one related model.<\/li>\n\n\n\n<li><strong>One-to-Many<\/strong>: A model can be associated with multiple models.<\/li>\n\n\n\n<li><strong>Many-to-Many<\/strong>: Models are connected through a pivot table.<\/li>\n<\/ul>\n\n\n\n<p>Defining a relationship is done within a model:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"public function user()\n{\n    return $this-&gt;belongsTo(User::class);\n}\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">public<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">function<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">user<\/span><span style=\"color: #E1E4E8\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">$this<\/span><span style=\"color: #F97583\">-&gt;<\/span><span style=\"color: #B392F0\">belongsTo<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">User<\/span><span style=\"color: #F97583\">::class<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced Eloquent Features<\/h2>\n\n\n\n<p>Eloquent provides features to refine your database interactions further:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Eager Loading<\/strong>: Prevents the N+1 query problem with <code>with()<\/code> method.<\/li>\n\n\n\n<li><strong>Mutators and Accessors<\/strong>: Customize how you set and get attributes on your models.<\/li>\n\n\n\n<li><strong>Scopes<\/strong>: Define common queries in your models to reuse throughout your application.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices with Laravel 11 Eloquent<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Keep Eloquent queries efficient<\/strong>: Avoid excessive database calls by utilizing eager loading.<\/li>\n\n\n\n<li><strong>Use Scopes<\/strong>: To maintain cleaner controllers and reuse query logic.<\/li>\n\n\n\n<li><strong>Select Eloquent or Query Builder<\/strong>: Use Eloquent for most database interactions, but switch to the Query Builder for complex queries for performance optimizations.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Eloquent ORM in Laravel 11 offers an efficient and elegant way to interact with your database. With its active record implementation, Eloquent allows you to write database queries with PHP syntax rather than SQL. This not only speeds up the development process but also ensures clarity and maintainability of your code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel has consistently delivered robust tools for developers, enhancing productivity and simplifying common web development tasks. One of the standout components of Laravel is Eloquent, its Object-Relational Mapping (ORM) system, designed to simplify database interactions using an active record implementation. Prerequisites Before diving into Eloquent, you must have Laravel installed. If you haven&#8217;t already completed<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57032,"featured_media":127653,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4486],"tags":[],"class_list":["post-127650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Introduction to Laravel Eloquent | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn the basics of Laravel Eloquent ORM for efficient database management and streamlined PHP development.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to Laravel Eloquent | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn the basics of Laravel Eloquent ORM for efficient database management and streamlined PHP development.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-18T19:40:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-10T13:55:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Derrell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Derrell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\"},\"author\":{\"name\":\"Derrell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/0736f70b4077032374f89709cdc255b7\"},\"headline\":\"Introduction to Laravel Eloquent\",\"datePublished\":\"2024-04-18T19:40:45+00:00\",\"dateModified\":\"2024-05-10T13:55:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\"},\"wordCount\":642,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png\",\"articleSection\":[\"Laravel\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\",\"name\":\"Introduction to Laravel Eloquent | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png\",\"datePublished\":\"2024-04-18T19:40:45+00:00\",\"dateModified\":\"2024-05-10T13:55:43+00:00\",\"description\":\"Learn the basics of Laravel Eloquent ORM for efficient database management and streamlined PHP development.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png\",\"width\":1200,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introduction to Laravel Eloquent\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/0736f70b4077032374f89709cdc255b7\",\"name\":\"Derrell\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/derrell-willis\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/derrellw\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to Laravel Eloquent | InMotion Hosting","description":"Learn the basics of Laravel Eloquent ORM for efficient database management and streamlined PHP development.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/","og_locale":"en_US","og_type":"article","og_title":"Introduction to Laravel Eloquent | InMotion Hosting","og_description":"Learn the basics of Laravel Eloquent ORM for efficient database management and streamlined PHP development.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2024-04-18T19:40:45+00:00","article_modified_time":"2024-05-10T13:55:43+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png","type":"image\/png"}],"author":"Derrell","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Derrell","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/"},"author":{"name":"Derrell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/0736f70b4077032374f89709cdc255b7"},"headline":"Introduction to Laravel Eloquent","datePublished":"2024-04-18T19:40:45+00:00","dateModified":"2024-05-10T13:55:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/"},"wordCount":642,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png","articleSection":["Laravel"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/","name":"Introduction to Laravel Eloquent | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png","datePublished":"2024-04-18T19:40:45+00:00","dateModified":"2024-05-10T13:55:43+00:00","description":"Learn the basics of Laravel Eloquent ORM for efficient database management and streamlined PHP development.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png","width":1200,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/introduction-to-laravel-eloquent\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Introduction to Laravel Eloquent"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/0736f70b4077032374f89709cdc255b7","name":"Derrell","sameAs":["https:\/\/www.linkedin.com\/in\/derrell-willis"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/derrellw\/"}]}},"jetpack_featured_media_url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2024\/04\/laravel-eloquent.png","jetpack_sharing_enabled":true,"primary_category":{"id":4486,"name":"Laravel","slug":"laravel","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/laravel\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/127650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57032"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=127650"}],"version-history":[{"count":2,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/127650\/revisions"}],"predecessor-version":[{"id":127655,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/127650\/revisions\/127655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media\/127653"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=127650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=127650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=127650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}