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
4c0f6f0e
Commit
4c0f6f0e
authored
4 years ago
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url shorter, hastags, dan title website
parent
5ad80794
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
app/Http/Controllers/Webprofile/Backend/PostController.php
+28
-7
No files found.
app/Http/Controllers/Webprofile/Backend/PostController.php
View file @
4c0f6f0e
...
@@ -2,13 +2,14 @@
...
@@ -2,13 +2,14 @@
namespace
App\Http\Controllers\Webprofile\Backend
;
namespace
App\Http\Controllers\Webprofile\Backend
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
App\Models\Webprofile\Categories
;
use
App\Models\Webprofile\Categories
;
use
App\Repositories\Webprofile\AutopostRepository
;
use
App\Repositories\Webprofile\AutopostRepository
;
use
App\Repositories\Webprofile\En\PostRepository
as
EnPostRepository
;
use
App\Repositories\Webprofile\En\PostRepository
as
EnPostRepository
;
use
App\Repositories\Webprofile\PostRepository
;
use
App\Repositories\Webprofile\PostRepository
;
use
App\Repositories\Webprofile\SocialSharingRepository
;
use
App\Repositories\Webprofile\SocialSharingRepository
;
use
GuzzleHttp\Client
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Config
;
use
Illuminate\Support\Facades\Config
;
use
Illuminate\Support\Str
;
use
Illuminate\Support\Str
;
use
Statickidz\GoogleTranslate
;
use
Statickidz\GoogleTranslate
;
...
@@ -68,8 +69,6 @@ class PostController extends Controller
...
@@ -68,8 +69,6 @@ class PostController extends Controller
/**
/**
* Store a newly created resource in storage.
* Store a newly created resource in storage.
*
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
...
@@ -100,8 +99,22 @@ class PostController extends Controller
...
@@ -100,8 +99,22 @@ class PostController extends Controller
return
redirect
()
->
route
(
'posts.index'
);
return
redirect
()
->
route
(
'posts.index'
);
}
}
public
function
shorterUrl
(
$long_url
)
{
$client
=
new
Client
();
$URI
=
'http://s.unesa.ac.id/create.php'
;
$params
[
'form_params'
]
=
[
'token'
=>
env
(
'TOKEN_URL'
,
'forge'
),
'url_value'
=>
$long_url
];
$response
=
$client
->
post
(
$URI
,
$params
);
$responseJson
=
json_decode
(
$response
->
getBody
(),
true
);
$url
=
$responseJson
[
'url'
];
return
$url
;
}
public
function
share
(
$data
,
$request
)
public
function
share
(
$data
,
$request
)
{
{
$setting
=
webprofilesetting
();
$autoPost
=
$this
->
autoPostRepo
->
get
();
$autoPost
=
$this
->
autoPostRepo
->
get
();
if
(
$request
->
hasFile
(
'thumbnail'
))
{
if
(
$request
->
hasFile
(
'thumbnail'
))
{
...
@@ -110,6 +123,15 @@ class PostController extends Controller
...
@@ -110,6 +123,15 @@ class PostController extends Controller
$img
=
null
;
$img
=
null
;
}
}
$title
=
html_entity_decode
(
$data
[
'title'
]);
$title
=
html_entity_decode
(
$data
[
'title'
]);
$url
=
$this
->
shorterUrl
(
url
(
'post/'
.
$data
[
'slug'
]));
$keys
=
$data
[
'keys'
];
$olhashtag
=
explode
(
', '
,
str_replace
([
', '
,
','
],
', '
,
$keys
));
$hashtag
=
'#unesa #unesaterkini '
;
foreach
(
$olhashtag
as
$value
)
{
$hashtag
.=
'#'
.
trim
(
$value
)
.
' '
;
}
foreach
(
$autoPost
as
$value
)
{
foreach
(
$autoPost
as
$value
)
{
//Social Share Facebook
//Social Share Facebook
...
@@ -132,9 +154,9 @@ class PostController extends Controller
...
@@ -132,9 +154,9 @@ class PostController extends Controller
]);
]);
if
(
$img
==
''
)
{
if
(
$img
==
''
)
{
$this
->
socialRepo
->
sendTextTweet
(
$
title
.
' '
.
url
(
'post/'
.
$data
[
'slug'
])
);
$this
->
socialRepo
->
sendTextTweet
(
$
setting
[
'header_admin'
]
.
'-'
.
$title
.
"
\n\n
"
.
$url
.
"
\n\n
"
.
$hashtag
);
}
else
{
}
else
{
$this
->
socialRepo
->
sendTweetWithMedia
(
$
title
.
' '
.
url
(
'post/'
.
$data
[
'slug'
])
,
[
$img
]);
$this
->
socialRepo
->
sendTweetWithMedia
(
$
setting
[
'header_admin'
]
.
'-'
.
$title
.
"
\n\n
"
.
$url
.
"
\n\n
"
.
$hashtag
,
[
$img
]);
}
}
}
}
}
}
...
@@ -194,8 +216,7 @@ class PostController extends Controller
...
@@ -194,8 +216,7 @@ class PostController extends Controller
/**
/**
* Update the specified resource in storage.
* Update the specified resource in storage.
*
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $id
*
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
...
...
This diff is collapsed.
Click to expand it.
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