1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Merge pull request #3977 from turbo124/v2

Fix for regression on refresh route
This commit is contained in:
David Bomba 2020-08-11 20:58:14 +10:00 committed by GitHub
commit 049b778d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 28 deletions

View File

@ -20,9 +20,7 @@ class NinjaTranslator extends Translator
list($namespace, $group, $item) = $this->parseKey($key);
if(null === $locale)
{
$locale = $this->locale;
}
// Load given group defaults if exists
$this->load($namespace, $group, $locale);

View File

@ -242,11 +242,14 @@ class LoginController extends BaseController
*/
public function refresh(Request $request)
{
$company_token = CompanyToken::whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])
->first();
$company_token = CompanyToken::whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])->first();
$cu = CompanyUser::query()
->where('user_id', $company_token->user_id)
->where('company_id', $company_token->company_id);
//$ct = CompanyUser::whereUserId(auth()->user()->id);
return $this->refreshResponse($company_token->company_user());
return $this->refreshResponse($cu);
}
/**

View File

@ -34,6 +34,8 @@ class DocumentController extends BaseController
{
parent::__construct();
$this->middleware('password_protected', ['only' => ['destroy']]);
$this->document_repo = $document_repo;
}
@ -117,6 +119,7 @@ class DocumentController extends BaseController
*/
public function destroy(DestroyDocumentRequest $request, Document $document)
{
$this->document_repo->delete($document);
return response()->json(['message'=>'success']);

View File

@ -50,8 +50,8 @@ class QueryLogging
Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
// if($count > 700)
// Log::info($queries);
// if($count > 100)
// Log::info($queries);
}
}

View File

@ -64,28 +64,17 @@ class ActivityRepository extends BaseRepository
{
$backup = new Backup();
// if(get_class($entity) == Client::class)
// $settings = $entity->getMergedSettings();
// else
// $settings = $entity->client->getMergedSettings();
// $entity->clientMergedDettings = $settings;
if (get_class($entity) == Client::class) {
$entity->load('company');
} elseif (get_class($entity) == User::class) {
} else {
$entity->load('company', 'client');
}
if (get_class($entity) == Invoice::class && ($activity->activity_type_id == Activity::MARK_SENT_INVOICE || $activity->activity_type_id == Activity::PAID_INVOICE)) {
//$backup->html_backup = $this->generateInvoiceHtml($entity->design(), $entity);
$backup->html_backup = $this->generateEntityHtml($entity->getEntityDesigner(), $entity);
}
// if (get_class($entity) == Client::class) {
// $entity->load('company');
// } elseif (get_class($entity) == User::class) {
// } else {
// $entity->load('company', 'client');
// }
$backup->html_backup = $this->generateEntityHtml($entity->getEntityDesigner(), $entity);
$backup->activity_id = $activity->id;
$backup->json_backup = $entity->toJson();
$backup->json_backup = '';
//$backup->json_backup = $entity->toJson();
$backup->save();
}

View File

@ -252,7 +252,6 @@ class BaseRepository
/* Get array of Keys which have been removed from the invitations array and soft delete each invitation */
$model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) use($resource){
// $this->getInvitation($invitation, $resource)->delete();
$invitation_class = sprintf("App\\Models\\%sInvitation", $resource);
$invitation = $invitation_class::whereRaw("BINARY `key`= ?", [$invitation])->first();

View File

@ -102,6 +102,9 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::post('migration/purge/{company}', 'MigrationController@purgeCompany')->middleware('password_protected');
Route::post('migration/purge_save_settings/{company}', 'MigrationController@purgeCompanySaveSettings')->middleware('password_protected');
Route::post('companies/purge/{company}', 'MigrationController@purgeCompany')->middleware('password_protected');
Route::post('companies/purge_save_settings/{company}', 'MigrationController@purgeCompanySaveSettings')->middleware('password_protected');
Route::post('migration/start/{company}', 'MigrationController@startMigration');
Route::resource('companies', 'CompanyController');// name = (companies. index / create / show / update / destroy / edit