Laravel Model Get Attribute Without Mutator Example
Hello Friends,
In this blog, I will show you how to get model attribute without mutator in laravel application. We will talk about laravel model get attribute without mutator example. This tutorial will give you how to get attribute without mutator.
We will show get attribute without mutator in laravel application. In this example I will give you simple and easy way to get attribute without mutator in laravel application.
Here i will give you full example for how to get model attribute without mutator in laravel application. So let's see the bellow example:
In this example, i have a "User" model with following fields :
- name
- password
- created_at
- updated_at
Define Method in Model
public function getOriginalValueAttribute($field)
{
return $this->attributes[$field];
}
Route::get('user', function (){
$user = \App\Models\User::find(1);
dd($user->getOriginal('name'));
});
It will help you....
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial