Skip to content
John Dave Decano edited this page Oct 22, 2013 · 6 revisions

Welcome to the PHPLaravelGymManagementSystem wiki!

Retrieving Members

// Members Model
$members = Member::all();
// Order by latest members
$members = Member::orderBy('created_at','desc')->get();
// Conditions
$members = Member::where('last_name','=','decano')->get();
// Single Result
$member = Member::find($primary_key);
$member->first_name;
$member->last_name;
// Same Result
$member = Member::where('id','=',1)->first();
$member->first_name;
$member->last_name;

Member's Packages

$packages = Memberpackage::where('member_id','=',1)->get();
//Same Result
$member = Member::find(1);
$packages = $member->memberpackages->get();
$member->memberpackages->count(); // Total Member packages

foreach($packages as $p){
     echo $p->expiration;
     echo $p->registration;
     echo $p->service->name;
     echo $p->package->price;
     echo $p->cycle->name;
}
Clone this wiki locally