Answer the question
In order to leave comments, you need to log in
Is it possible to define a function in the table property of a Laravel Model?
Colleagues, help out. In my database (the database is built on a separate schema that is not tied to migrations) there is a function lst_books_hist (?) (which we pass the ID and it returns a line from the table of obsolete books)
class BooksListHist extends Model
{
protected $connection = 'db_main';
protected $table = 'lst_books_hist(?)'; --> могу ли я вот так сделать?
}
Answer the question
In order to leave comments, you need to log in
I do not think that it will be possible to implement this in the form of a model.
Make a repository that will implement the query logic and DTO that will hold the values of the table row fields.
However, you can try this:
(new BooksListHist)
->setTable("lst_books_hist({$IdFilter['value']})")
->first();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question