本文整理汇总了PHP中app\models\Person::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::where方法的具体用法?PHP Person::where怎么用?PHP Person::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Person
的用法示例。
在下文中一共展示了Person::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPerson
public function getPerson($name = false, $where = [])
{
if (env('APP_DEBUG', false)) {
$where_str = '';
if (!empty($where)) {
$where_str = 'where ';
foreach ($where as $field => $val) {
$where_str .= ',' . $field . '=' . $val;
}
}
\Debugbar::info('PersonRepository::getPerson(' . ' name:' . $name . ') ' . $where_str);
}
$people = false;
if ($name) {
$where['name'] = $name;
}
$people = empty($where) ? Person::all() : Person::where($where)->get();
//
// prepare results:
// fixup sn urls from accounts and photos
//
if (!empty($people)) {
foreach ($people as $key => $person) {
if (isset($person->accounts)) {
$accts = explode(',', $person->accounts);
foreach ($accts as $act) {
$pair = explode('=', $act);
if (!empty($pair) && count($pair) == 2) {
$url = $this->getUrl($pair[0], $pair[1]);
if ($url) {
$people[$key][$pair[0]] = $url;
}
}
}
}
if (isset($person->photos)) {
$photos = explode(',', $person->photos);
foreach ($photos as $photo) {
$pair = explode('=', $photo);
if (!empty($pair) && count($pair) == 2) {
$people[$key][$pair[0] . '_photo'] = $pair[1];
}
}
}
\Debugbar::info('PersonRepository::getPerson - ' . print_r($people[$key], true));
}
}
return $people;
}
示例2: getPerson
public function getPerson($id = null)
{
try {
$response = [];
$statusCode = 200;
//$city = City::all();
$id = Request::segment(2);
if ($id != null) {
$id = Person::where('country_id', 'like', $this->getCountryIdOfFestival($id));
}
$id = $id->get();
foreach ($id as $a) {
$response[] = ['id' => $a->id, 'value' => $a->first_name . ' ' . $a->last_name . ', ' . $a->name . ' (' . $a->city . ')'];
}
} catch (Exception $e) {
$statusCode = 404;
} finally {
return Response::json($response, $statusCode);
}
}
示例3: run
public function run()
{
// add a sample employee
$person = Person::where('first_name', 'Francesco')->where('last_name', 'Meli')->first();
if (isset($person)) {
User::create(['person_id' => $person->id, 'username' => 'pinkynrg', 'password' => '$2y$10$95CM4BghK9tM0HxsDfAFyO0Ofw7AavS7rC6pArWpEk5ehw12P.U2a']);
}
// add a sample customer
$person = Person::where('first_name', 'James')->where('last_name', 'Sample')->first();
if (isset($person)) {
User::create(['person_id' => $person->id, 'username' => 'sample_customer', 'password' => '$2y$10$95CM4BghK9tM0HxsDfAFyO0Ofw7AavS7rC6pArWpEk5ehw12P.U2a']);
}
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Performer::find($id)->Festival()->detach();
Performer::find($id)->Association()->detach();
$person = Person::find($id);
$a = Person::where('id', $id)->delete();
$response = [];
$response["name"] = $person->name;
if ($a > trashed()) {
$statusCode = 200;
$response['result'] = "deleted";
} else {
$statusCode = 422;
$response['result'] = "Cannot delete.";
}
return Response::json($response, $statusCode);
}
示例5: person
public function person($company_id)
{
$person = Person::where('salesman_yn', 'Y')->where('company_id', $company_id)->orderBy('id', 'desc')->paginate(5);
$data = ['person' => $person];
return view('order.person', compact('data'));
}
示例6: index
public function index()
{
$person = Person::where('id', '>=', '1')->orderBy('id', 'desc')->paginate(5);
return view('person.index', compact('person'));
}