本文整理汇总了PHP中app\models\Person::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::all方法的具体用法?PHP Person::all怎么用?PHP Person::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Person
的用法示例。
在下文中一共展示了Person::all方法的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: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
try {
$response = ['person' => []];
$statusCode = 200;
$data = Person::all();
//$users = User::all()->take(9);
foreach ($data as $d) {
$response['person'][] = ['id' => $d->id, 'username' => $d->User['username'], 'first_name' => $d->first_name, 'last_name' => $d->last_name, 'name' => $d->name, 'position' => $d->position, 'address' => $d->address, 'city' => $d->city, 'country' => $d->Country->country_name, 'contact_number' => $d->contact_number, 'email' => $d->email, 'status' => $d->status, 'registerd_by' => $d->CreatedBy['username'], 'user' => $d->User['Role'], 'short_text' => $d->short_text, 'pic' => $d->pic, 'facebook' => $d->facebook, 'twitter' => $d->twitter, 'gplus' => $d->gplus, 'created_at' => $d->created_at, 'updated_at' => $d->updated_at, 'deleted_at' => $d->deleted_at];
}
} catch (Exception $e) {
$statusCode = 404;
} finally {
return Response::json($response['person'], $statusCode);
}
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
try {
$response = ['collab' => []];
$statusCode = 200;
$data = Person::all();
//echo $data;
//$data = Collaborator::all();
//$users = User::all()->take(9);
foreach ($data as $d) {
//echo $d->User->Role->where('id', 4);
//4 = collab
if (sizeof($d->User->Role->where('id', 4)) > 0) {
$response['collab'][] = ['id' => $d->id, 'first_name' => $d->first_name, 'last_name' => $d->last_name, 'name' => $d->name, 'city' => $d->city, 'country' => $d->Country->country_name, 'association' => $d->Association, 'user' => $d->User->Role, 'short_text' => $d->short_text, 'pic' => $d->pic, 'facebook' => $d->facebook, 'twitter' => $d->twitter, 'gplus' => $d->gplus, 'created_at' => $d->created_at, 'updated_at' => $d->updated_at, 'deleted_at' => $d->deleted_at];
}
}
} catch (Exception $e) {
$statusCode = 404;
} finally {
return Response::json($response['collab'], $statusCode);
}
}
示例4: all
public function all()
{
return Person::all();
}
示例5:
require_once __DIR__ . '/vendor/autoload.php';
// Require the person class file
// require("Person.class.php");
// Instantiate the person class
use App\Models\Person;
$person = new \App\Models\Person();
// Create new person
$person->Firstname = "Kona";
$person->Age = "20";
$person->Sex = "F";
$creation = $person->Create();
// Update Person Info
$person->id = "4";
$person->Age = "32";
$saved = $person->Save();
// Find person
$person->id = "4";
$person->Find();
d($person->Firstname, "Person->Firstname");
d($person->Age, "Person->Age");
// Delete person
$person->id = "17";
$delete = $person->Delete();
// Get all persons
$persons = $person->all();
// Aggregates methods
d($person->max('age'), "Max person age");
d($person->min('age'), "Min person age");
d($person->sum('age'), "Sum persons age");
d($person->avg('age'), "Average persons age");
d($person->count('id'), "Count persons");
示例6: index
/**
* Display a listing of the resource.
* @return Response
*/
public function index()
{
$persons = Person::all();
return view('persons.index', compact('persons'));
}