Skip to content

Commit

Permalink
v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwijaya-dev committed Sep 30, 2020
1 parent cb5c711 commit 374fba5
Show file tree
Hide file tree
Showing 19 changed files with 465 additions and 367 deletions.
24 changes: 24 additions & 0 deletions src/Classes/MySQLDB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Andiwijaya\AppCore\Classes;

class MySQLDB{

private static $conn;

public static function fetch($params, $indexes = null){

self::$conn = mysqli_connect(env('DB_HOST'), env('DB_USERNAME'), env('DB_PASSWORD'), env('DB_DATABASE'));

if(is_string($params))
$query = mysqli_query(self::$conn, $params);

$arr = $query->fetch_all(MYSQLI_ASSOC);

if($indexes != null)
$arr = array_index($arr, $indexes);

return $arr;
}

}
4 changes: 0 additions & 4 deletions src/Console/Commands/ScheduledTaskRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
namespace Andiwijaya\AppCore\Console\Commands;

use Andiwijaya\AppCore\Models\ScheduledTask;
use Andiwijaya\AppCore\Models\ScheduledTaskInstance;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Process\Process;

class ScheduledTaskRun extends Command
{
Expand Down
12 changes: 11 additions & 1 deletion src/Http/Controllers/ActionableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function store(Request $request){
return call_user_func_array([ $this, $method ], func_get_args());
}

public function show(Request $request){
public function show(Request $request, $id){

$this->request = $request;

Expand All @@ -40,6 +40,16 @@ public function show(Request $request){
return call_user_func_array([ $this, $method ], func_get_args());
}

public function patch(Request $request){

$this->request = $request;

$action = isset(($actions = explode('|', $request->input('action', 'patch')))[0]) ? $actions[0] : '';
$method = action2method($action);
if(method_exists($this, $method))
return call_user_func_array([ $this, $method ], func_get_args());
}

public function onlyMethods($methods){

$arr = is_scalar($methods) ? [ $methods ] : (!is_array($methods) ? [] : $methods);
Expand Down
22 changes: 2 additions & 20 deletions src/Http/Controllers/ListPageController2.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;

class ListPageController2 extends BaseController{
class ListPageController2 extends ActionableController{

public $model = null;

Expand Down Expand Up @@ -49,24 +49,6 @@ public function __construct()
View::share('meta', $this->meta);
}

public function index(Request $request){

$action = isset(($actions = explode('|', $request->get('action', 'fetch')))[0]) ? $actions[0] : '';

$method = action2method($action);
if(method_exists($this, $method))
return call_user_func_array([ $this, $method ], func_get_args());
}

public function store(Request $request){

$action = isset(($actions = explode('|', $request->get('action', 'save')))[0]) ? $actions[0] : '';

$method = action2method($action);
if(method_exists($this, $method))
return call_user_func_array([ $this, $method ], func_get_args());
}

public function applySorts($builder, array $sorts)
{
foreach($sorts as $sort){
Expand Down
9 changes: 9 additions & 0 deletions src/Interfaces/VerboseOutputInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Andiwijaya\AppCore\Interfaces;

interface VerboseOutputInterface{

public function info($text);

}
16 changes: 15 additions & 1 deletion src/Models/ChatDiscussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Andiwijaya\AppCore\Events\ChatEvent;
use App\Mail\ChatDiscussionCustomerNotification;
use App\Models\Customer;
use App\Models\FAQ;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -215,12 +216,25 @@ public static function sendOfflineMessage($discussion_id){
$offline_message_at = Carbon::createFromTimeString(date('Y-m-d H:i:s', strtotime($discussion->extra['offline_message_at'] ?? null)));

$offline = self::isOffline();

if($offline && config('chat.offline-message') && $offline_message_at->diffInHours() > 2){

$message = config('chat.offline-message');
$faqs = config('chat.offline-message-faqs', []);
if(count($faqs) > 0){
$message .= "<div class='vmar-1'><label>Apakah yang anda cari terdapat dibawah ini:</label><ol class='vmart-05'>";
foreach($faqs as $faq_topic){

$faq = FAQ::where('topic', $faq_topic)->first();
$message .= "<li><a href='" . env('APP_URL') . "/faq/{$faq->seo_url}' target='_blank'>{$faq->topic}</a></li>";
}
$message .= "</ol></div>";
}

$message = new ChatMessage([
'discussion_id'=>$discussion_id,
'direction'=>ChatMessage::DIRECTION_OUT,
'text'=>config('chat.offline-message'),
'text'=>$message,
'is_system'=>1,
'extra'=>[ 'name'=>'Tara', 'avatar_url'=>'chat-figure.png' ],
]);
Expand Down
Loading

0 comments on commit 374fba5

Please sign in to comment.