Commit 5ad80794 by Aan Choesni Herlingga

looping autopost

parent 7f539aef
......@@ -5,10 +5,12 @@ namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Webprofile\Categories;
use App\Repositories\Webprofile\AutopostRepository;
use App\Repositories\Webprofile\En\PostRepository as EnPostRepository;
use App\Repositories\Webprofile\PostRepository;
use App\Repositories\Webprofile\SocialSharingRepository;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use Statickidz\GoogleTranslate;
class PostController extends Controller
......@@ -22,11 +24,13 @@ class PostController extends Controller
public function __construct(
PostRepository $repo,
EnPostRepository $repoEn,
SocialSharingRepository $socialRepo
SocialSharingRepository $socialRepo,
AutopostRepository $autoPostRepo
) {
$this->repo = $repo;
$this->repoEn = $repoEn;
$this->socialRepo = $socialRepo;
$this->autoPostRepo = $autoPostRepo;
}
/**
......@@ -74,7 +78,7 @@ class PostController extends Controller
array_key_exists('post_status', $data) ? $data['post_status'] = 1 : $data['post_status'] = 0;
array_key_exists('cover_status', $data) ? $data['cover_status'] = 1 : $data['cover_status'] = 0;
$data['slug'] = str_slug($request->input('title'));
$data['slug'] = Str::slug($request->input('title'));
$save = $this->repo->store($data);
......@@ -98,7 +102,7 @@ class PostController extends Controller
public function share($data, $request)
{
$setting = webprofilesetting();
$autoPost = $this->autoPostRepo->get();
if ($request->hasFile('thumbnail')) {
$img = $request->file('thumbnail')->getRealPath();
......@@ -107,6 +111,7 @@ class PostController extends Controller
}
$title = html_entity_decode($data['title']);
foreach ($autoPost as $value) {
//Social Share Facebook
// Config::set('larasap.facebook', [
// 'app_id' => $setting['facebook_app_id'],
......@@ -117,12 +122,13 @@ class PostController extends Controller
// $this->socialRepo->sendLinkToFacebook(url('post/'.$data['slug']), $data['content']);
if ($value->type == 'twitter') {
//Social Share Twitter
Config::set('larasap.twitter', [
'consurmer_key' => $setting['twitter_consurmer_key'],
'consurmer_secret' => $setting['twitter_consurmer_secret'],
'access_token' => $setting['twitter_access_token'],
'access_token_secret' => $setting['twitter_access_token_secret'],
'consurmer_key' => $value->key_1,
'consurmer_secret' => $value->key_2,
'access_token' => $value->key_3,
'access_token_secret' => $value->key_4,
]);
if ($img == '') {
......@@ -131,6 +137,8 @@ class PostController extends Controller
$this->socialRepo->sendTweetWithMedia($title.' '.url('post/'.$data['slug']), [$img]);
}
}
}
}
private function createEn($data, $post)
{
......@@ -198,7 +206,7 @@ class PostController extends Controller
array_key_exists('post_status', $data) ? $data['post_status'] = 1 : $data['post_status'] = 0;
array_key_exists('cover_status', $data) ? $data['cover_status'] = 1 : $data['cover_status'] = 0;
$data['slug'] = str_slug($request->input('title'));
$data['slug'] = Str::slug($request->input('title'));
$post = $this->repo->findId($id, ['rEn']);
$edit = $this->repo->update($data, $post);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment