Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ZeMKI
Mesort
Commits
621c3a5c
Commit
621c3a5c
authored
Mar 04, 2020
by
ZeMKI
Browse files
Code Optmization
this update is meant to be just a code styling and optimization.
parent
bcd11dc9
Changes
85
Hide whitespace changes
Inline
Side-by-side
.idea/codeStyles/codeStyleConfig.xml
0 → 100644
View file @
621c3a5c
<component
name=
"ProjectCodeStyleConfiguration"
>
<state>
<option
name=
"PREFERRED_PROJECT_CODE_STYLE"
value=
"Default"
/>
</state>
</component>
\ No newline at end of file
.idea/mesort.iml
View file @
621c3a5c
...
@@ -12,13 +12,15 @@
...
@@ -12,13 +12,15 @@
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/composer"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/composer"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/dnoegel/php-xdg-base-dir"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/dnoegel/php-xdg-base-dir"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/annotations"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/annotations"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/cache"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/dbal"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/event-manager"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/inflector"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/inflector"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/instantiator"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/instantiator"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/lexer"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/doctrine/lexer"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/dompdf/dompdf"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/dompdf/dompdf"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/dragonmantank/cron-expression"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/dragonmantank/cron-expression"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/egulias/email-validator"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/egulias/email-validator"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/erusev/parsedown"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/facade/flare-client-php"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/facade/flare-client-php"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/facade/ignition"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/facade/ignition"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/facade/ignition-contracts"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/facade/ignition-contracts"
/>
...
@@ -33,12 +35,14 @@
...
@@ -33,12 +35,14 @@
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/intervention/image"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/intervention/image"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/jakub-onderka/php-console-color"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/jakub-onderka/php-console-color"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/jakub-onderka/php-console-highlighter"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/jakub-onderka/php-console-highlighter"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/jasonmccreary/laravel-test-assertions"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/justinrainbow/json-schema"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/justinrainbow/json-schema"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/kkszymanowski/traitor"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/kkszymanowski/traitor"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravel/framework"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravel/framework"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravel/telescope"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravel/telescope"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravel/tinker"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravel/tinker"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravelcollective/html"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/laravelcollective/html"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/league/commonmark"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/league/container"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/league/container"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/league/flysystem"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/league/flysystem"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/maatwebsite/excel"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/maatwebsite/excel"
/>
...
@@ -48,6 +52,7 @@
...
@@ -48,6 +52,7 @@
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/mockery/mockery"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/mockery/mockery"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/monolog/monolog"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/monolog/monolog"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/moontoast/math"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/moontoast/math"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/mpociot/laravel-test-factory-helper"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/myclabs/deep-copy"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/myclabs/deep-copy"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/nesbot/carbon"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/nesbot/carbon"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/nette/utils"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/nette/utils"
/>
...
@@ -68,6 +73,8 @@
...
@@ -68,6 +73,8 @@
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phploc/phploc"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phploc/phploc"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpoffice/phpspreadsheet"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpoffice/phpspreadsheet"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpoption/phpoption"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpoption/phpoption"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpseclib/bcmath_compat"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpseclib/phpseclib"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpspec/prophecy"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpspec/prophecy"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpstan/phpdoc-parser"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpstan/phpdoc-parser"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpunit/php-code-coverage"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/vendor/phpunit/php-code-coverage"
/>
...
...
.idea/php.xml
View file @
621c3a5c
...
@@ -85,7 +85,6 @@
...
@@ -85,7 +85,6 @@
<path
value=
"$PROJECT_DIR$/vendor/psr/simple-cache"
/>
<path
value=
"$PROJECT_DIR$/vendor/psr/simple-cache"
/>
<path
value=
"$PROJECT_DIR$/vendor/dragonmantank/cron-expression"
/>
<path
value=
"$PROJECT_DIR$/vendor/dragonmantank/cron-expression"
/>
<path
value=
"$PROJECT_DIR$/vendor/nunomaduro/collision"
/>
<path
value=
"$PROJECT_DIR$/vendor/nunomaduro/collision"
/>
<path
value=
"$PROJECT_DIR$/vendor/erusev/parsedown"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/instantiator"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/instantiator"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/inflector"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/inflector"
/>
<path
value=
"$PROJECT_DIR$/vendor/jakub-onderka/php-console-highlighter"
/>
<path
value=
"$PROJECT_DIR$/vendor/jakub-onderka/php-console-highlighter"
/>
...
@@ -148,6 +147,14 @@
...
@@ -148,6 +147,14 @@
<path
value=
"$PROJECT_DIR$/vendor/markbaker/matrix"
/>
<path
value=
"$PROJECT_DIR$/vendor/markbaker/matrix"
/>
<path
value=
"$PROJECT_DIR$/vendor/markbaker/complex"
/>
<path
value=
"$PROJECT_DIR$/vendor/markbaker/complex"
/>
<path
value=
"$PROJECT_DIR$/vendor/symfony/error-handler"
/>
<path
value=
"$PROJECT_DIR$/vendor/symfony/error-handler"
/>
<path
value=
"$PROJECT_DIR$/vendor/phpseclib/phpseclib"
/>
<path
value=
"$PROJECT_DIR$/vendor/phpseclib/bcmath_compat"
/>
<path
value=
"$PROJECT_DIR$/vendor/league/commonmark"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/event-manager"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/dbal"
/>
<path
value=
"$PROJECT_DIR$/vendor/doctrine/cache"
/>
<path
value=
"$PROJECT_DIR$/vendor/mpociot/laravel-test-factory-helper"
/>
<path
value=
"$PROJECT_DIR$/vendor/jasonmccreary/laravel-test-assertions"
/>
</include_path>
</include_path>
</component>
</component>
<component
name=
"PhpProjectSharedConfiguration"
php_language_level=
"7.2"
/>
<component
name=
"PhpProjectSharedConfiguration"
php_language_level=
"7.2"
/>
...
...
.idea/symfony2.xml
View file @
621c3a5c
...
@@ -3,5 +3,6 @@
...
@@ -3,5 +3,6 @@
<component
name=
"Symfony2PluginSettings"
>
<component
name=
"Symfony2PluginSettings"
>
<option
name=
"directoryToWeb"
value=
"public"
/>
<option
name=
"directoryToWeb"
value=
"public"
/>
<option
name=
"pluginEnabled"
value=
"true"
/>
<option
name=
"pluginEnabled"
value=
"true"
/>
<option
name=
"lastServiceGeneratorLanguage"
value=
"yaml"
/>
</component>
</component>
</project>
</project>
\ No newline at end of file
app/Action.php
View file @
621c3a5c
...
@@ -3,18 +3,22 @@
...
@@ -3,18 +3,22 @@
namespace
App
;
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
class
Action
extends
Model
class
Action
extends
Model
{
{
/**
* @var array
*/
protected
$fillable
=
[
protected
$fillable
=
[
'user_id'
,
'url'
,
'name'
,
'description'
,
'user_id'
,
'url'
,
'name'
,
'description'
,
];
];
/**
* @return BelongsTo
*/
public
function
user
()
public
function
user
()
{
{
return
$this
->
belongsTo
(
\
App\
User
::
class
);
return
$this
->
belongsTo
(
User
::
class
);
}
}
}
}
app/AllInterviewTokenExport.php
View file @
621c3a5c
...
@@ -4,6 +4,8 @@ namespace App\Exports;
...
@@ -4,6 +4,8 @@ namespace App\Exports;
use
App\InterviewTokens
;
use
App\InterviewTokens
;
use
App\Study
;
use
App\Study
;
use
App\Token
;
use
Illuminate\Support\Collection
;
use
Image
;
use
Image
;
use
Maatwebsite\Excel\Concerns\Exportable
;
use
Maatwebsite\Excel\Concerns\Exportable
;
use
Maatwebsite\Excel\Concerns\FromCollection
;
use
Maatwebsite\Excel\Concerns\FromCollection
;
...
@@ -15,11 +17,18 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
...
@@ -15,11 +17,18 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
{
{
use
Exportable
;
use
Exportable
;
/**
* AllInterviewTokenExport constructor.
* @param $id
*/
public
function
__construct
(
$id
)
public
function
__construct
(
$id
)
{
{
$this
->
id
=
$id
;
$this
->
id
=
$id
;
}
}
/**
* @return array
*/
public
function
headings
():
array
public
function
headings
():
array
{
{
return
[
return
[
...
@@ -35,77 +44,76 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
...
@@ -35,77 +44,76 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
}
}
/**
/**
* @param mixed $study
* @return array
* @return array
* @var Interview $interview
*/
*/
public
function
map
(
$study
):
array
public
function
map
(
$study
):
array
{
{
$printArray
=
[];
$printArray
=
[];
$indexForName
=
0
;
$count
=
0
;
foreach
(
$study
->
interviews
as
$emptyInterview
)
{
foreach
(
$study
->
interviews
as
$emptyInterview
)
{
$allinterviews
=
InterviewTokens
::
where
(
'interview_id'
,
$emptyInterview
->
id
)
->
get
();
$allinterviews
=
InterviewTokens
::
where
(
'interview_id'
,
$emptyInterview
->
id
)
->
get
();
array_push
(
$printArray
,[
$emptyInterview
->
interviewed
]);
array_push
(
$printArray
,
[
$emptyInterview
->
interviewed
]);
foreach
(
$allinterviews
as
$interview
)
{
foreach
(
$allinterviews
as
$interview
)
{
if
(
$this
->
invalidData
(
$interview
))
continue
;
if
(
$this
->
invalidData
(
$interview
))
continue
;
$this
->
formatTokenValuesForExport
(
$interview
,
$toprint
);
if
(
isset
(
$interview
->
valutation
->
percentagePosition
))
{
$percentagePosition
=
"x: "
.
$interview
->
valutation
->
percentagePosition
->
x
.
" y:"
.
$interview
->
valutation
->
percentagePosition
->
y
;
}
else
{
$percentagePosition
=
''
;
}
if
(
is_object
(
$interview
->
valutation
->
position
))
{
$position
=
"x: "
.
$interview
->
valutation
->
position
->
x
.
" y:"
.
$interview
->
valutation
->
position
->
y
;
}
else
{
$position
=
$interview
->
valutation
->
position
;
}
if
(
is_array
(
$interview
->
valutation
->
classifiers
))
{
$classifiers
=
""
;
foreach
(
$interview
->
valutation
->
classifiers
as
$classifier
)
{
$classifiers
.
=
$classifier
->
basename
.
" - "
;
}
}
$toprint
=
[
$interview
->
token_id
,
\
App\Token
::
where
(
'id'
,
$interview
->
token_id
)
->
first
()
->
name
,
$interview
->
valutation
->
circle
,
$interview
->
valutation
->
distance
,
$interview
->
valutation
->
sorting
,
$position
,
$percentagePosition
,
$classifiers
];
array_push
(
$printArray
,
$toprint
);
array_push
(
$printArray
,
$toprint
);
}
}
//array_unshift($printArray,[$emptyInterview->interviewed]);
}
}
return
$printArray
;
return
$printArray
;
}
}
public
function
collection
()
/**
* @param $token
* @return bool
* if the token has position 0 or is not set, don't print it.
*/
private
function
invalidData
(
$token
):
bool
{
{
return
Study
::
where
(
'id'
,
$this
->
id
)
->
get
()
;
return
!
is_object
(
$token
->
valutation
->
position
)
&&
$token
->
valutation
->
position
==
0
&&
$token
->
valutation
->
distance
==
0
&&
$token
->
valutation
->
circle
==
0
;
}
}
/**
/**
* @param $interview
* @param $interview
* @
return bool
* @
param $toprint
*/
*/
private
function
invalidData
(
$interview
):
bool
private
function
formatTokenValuesForExport
(
$interview
,
&
$toprint
)
:
void
{
{
return
!
is_object
(
$interview
->
valutation
->
position
)
&&
$interview
->
valutation
->
position
==
0
&&
$interview
->
valutation
->
distance
==
0
&&
$interview
->
valutation
->
circle
==
0
;
if
(
isset
(
$interview
->
valutation
->
percentagePosition
))
{
$percentagePosition
=
"x: "
.
$interview
->
valutation
->
percentagePosition
->
x
.
" y:"
.
$interview
->
valutation
->
percentagePosition
->
y
;
}
else
{
$percentagePosition
=
''
;
}
if
(
is_object
(
$interview
->
valutation
->
position
))
{
$position
=
"x: "
.
$interview
->
valutation
->
position
->
x
.
" y:"
.
$interview
->
valutation
->
position
->
y
;
}
else
{
$position
=
$interview
->
valutation
->
position
;
}
if
(
is_array
(
$interview
->
valutation
->
classifiers
))
{
$classifiers
=
""
;
foreach
(
$interview
->
valutation
->
classifiers
as
$classifier
)
{
$classifiers
.
=
$classifier
->
basename
.
" - "
;
}
}
$toprint
=
[
$interview
->
token_id
,
Token
::
where
(
'id'
,
$interview
->
token_id
)
->
first
()
->
name
,
$interview
->
valutation
->
circle
,
$interview
->
valutation
->
distance
,
$interview
->
valutation
->
sorting
,
$position
,
$percentagePosition
,
$classifiers
];
}
}
/**
* @return Collection
*/
public
function
collection
()
{
return
Study
::
where
(
'id'
,
$this
->
id
)
->
get
();
}
}
}
app/Answer.php
View file @
621c3a5c
...
@@ -7,29 +7,19 @@ use Illuminate\Http\Request;
...
@@ -7,29 +7,19 @@ use Illuminate\Http\Request;
class
Answer
extends
Model
class
Answer
extends
Model
{
{
/**
* @var array
*/
protected
$fillable
=
[
'question_id'
,
'answer'
];
protected
$fillable
=
[
'question_id'
,
'answer'
];
/**
* @var array
*/
protected
$casts
=
[
protected
$casts
=
[
'answer'
=>
'array'
,
'answer'
=>
'array'
,
];
];
public
function
question
()
{
return
$this
->
hasOne
(
\
App\Question
::
class
);
}
public
function
interviews
()
{
return
$this
->
belongsToMany
(
\
App\Interview
::
class
,
'interview_answers'
)
->
withPivot
(
'result'
)
->
withTimestamps
();
}
public
function
getAnswerAttribute
(
$value
)
{
return
is_array
(
$value
)
?
$value
:
(
array
)
json_decode
(
$value
);
}
/**
/**
* @param Request $request
* @param Request
$request
* @param Interview $interview
* @param Interview $interview
*/
*/
public
static
function
saveResultQuestions
(
Request
$request
,
Interview
$interview
):
void
public
static
function
saveResultQuestions
(
Request
$request
,
Interview
$interview
):
void
...
@@ -43,28 +33,20 @@ class Answer extends Model
...
@@ -43,28 +33,20 @@ class Answer extends Model
$interview
->
answers
()
->
attach
(
$key
,
[
'result'
=>
$value
,
'question_id'
=>
$question
->
id
]);
$interview
->
answers
()
->
attach
(
$key
,
[
'result'
=>
$value
,
'question_id'
=>
$question
->
id
]);
}
}
}
}
if
(
$key
===
'multi'
||
$key
===
'onechoice'
)
{
if
(
$key
===
'multi'
)
{
foreach
(
$value
as
$answer
)
{
foreach
(
$value
as
$multi
)
{
$answer
=
Answer
::
where
(
'id'
,
'='
,
$answer
[
'id'
])
->
first
();
$answer
=
Answer
::
where
(
'id'
,
'='
,
$multi
[
'id'
])
->
first
();
$question
=
Question
::
where
(
'id'
,
'='
,
$answer
->
question_id
)
->
first
();
$question
=
Question
::
where
(
'id'
,
'='
,
$answer
->
question_id
)
->
first
();
$interview
->
answers
()
->
attach
(
$
multi
[
'id'
],
[
'question_id'
=>
$question
->
id
]);
$interview
->
answers
()
->
attach
(
$
answer
[
'id'
],
[
'question_id'
=>
$question
->
id
]);
}
}
}
}
if
(
$key
===
'onechoice'
)
{
foreach
(
$value
as
$one
)
{
$answer
=
Answer
::
where
(
'id'
,
'='
,
$one
[
'id'
])
->
first
();
$question
=
Question
::
where
(
'id'
,
'='
,
$answer
->
question_id
)
->
first
();
$interview
->
answers
()
->
attach
(
$one
[
'id'
],
[
'question_id'
=>
$question
->
id
]);
}
}
}
}
}
}
/**
/**
* @param
\App\
Interview $interview
* @param Interview $interview
* @param $data
* @param
$data
*/
*/
public
static
function
assignAnswersToQuestion
(
Interview
$interview
,
$data
):
void
public
static
function
assignAnswersToQuestion
(
Interview
$interview
,
$data
):
void
{
{
...
@@ -74,4 +56,23 @@ class Answer extends Model
...
@@ -74,4 +56,23 @@ class Answer extends Model
}
}
}
}
public
function
question
()
{
return
$this
->
hasOne
(
Question
::
class
);
}
public
function
interviews
()
{
return
$this
->
belongsToMany
(
Interview
::
class
,
'interview_answers'
)
->
withPivot
(
'result'
)
->
withTimestamps
();
}
/**
* @param $value
* @return array
*/
public
function
getAnswerAttribute
(
$value
)
{
return
is_array
(
$value
)
?
$value
:
(
array
)
json_decode
(
$value
);
}
}
}
app/Console/Commands/CreateUserCommand.php
View file @
621c3a5c
...
@@ -2,14 +2,12 @@
...
@@ -2,14 +2,12 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
Helper
;
use
App\Permission
;
use
App\Role
;
use
App\Role
;
use
App\User
;
use
App\User
;
use
App\Permission
;
use
Helper
;
use
App\Mail\VerificationEmail
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\Mail
;
class
CreateUserCommand
extends
Command
class
CreateUserCommand
extends
Command
{
{
...
@@ -45,22 +43,23 @@ class CreateUserCommand extends Command
...
@@ -45,22 +43,23 @@ class CreateUserCommand extends Command
public
function
handle
()
public
function
handle
()
{
{
$email
=
$this
->
ask
(
'Enter *supervisor* email'
);
$email
=
$this
->
ask
(
'Enter *supervisor* email'
);
/* $this->info('2 -> Supervisor');*/
/* $this->info('2 -> Supervisor');*/
/* $this->info('3 -> Researcher');*/
/* $this->info('3 -> Researcher');*/
/* $role = $this->choice('User role?', [2, 3]);*/
/* $role = $this->choice('User role?', [2, 3]);*/
$password
=
$this
->
secret
(
'Enter password'
);
$password
=
$this
->
secret
(
'Enter password'
);
$role
=
2
;
$role
=
2
;
if
(
$this
->
store
(
$role
,
$email
,
$password
,
$user
))
{
if
(
$this
->
store
(
$role
,
$email
,
$password
,
$user
))
{
//Mail::to($email)->send(new VerificationEmail($user, config('utilities.emailDefaultText')));
//Mail::to($email)->send(new VerificationEmail($user, config('utilities.emailDefaultText')));
//$this->info('An email was sent to '.$user->email.' he/she needs to set the password.');
//$this->info('An email was sent to '.$user->email.' he/she needs to set the password.');
$this
->
info
(
'User '
.
$email
.
' created'
);
$this
->
info
(
'User '
.
$email
.
' created'
);
return
true
;
return
true
;
}
else
{
}
$this
->
info
(
'There it was an error during user creation, please try again.'
);
$this
->
info
(
'There it was an error during user creation, please try again.'
);
return
false
;
return
false
;
}
}
}
public
function
store
(
$roleId
,
$email
,
$password
,
&
$user
)
public
function
store
(
$roleId
,
$email
,
$password
,
&
$user
)
...
...
app/Console/Commands/DeleteClosedStudies.php
View file @
621c3a5c
...
@@ -37,21 +37,11 @@ class DeleteClosedStudies extends Command
...
@@ -37,21 +37,11 @@ class DeleteClosedStudies extends Command
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$headers
=
[
'Study Name'
,
'made by'
];
$studiesId
=
$this
->
ShowCurrentStudies
();
$studiesAndCreator
=
\
App\Study
::
join
(
'users'
,
'user_id'
,
'='
,
'users.id'
)
->
select
(
'studies.name'
,
'users.email'
)
->
get
()
->
toArray
();
$this
->
table
(
$headers
,
$studiesAndCreator
);
$headers
=
[
'Study Id'
,
'Study Name'
];
$studies
=
\
App\Study
::
select
(
'studies.id'
,
'studies.name'
)
->
get
()
->
toArray
();
$this
->
table
(
$headers
,
$studies
);
$studiesId
=
\
App\Study
::
pluck
(
'id'
)
->
toArray
();
array_unshift
(
$studiesId
,
0
);
$this
->
warn
(
'Press 0 to delete nothing'
);
$id
=
$this
->
choice
(
'Which study you want to delete??'
,
$studiesId
,
0
);
$id
=
$this
->
choice
(
'Which study you want to delete??'
,
$studiesId
,
0
);
$study
=
\
App\Study
::
find
(
$id
);
$study
=
\
App\Study
::
find
(
$id
);
if
(
!
$study
)
{
if
(
!
$study
)
{
$this
->
warn
(
'study not found or exited with 0'
);
$this
->
warn
(
'study not found or exited with 0'
);
}
elseif
(
$study
->
interviews
->
count
()
>
0
&&
$this
->
confirm
(
'THIS STUDY HAS INTERVIEWS, YOU WILL DELETE THEM. ARE YOU SURE?'
,
false
))
{
}
elseif
(
$study
->
interviews
->
count
()
>
0
&&
$this
->
confirm
(
'THIS STUDY HAS INTERVIEWS, YOU WILL DELETE THEM. ARE YOU SURE?'
,
false
))
{
foreach
(
$study
->
interviews
as
$interview
)
{
foreach
(
$study
->
interviews
as
$interview
)
{
...
@@ -66,4 +56,24 @@ class DeleteClosedStudies extends Command
...
@@ -66,4 +56,24 @@ class DeleteClosedStudies extends Command
$this
->
info
(
'study deleted!'
);
$this
->
info
(
'study deleted!'
);
}
}
}
}
/**
* @return mixed
*/
private
function
ShowCurrentStudies
()
{
$headers
=
[
'Study Name'
,
'made by'
];
$studiesAndCreator
=
\
App\Study
::
join
(
'users'
,
'user_id'
,
'='
,
'users.id'
)
->
select
(
'studies.name'
,
'users.email'
)
->
get
()
->
toArray
();
$this
->
table
(
$headers
,
$studiesAndCreator
);
$headers
=
[
'Study Id'
,
'Study Name'
];
$studies
=
\
App\Study
::
select
(
'studies.id'
,
'studies.name'
)
->
get
()
->
toArray
();
$this
->
table
(
$headers
,
$studies
);
$studiesId
=
\
App\Study
::
pluck
(
'id'
)
->
toArray
();
array_unshift
(
$studiesId
,
0
);
$this
->
warn
(
'Press 0 to delete nothing'
);
return
$studiesId
;
}
}
}
app/Console/Commands/DeleteUserCommand.php
View file @
621c3a5c
...
@@ -40,39 +40,23 @@ class DeleteUserCommand extends Command
...
@@ -40,39 +40,23 @@ class DeleteUserCommand extends Command
public
function
handle
()
public
function
handle
()
{
{
$info
=
$this
->
choice
(
'Email or ID?'
,
[
'email'
,
'id'
]);
$info
=
$this
->
choice
(
'Email or ID?'
,
[
'email'
,
'id'
]);
$userEnteredData
=
$this
->
ask
(
'Enter '
.
$info
);
if
(
$info
===
'email'
)
{
try
{
$email
=
$this
->
ask
(
'Enter email'
);
$user
=
User
::
where
(
$info
,
'='
,
$userEnteredData
)
->
withTrashed
()
->
firstOrFail
();