Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webprofile-jwg2024
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Siti Aisah
webprofile-jwg2024
Commits
5ad80794
Commit
5ad80794
authored
Aug 24, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
looping autopost
parent
7f539aef
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
app/Http/Controllers/Webprofile/Backend/PostController.php
+16
-8
No files found.
app/Http/Controllers/Webprofile/Backend/PostController.php
View file @
5ad80794
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment