本文整理汇总了PHP中app\Contact::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::get方法的具体用法?PHP Contact::get怎么用?PHP Contact::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Contact
的用法示例。
在下文中一共展示了Contact::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$contacts = Contact::get();
if ($contacts != null) {
$returnValue['status'] = 200;
$returnValue['message'] = $contacts;
return Response::json($returnValue, 200);
}
$returnValue['status'] = 400;
$returnValue['error_message'] = 'An error occurred while fetching contacts.';
return Response::json($returnValue, 400);
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (\Request::input('filter')) {
$filter = json_decode(\Request::input('filter'), true);
for ($i = 0; $i < count($filter); $i++) {
$field = $filter[$i]['property'];
$value = $filter[$i]['value'];
$operator = isset($filter[$i]['operator']) ? $filter[$i]['operator'] : null;
$filterType = isset($filter[$i]['type']) ? $filter[$i]['type'] : null;
switch ($filterType) {
case 'string':
$contact = contact::where($field, $operator, "%{$value}%");
$count = contact::where($field, $operator, "%{$value}%")->count();
break;
}
}
return \Response::json(array('success' => true, 'contacts' => $contact->get()));
} else {
return \Response::json(array('success' => true, 'contacts' => Contact::get()));
}
}