Answer the question
In order to leave comments, you need to log in
Laravel: How to make a handler-model?
Good afternoon, this question is still ripe in CodeIgniter, I worked with models as follows:
After creating the model and the function in it, I applied by passing the parameters
$this->model_my->function($param...$params)
to the output. what the function returns in the model, and already gave it to the view.
Attention the question is how to implement this in Laravel? Throw a guide at me, otherwise I didn’t find it =(
Answer the question
In order to leave comments, you need to log in
<?php
class MySuperModel extends Eloquent
{
public function mySuperFunction($param1 = null, $param2 = null)
{
return [$param1, $param2, $this->id];
}
}
$model = MySuperModel::find(1); // 1 это ID модели в базе
$result = $model->mySuperFunction(100, 200);
print_r($result);
/*
Array
(
[0] => 100
[1] => 200
[2] => 1 // ID модели $this->id
)
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question