Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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