forked from gwaps4nlp/zombilingo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Lefebvre
committed
Mar 29, 2018
1 parent
235c3f7
commit f98cba2
Showing
936 changed files
with
325,378 additions
and
83,083 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Models\Duel; | ||
use DB; | ||
|
||
class CloseDuels extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'duels:close'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Free the duels not completed of more than 14 days'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$duels_to_close = Duel::where('state','in_progress')->whereRaw('DATEDIFF(NOW(), updated_at) > 14')->get(); | ||
foreach($duels_to_close as $duel){ | ||
$users_completed = array(); | ||
$users_in_progress = array(); | ||
foreach($duel->users as $user){ | ||
if($user->pivot->turn==$duel->nb_turns){ | ||
$users_completed[]=$user; | ||
} else { | ||
$users_in_progress[]=$user; | ||
} | ||
} | ||
if($users_completed){ | ||
foreach($users_in_progress as $user){ | ||
$duel->users()->detach($user->id); | ||
} | ||
$duel->state = 'pending'; | ||
$duel->save(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Filesystem\Filesystem; | ||
// use Illuminate\Events\Dispatcher; | ||
// use Barryvdh\TranslationManager\Models\Translation; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Support\Facades\Storage; | ||
use App\Models\Language; | ||
use Artisan; | ||
|
||
class CreateLanguage extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'language:create {language} {original_language=en}'; | ||
|
||
/** @var \Illuminate\Foundation\Application */ | ||
protected $app; | ||
/** @var \Illuminate\Filesystem\Filesystem */ | ||
protected $files; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Add a new language to the application'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Application $app, Filesystem $files) | ||
{ | ||
$this->app = $app; | ||
$this->files = $files; | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
|
||
$new_language = $this->argument('language'); | ||
$original_language = $this->argument('original_language'); | ||
|
||
|
||
$new_directory = $this->app['path.lang']. DIRECTORY_SEPARATOR . $new_language; | ||
$original_directory = $this->app['path.lang']. DIRECTORY_SEPARATOR . $original_language; | ||
|
||
if(!$this->files->exists($original_directory)){ | ||
$this->error($original_language.' does not exist!'); | ||
return; | ||
} | ||
|
||
if($this->files->exists($new_directory)){ | ||
$this->error($new_language.' already exists!'); | ||
while(!in_array($overwrite = $this->askOverwriteExistingFiles(),['y','n'])){ | ||
|
||
} | ||
if($overwrite=='n') | ||
return; | ||
} | ||
|
||
$language = Language::firstOrCreate(['slug'=> $new_language]); | ||
$this->files->copyDirectory($original_directory,$new_directory); | ||
$this->files->copyDirectory(resource_path('views/lang/'.$original_language),resource_path('views/lang/'.$new_language)); | ||
Artisan::call('translations:import'); | ||
|
||
} | ||
|
||
private function askOverwriteExistingFiles(){ | ||
return $this->ask('Overwrite the existing files (y/n)?'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class ExportDatabase extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'db:export'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Make a dump of the database and send it to a remote server'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$dump_file = storage_path('app/dump.sql'); | ||
|
||
$command = "mysqldump -h ".env('DB_HOST')." -u ".env('DB_USERNAME')." -p".env('DB_PASSWORD')." --databases ".env('DB_DATABASE')." > ".$dump_file; | ||
|
||
system($command, $return_var); | ||
|
||
$command_send_file = "scp ".$dump_file." ".config('database.backup-server.user')."@".config('database.backup-server.host').":".config('database.backup-server.path'); | ||
system($command_send_file, $return_var); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class ImportDatabase extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'db:import'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Imports the database backup.'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
if ($this->confirm('The current database will be overwritten. Are you sure you want to continue ?')) { | ||
|
||
$dump_file = storage_path('app/dump.sql'); | ||
|
||
$command = "mysql -h ".env('DB_HOST')." -u ".env('DB_USERNAME')." -p".env('DB_PASSWORD')." ".env('DB_DATABASE')." < ".$dump_file; | ||
|
||
system($command, $return_var); | ||
|
||
} | ||
|
||
} | ||
} |
Oops, something went wrong.