本文整理汇总了PHP中app\Client::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::with方法的具体用法?PHP Client::with怎么用?PHP Client::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Client
的用法示例。
在下文中一共展示了Client::with方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//$client = Client::findOrFail($id);
//return view('clients.show')->withClient($client);
$client = Client::with('Tasks', 'Tasks.taskAssignedTo')->findOrFail($id);
return view('clients.show')->with(compact('client'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return view('project.index', ['clients' => Client::with(['projects' => function ($query) {
$query->select(['*', DB::raw('closed_at IS NULL AS open')]);
$query->orderBy('open', 'desc')->orderBy('closed_at', 'desc')->orderBy('closed_at', 'desc');
}])->orderBy('name')->get()]);
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
if (!($client = Client::with(['projects' => function ($query) {
$query->select(['*', DB::raw('closed_at IS NULL AS open')]);
$query->orderBy('open', 'desc')->orderBy('closed_at', 'desc')->orderBy('closed_at', 'desc');
}])->find($id))) {
return redirect()->action('ClientController@index');
}
return view('client.show', compact('client'));
}
示例4: histories
/**
* client rental histories
* @param $id
* @return \Illuminate\Http\JsonResponse
*/
public function histories($id)
{
$histories = Client::with(['histories' => function ($query) {
$query->join('car', 'car.id', '=', 'rental.car-id')->select('client-id', 'brand', 'type', 'plate', 'date-from', 'date-to');
}])->find($id);
if ($histories == null) {
$histories = ['error' => 'Client data not found'];
}
return response()->json($histories);
}
示例5: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
return Client::with(['images', 'attributes'])->find($id);
}