Skip to content

Instantly share code, notes, and snippets.

@EricMcWinNer
Created July 22, 2021 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricMcWinNer/0c8245bb539fd3306e37a35c15b3fc44 to your computer and use it in GitHub Desktop.
Save EricMcWinNer/0c8245bb539fd3306e37a35c15b3fc44 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers\Employer\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\User;
class HomeController extends Controller
{
public function getUserPosts($id) {
$user = User::find($id);
$response = ['data' => $user];
if($user->posts) {
// Do something if user has posts
}
return response($response, 200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment