Expand API.

This commit is contained in:
James Cole
2020-11-15 14:02:29 +01:00
parent 20e7948d99
commit eb616f36ea
6 changed files with 152 additions and 27 deletions

View File

@@ -43,6 +43,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string spent
* @property int $transaction_currency_id
* @property TransactionCurrency $transactionCurrency
* @property string $repeat_freq
* @property bool @auto_budget
* @method static Builder|BudgetLimit newModelQuery()
* @method static Builder|BudgetLimit newQuery()
* @method static Builder|BudgetLimit query()
@@ -65,10 +67,11 @@ class BudgetLimit extends Model
*/
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_date' => 'date',
'end_date' => 'date',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_date' => 'date',
'end_date' => 'date',
'auto_budget' => 'boolean',
];
/** @var array Fields that can be filled */
@@ -79,13 +82,13 @@ class BudgetLimit extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): BudgetLimit
{
if (auth()->check()) {
$budgetLimitId = (int) $value;
$budgetLimitId = (int)$value;
$budgetLimit = self::where('budget_limits.id', $budgetLimitId)
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', auth()->user()->id)