Thing with order and should fix Travis.

This commit is contained in:
James Cole
2015-03-27 07:20:32 +01:00
parent f80de12cb5
commit 6dddd6629d
14 changed files with 103 additions and 46 deletions

View File

@@ -210,6 +210,15 @@ class TransactionController extends Controller
}
/**
* Reorder transactions (which all must have the same date)
*/
public function reorder()
{
$ids = Input::get('items');
}
/**
* @param TransactionJournal $journal
*

View File

@@ -366,6 +366,7 @@ Route::group(
);
Route::post('/transaction/update/{tj}', ['uses' => 'TransactionController@update', 'as' => 'transactions.update']);
Route::post('/transaction/destroy/{tj}', ['uses' => 'TransactionController@destroy', 'as' => 'transactions.destroy']);
Route::post('/transaction/reorder', ['uses' => 'TransactionController@reorder', 'as' => 'transactions.reorder']);
/**
* Auth\Auth Controller

View File

@@ -80,18 +80,36 @@ class FireflyValidator extends Validator
public function validateUniqueAccountForUser($attribute, $value, $parameters)
{
// get account type from data, we must have this:
$type = isset($this->data['what']) ? $this->data['what'] : Input::get('what');
$longType = Config::get('firefly.accountTypeByIdentifier.' . $type);
$dbType = AccountType::whereType($longType)->first();
if (!$dbType) {
$type = isset($this->data['what']) ? $this->data['what'] : null;
// some fallback:
if(is_null($type)) {
$type = Input::get('what');
}
// still null?
if(is_null($type)) {
// find by other field:
$type = isset($this->data['account_type_id']) ? $this->data['account_type_id'] : 0;
$dbType = AccountType::find($type);
} else {
$longType = Config::get('firefly.accountTypeByIdentifier.' . $type);
$dbType = AccountType::whereType($longType)->first();
}
if (is_null($dbType)) {
return false;
}
$query = DB::table('accounts')->where('name', $value)->where('account_type_id', $dbType->id)->where('user_id', Auth::user()->id);
// user id?
$userId = Auth::check() ? Auth::user()->id : $this->data['user_id'];
$query = DB::table('accounts')->where('name', $value)->where('account_type_id', $dbType->id)->where('user_id', $userId);
if (isset($parameters[0])) {
$query->where('id', '!=', $parameters[0]);
}
$count = $query->count();
if ($count == 0) {
return true;
}