New translations and routes.

This commit is contained in:
James Cole
2018-06-29 12:11:44 +02:00
parent f048e943f8
commit 8c28c4b5ac
22 changed files with 234 additions and 60 deletions

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Crypt;
use Exception;
use FireflyIII\Exceptions\FireflyException;
@@ -29,12 +30,16 @@ use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Model;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Preference.
*
* @property mixed $data
* @property string $name
* @property Carbon $updated_at
* @property Carbon $created_at
* @property int $id
*/
class Preference extends Model
{
@@ -52,6 +57,25 @@ class Preference extends Model
/** @var array */
protected $fillable = ['user_id', 'data', 'name'];
/**
* @param string $value
*
* @return Account
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public static function routeBinder(string $value): Preference
{
if (auth()->check()) {
$preferenceId = (int)$value;
$preference = auth()->user()->preferences()->find($preferenceId);
if (null !== $preference) {
return $preference;
}
}
throw new NotFoundHttpException;
}
/**
* @param $value
*