Task schedule

This commit is contained in:
Vijay Sebastian
2017-01-05 16:14:49 +05:30
parent d18facc079
commit f99aa6f185
3 changed files with 44 additions and 43 deletions

View File

@@ -30,8 +30,9 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
if (env('DB_INSTALL') == 1) { if (env('DB_INSTALL') == 1) {
$queue = $this->getCurrentQueue(); if ($this->getCurrentQueue() != "sync") {
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute(); $schedule->command('queue:listen '.$this->getCurrentQueue().' --sleep 60')->everyMinute();
}
$this->execute($schedule, 'fetching'); $this->execute($schedule, 'fetching');
$this->execute($schedule, 'notification'); $this->execute($schedule, 'notification');
$this->execute($schedule, 'work'); $this->execute($schedule, 'work');
@@ -61,34 +62,34 @@ class Kernel extends ConsoleKernel
$at = $command['at']; $at = $command['at'];
switch ($condition) { switch ($condition) {
case 'everyMinute': case 'everyMinute':
$schedule->everyMinute()->withoutOverlapping(); $schedule->everyMinute();
break; break;
case 'everyFiveMinutes': case 'everyFiveMinutes':
$schedule->everyFiveMinutes()->withoutOverlapping(); $schedule->everyFiveMinutes();
break; break;
case 'everyTenMinutes': case 'everyTenMinutes':
$schedule->everyTenMinutes()->withoutOverlapping(); $schedule->everyTenMinutes();
break; break;
case 'everyThirtyMinutes': case 'everyThirtyMinutes':
$schedule->everyThirtyMinutes()->withoutOverlapping(); $schedule->everyThirtyMinutes();
break; break;
case 'hourly': case 'hourly':
$schedule->hourly()->withoutOverlapping(); $schedule->hourly();
break; break;
case 'daily': case 'daily':
$schedule->daily()->withoutOverlapping(); $schedule->daily();
break; break;
case 'dailyAt': case 'dailyAt':
$this->getConditionWithOption($schedule, $condition, $at); $this->getConditionWithOption($schedule, $condition, $at);
break; break;
case 'weekly': case 'weekly':
$schedule->weekly()->withoutOverlapping(); $schedule->weekly();
break; break;
case 'monthly': case 'monthly':
$schedule->monthly()->withoutOverlapping(); $schedule->monthly();
break; break;
case 'yearly': case 'yearly':
$schedule->yearly()->withoutOverlapping(); $schedule->yearly();
break; break;
} }
} }
@@ -97,7 +98,7 @@ class Kernel extends ConsoleKernel
{ {
switch ($command) { switch ($command) {
case 'dailyAt': case 'dailyAt':
$schedule->dailyAt($at)->withoutOverlapping(); $schedule->dailyAt($at);
break; break;
} }
} }

View File

@@ -11,26 +11,24 @@ use Lang;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
class SettingsController extends Controller class SettingsController extends Controller {
{
public function settingsIcon() public function settingsIcon() {
{
return ' <div class="col-md-2 col-sm-6"> return ' <div class="col-md-2 col-sm-6">
<div class="settingiconblue"> <div class="settingiconblue">
<div class="settingdivblue"> <div class="settingdivblue">
<a href="'.url('storage').'"> <a href="' . url('storage') . '">
<span class="fa-stack fa-2x"> <span class="fa-stack fa-2x">
<i class="fa fa-save fa-stack-1x"></i> <i class="fa fa-save fa-stack-1x"></i>
</span> </span>
</a> </a>
</div> </div>
<p class="box-title" >'.Lang::get('storage::lang.storage').'</p> <p class="box-title" >' . Lang::get('storage::lang.storage') . '</p>
</div> </div>
</div>'; </div>';
} }
public function settings() public function settings() {
{
try { try {
$settings = new CommonSettings(); $settings = new CommonSettings();
$directories = $this->directories(); $directories = $this->directories();
@@ -51,8 +49,7 @@ class SettingsController extends Controller
} }
} }
public function postSettings(Request $request) public function postSettings(Request $request) {
{
try { try {
$requests = $request->except('_token'); $requests = $request->except('_token');
$this->delete(); $this->delete();
@@ -70,8 +67,7 @@ class SettingsController extends Controller
} }
} }
public function delete() public function delete() {
{
$settings = CommonSettings::where('option_name', 'storage')->get(); $settings = CommonSettings::where('option_name', 'storage')->get();
if ($settings->count() > 0) { if ($settings->count() > 0) {
foreach ($settings as $setting) { foreach ($settings as $setting) {
@@ -80,17 +76,15 @@ class SettingsController extends Controller
} }
} }
public function save($key, $value) public function save($key, $value) {
{
CommonSettings::create([ CommonSettings::create([
'option_name' => 'storage', 'option_name' => 'storage',
'optional_field' => $key, 'optional_field' => $key,
'option_value' => $value, 'option_value' => $value,
]); ]);
} }
public function directories($root = '') public function directories($root = '') {
{
if ($root == '') { if ($root == '') {
$root = base_path(); $root = base_path();
} }
@@ -109,18 +103,19 @@ class SettingsController extends Controller
return $paths; return $paths;
} }
public function attachment() public function attachment() {
{
$storage = new StorageController(); $storage = new StorageController();
$storage->upload(); $storage->upload();
} }
public function activate() public function activate() {
{ if (!\Schema::hasColumn('ticket_attachment', 'driver')) {
$path = 'app'.DIRECTORY_SEPARATOR.'FaveoStorage'.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'migrations'; $path = 'app' . DIRECTORY_SEPARATOR . 'FaveoStorage' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR . 'migrations';
Artisan::call('migrate', [ Artisan::call('migrate', [
'--path' => $path, '--path' => $path,
'--force'=> true, '--force' => true,
]); ]);
}
} }
} }

View File

@@ -326,14 +326,19 @@ class TemplateController extends Controller
if (!$from_address) { if (!$from_address) {
throw new Exception('Sorry! We can not find your request'); throw new Exception('Sorry! We can not find your request');
} }
$controller = new PhpMailController(); $to_address = [
$controller->setMailConfig($from_address); 'name' => "",
$controller->laravelMail($to, '', $subject, $msg, [], null); 'email' => $to
];
$message = [
'subject' => $subject,
'scenario' => null,
'body' => $msg
];
$this->PhpMailController->sendmail($from, $to_address, $message,[],[]);
return redirect()->back()->with('success', 'Mail has send successfully'); return redirect()->back()->with('success', 'Mail has send successfully');
} catch (Exception $e) { } catch (Exception $e) {
dd($e);
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
} }