T
T
terehinis2017-06-23 16:12:15
Laravel
terehinis, 2017-06-23 16:12:15

How to add property in laravel while saving at model level?

There is a News model, in the database this table has a user_id field user_id
can be obtained by Auth::id()
When adding new news , it is necessary that user_id is automatically substituted from Auth::id()
News::create(['name'=>'Новость 1'])

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2017-06-23
@terehinis

https://laravel.com/docs/5.4/eloquent#events

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question