本文整理汇总了PHP中app\models\Group::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::with方法的具体用法?PHP Group::with怎么用?PHP Group::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Group
的用法示例。
在下文中一共展示了Group::with方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDatatable
/**
* Generates the JSON used to display the User Group listing.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v2.0]
* @return String JSON
*/
public function getDatatable()
{
if (Input::has('offset')) {
$offset = e(Input::get('offset'));
} else {
$offset = 0;
}
if (Input::has('limit')) {
$limit = e(Input::get('limit'));
} else {
$limit = 50;
}
if (Input::get('sort') == 'name') {
$sort = 'first_name';
} else {
$sort = e(Input::get('sort'));
}
// Grab all the groups
$groups = Group::with('users')->orderBy('name', 'ASC');
//$users = Company::scopeCompanyables($users);
if (Input::has('search')) {
$groups = $users->TextSearch(e(Input::get('search')));
}
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
$allowed_columns = ['name', 'created_at'];
$sort = in_array($sort, $allowed_columns) ? $sort : 'name';
$groups = $groups->orderBy($sort, $order);
$groupsCount = $groups->count();
$groups = $groups->skip($offset)->take($limit)->get();
$rows = array();
foreach ($groups as $group) {
$group_names = '';
$inout = '';
$actions = '<nobr>';
$actions .= '<a href="' . route('update/group', $group->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
if (!config('app.lock_passwords')) {
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/group', $group->id) . '" data-content="' . trans('admin/groups/message.delete.confirm') . '" data-title="Delete ' . htmlspecialchars($group->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a> ';
} else {
$actions .= ' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
}
$actions .= '</nobr>';
$rows[] = array('id' => $group->id, 'name' => $group->name, 'users' => $group->users->count(), 'created_at' => $group->created_at->format('Y-m-d'), 'actions' => $actions ? $actions : '');
}
$data = array('total' => $groupsCount, 'rows' => $rows);
return $data;
}
示例2: index
/**
* Show the application dashboard to the user.
*
* @param Group $group
*
* @return Response
*/
public function index(Group $group, Envoy $envoy)
{
$groups = $group->with('sites')->get();
$siteJsonLink = route('site.json');
$this->setJavascriptData(compact('groups', 'siteJsonLink'));
}
示例3: function
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get('/', function () use($app) {
return $app->welcome();
});
// Auth endpoint
$app->post('v1/auth/login', 'AuthController@postLogin');
$app->group(['prefix' => 'v1', 'middleware' => 'jwt.auth'], function ($app) {
// Get a group and its users
$app->get('/group/{id}', function ($id) {
$group = Group::with('user')->with('users')->find($id);
return response()->json($group);
});
// Get the timeline of certain group
$app->get('/group/{id}/messages', function ($id) {
});
// Create a group
$app->post('/group', function (Request $request) {
$user = JWTAuth::parseToken()->authenticate();
$group = new Group();
$group->name = $request->input('name');
$group->description = $request->input('description');
$group->user_id = $user->id;
$group->save();
return response()->json($group);
});
示例4: sendMessage
public function sendMessage($society, $type)
{
$soc = Society::find($society);
$input = Input::all();
$alldat = array();
if ($input['leaderoptions'] == "everyone") {
$allhouseholds = Household::with('individual')->where('society_id', '=', $society)->get();
foreach ($allhouseholds as $hhh) {
foreach ($hhh->individual as $iii) {
if ($iii->id == $hhh->householdcell) {
$dum = self::PopulateRecipient($iii);
if ($dum['cellphone'] != "" and $iii->memberstatus == "member") {
$alldat[$iii->id] = $dum;
}
}
}
}
} elseif (isset($input['groups'])) {
$groups = $input['groups'];
if ($input['leaderoptions'] == "allmembers") {
foreach ($groups as $thisgroup) {
$group = Group::with('individual')->find($thisgroup);
foreach ($group->individual as $indiv) {
$dum = self::PopulateRecipient($indiv);
$alldat[$indiv->id] = $dum;
}
}
} elseif ($input['leaderoptions'] == "leadersonly" or $input['leaderoptions'] == "leadersandlist") {
foreach ($groups as $thisgroup) {
$group = Group::with('individual')->find($thisgroup);
foreach ($group->individual as $indiv) {
if ($group->contact == $indiv->id) {
$dum = self::PopulateRecipient($indiv);
if (!isset($alldat[$indiv->id])) {
$alldat[$indiv->id] = $dum;
}
if ($input['leaderoptions'] == "leadersandlist") {
if (isset($alldat[$indiv->id]['grouplist'])) {
$alldat[$indiv->id]['grouplist'] = $alldat[$indiv->id]['grouplist'] . $group->id . ",";
} else {
$alldat[$indiv->id]['grouplist'] = $group->id . ",";
}
}
}
}
}
}
}
if (isset($input['indivs'])) {
foreach ($input['indivs'] as $individ) {
$indiv = Individual::find($individ);
$dum = self::PopulateRecipient($indiv);
if (!isset($alldat[$individ])) {
$alldat[$individ] = $dum;
}
}
}
if ($type == "email") {
if (isset($input['htmlbody'])) {
$message = nl2br($input['message']) . file_get_contents($input['htmlbody']);
} else {
$message = nl2br($input['message']);
}
$message = HTML::decode($message);
$subject = $input['subject'];
$sender = Input::get('sender');
Mail::queue('messages.message', array('msg' => $message), function ($message) use($subject, $soc, $alldat, $sender) {
if (Input::file('attachment')) {
$message->attach(Input::file('attachment'), array('as' => Input::file('attachment')->getClientOriginalName(), 'mime' => Input::file('attachment')->getMimeType()));
}
foreach ($alldat as $thisrec) {
$name = $thisrec['name'];
$email = $thisrec['email'];
$household = $thisrec['household'];
if (isset($thisrec['grouplist'])) {
$grouplist = $thisrec['grouplist'];
} else {
$grouplist = "No group";
}
$message->from('info@umc.org.za', $soc->society . " Methodist Church");
$message->to($email, $name)->replyTo($sender);
if ($subject == "") {
$subject = "Email from " . $soc->society . " Methodist Church";
}
if ($grouplist != "No group") {
$ggl = explode(",", substr($grouplist, 0, -1));
foreach ($ggl as $gl) {
$repdata = app('App\\Http\\Controllers\\ReportsController')->show($gl, true);
$tg = Group::find($gl);
$message->attachData($repdata, $tg->groupname . ".pdf");
}
}
$message->subject($subject);
}
});
$results = array();
foreach ($alldat as $tdat) {
$result['name'] = $tdat['name'];
$result['address'] = $tdat['email'];
$result['household'] = $tdat['household'];
//.........这里部分代码省略.........
示例5: anyIndex
public function anyIndex()
{
return Group::with(['users'])->get()->toJson();
}
示例6: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$societies = Society::where('group_birthdays', '<>', 0)->select('group_birthdays', 'id', 'email', 'society')->get();
foreach ($societies as $soc) {
// Birthdays
$thisyr = date("Y");
$mon = strval(date('m-d', strtotime("next Monday")));
$tue = strval(date('m-d', strtotime("next Monday") + 86400));
$wed = strval(date('m-d', strtotime("next Monday") + 172800));
$thu = strval(date('m-d', strtotime("next Monday") + 259200));
$fri = strval(date('m-d', strtotime("next Monday") + 345600));
$sat = strval(date('m-d', strtotime("next Monday") + 432000));
$sun = strval(date('m-d', strtotime("next Monday") + 518400));
$msg = "Birthdays for the week: (starting " . $thisyr . "-" . $mon . ")<br><br>";
$days = array($mon, $tue, $wed, $thu, $fri, $sat, $sun);
//DB::enableQueryLog();
$birthdays = Individual::join('households', 'household_id', '=', 'households.id')->where('households.society_id', '=', $soc->id)->select('individuals.id', 'homephone', 'householdcell', 'cellphone', 'firstname', 'surname', DB::raw('substr(birthdate, 6, 5) as bd'))->wherein(DB::raw('substr(birthdate, 6, 5)'), $days)->orderBy(DB::raw('substr(birthdate, 6, 5)'))->get();
//Log::debug(DB::getQueryLog());
foreach ($birthdays as $bday) {
$msg = $msg . date("D d M", strtotime($thisyr . "-" . $bday->bd)) . " " . $bday->firstname . " " . $bday->surname . ":";
if ($bday->cellphone) {
$msg = $msg . " Cellphone: " . $bday->cellphone;
}
if ($bday->homephone) {
$msg = $msg . " Homephone: " . $bday->homephone;
}
if ($bday->householdcell and $bday->householdcell != $bday->id) {
$msg = $msg . " Household cellphone: " . self::gethcell($bday->householdcell);
}
$msg = $msg . "<br>";
//Log::notice($bday->surname . ", " . $bday->firstname);
}
$anniversaries = Specialday::join('households', 'household_id', '=', 'households.id')->select('homephone', 'householdcell', 'addressee', 'household_id', 'anntype', 'details', DB::raw('substr(anniversarydate, 6, 5) as ad'))->wherein(DB::raw('substr(anniversarydate, 6, 5)'), $days)->orderBy(DB::raw('substr(anniversarydate, 6, 5)'))->get();
$msg = $msg . "<br>" . "Anniversaries" . "<br><br>";
foreach ($anniversaries as $ann) {
$msg = $msg . date("D d M", strtotime($thisyr . "-" . $ann->ad)) . " (" . $ann->addressee . ". " . ucfirst($ann->anntype) . ": " . $ann->details . ")";
if ($ann->homephone) {
$msg = $msg . " Homephone: " . $ann->homephone;
}
if ($ann->householdcell) {
$msg = $msg . " Household cellphone: " . self::gethcell($ann->householdcell);
}
$msg = $msg . "<br>";
}
$group = Group::with('individual')->find($soc->group_birthdays);
foreach ($group->individual as $recip) {
$fname = $recip->firstname;
$name = $recip->firstname . " " . $recip->surname;
$email = $recip->email;
$subject = "Birthday email from " . $soc->society . " Methodist Church";
Mail::queue('messages.message', array('msg' => "Good morning, " . $fname . " :)<br><br>" . $msg), function ($message) use($name, $email, $subject, $soc) {
$message->from($soc->email, $soc->society . " Methodist Church");
$message->to($email, $name);
$message->replyTo($email);
$message->subject($subject);
});
}
}
}
示例7: index
/**
* Get full list of groups and basic information
*/
public function index()
{
$g = Group::with('leaders')->with('tags')->get(['id', 'name', 'profile_pic', 'group_type'])->toArray();
// dd($g);
return $g;
}
示例8: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($society, $id)
{
if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
$data['group'] = Group::with(array('individual' => function ($query) {
$query->wherePivot('deleted_at', null)->orderBy('surname', 'asc');
}))->find($id);
$data['individuals'] = Individual::socindiv($society)->get();
$data['society'] = $society;
$coords = Society::find($society);
if ($data['group']->latitude == "0") {
$data['deflat'] = $coords->latitude;
$data['deflon'] = $coords->longitude;
}
$data['history'] = Group::with('individual')->find($id);
$data['members'] = Individual::socindiv($society)->get();
$data['contact'] = Individual::find($data['group']->contact);
$daysofweek = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
$data['meeting'] = $daysofweek[-1 + $data['group']->meeting];
return View::make('groups.edit', $data);
} else {
return View::make("shared.unauthorised");
}
}