本文整理汇总了PHP中app\Member::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Member::with方法的具体用法?PHP Member::with怎么用?PHP Member::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Member
的用法示例。
在下文中一共展示了Member::with方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($id)
{
$article = Member::with('command')->find($id);
if (!$article) {
return response()->json(null, 404);
}
return response()->json($article);
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
try {
$result = Member::with('memberships')->findOrFail($id);
return response()->json($result);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => 'not found'], Response::HTTP_NOT_FOUND);
}
}
示例3: membersCsv
public function membersCsv()
{
if (Gate::denies('admin')) {
Auth::logout();
return redirect('/admin/login');
}
$members = Member::with('group')->get();
$columns = ['id', 'email', 'first_name', 'last_name', 'country', 'group.name', 'created_at', 'birthdate', 'faculty'];
$headers = ['ID', 'Email', 'First Name', 'Last Name', 'Country', 'Team Name', 'Registered At', 'Birthdate', 'Faculty/School'];
$csv = $this->exportCsv($members, $columns, $headers);
$csvName = 'eca-members-' . date('Y-m-d-His') . '.csv';
return response($csv, 200, ['Content-type' => 'text/csv', 'Content-Disposition' => sprintf('attachment; filename="%s"', $csvName), 'Content-Length' => strlen($csv)]);
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$data = Member::with('person.contacts', 'person.files', 'person.education')->paginate(50);
return view('admin.index', compact('data'));
}
示例5: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show(Request $request, $id)
{
// Fetch the first match
// detail -- [ high | med | low ]
$detailLevel = $request->input('detail', 'low');
// Todo: Add $detailLevel == med
try {
if ($detailLevel == 'high') {
// Todo: to add more "eager loaded" relationshions, add extra args to Member::with()
$member = Member::with('postings')->where('regt_num', $id)->withTrashed()->firstOrFail();
} else {
// when $detailLevel == low
$member = Member::where('regt_num', $id)->withTrashed()->firstOrFail();
}
return response()->json(['member' => $member->toArray()]);
} catch (\Exception $ex) {
return response()->json(['error' => ['code' => $ex->getCode(), 'reason' => $ex->getMessage()]], 404);
}
}
示例6: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return Member::with(['experiences' => function ($query) {
$query->with('project');
}])->where('id', $id)->first();
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$member = Member::with('contacts', 'projects', 'sector')->find($id);
return view('members.show', compact('member'));
}
示例8: index
public function index()
{
return view('committee/table', ['membersJson' => Member::with('college', 'course', 'scholarship')->get()->map(function ($member) {
return $member->setAllVisible();
})->toJson()]);
}
示例9: function
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/home', function () {
return view('welcome');
});
Route::get('/', function () {
return view('welcome');
});
Route::get('/members/frontend', function () {
// Approved()->
$members = \App\Member::with('sector')->approved()->get();
return view('members.frontend', compact('members'));
});
Route::get('/thanks', ['as' => 'thank.you', function () {
return view('members.thanks');
}]);
Route::group(['middleware' => 'auth'], function () {
Route::get('members/create', ['uses' => 'MembersController@Create', 'as' => 'members.create']);
Route::get('members/links/{id}', ['uses' => 'MembersController@AddLinks', 'as' => 'members.links']);
Route::get('members/projects/{id}', ['uses' => 'MembersController@AddProjects', 'as' => 'members.projects']);
Route::post('members/links/{id}', ['uses' => 'MembersController@SaveLinks', 'as' => 'members.links.save']);
Route::post('member/project/{id}/save', ['uses' => 'MembersController@SaveProject', 'as' => 'members.project.save']);
Route::post('members', ['uses' => 'MembersController@store', 'as' => 'members.save']);
Route::get('members/', ['uses' => 'MembersController@index', 'as' => 'members.view']);
Route::get('members/approve/{id}', ['uses' => 'MembersController@approve', 'as' => 'members.approve']);
});
示例10: show
public function show()
{
return view('directory/table', ['membersJson' => Member::with('college', 'course')->get()->toJson()]);
}