Created
July 22, 2021 03:57
-
-
Save EricMcWinNer/aeed43e4299710506837eaaf41b08364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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