Skip to content

Instantly share code, notes, and snippets.

@EricMcWinNer
Created July 22, 2021 03:57
Show Gist options
  • Save EricMcWinNer/aeed43e4299710506837eaaf41b08364 to your computer and use it in GitHub Desktop.
Save EricMcWinNer/aeed43e4299710506837eaaf41b08364 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) {
$users = User::all();
$users->)->map(function ($user) {
$user->first_name; // The accessor has to be "accessed" for the function to work.
$user->phone_number; // This would create this property and do the concatenation.
});
return response(['data' => $users], 200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment