Database

All database models are stored in system/models/ folder.

Find Single Resource

Example-

$workspace_id = 1;
$contact_id = 1;
$contact = Contact::where('workspace_id',$workspace_id)
                ->where('id',$contact_id)
                ->first();

Update Single Resource

// First you will have to find the resource 
$contact = Contact::where('workspace_id',$workspace_id)
                ->where('id',$contact_id)
                ->first();
// Now you can update
$contact->email = '[email protected]';
$contact->save();

Creating New Resource

$contact = new Contact;
$contact->email = '[email protected]';
$contact->save();

$contact_id = $contact->id;

Deleting a Resource

// First you will have to find the resource 
$contact = Contact::where('workspace_id',$workspace_id)
                ->where('id',$contact_id)
                ->first();
// Now you can delete
$contact->delete();

Find Many

// It will return all records
$contacts = Contact::where('workspace_id',$workspace_id)->get();

// Now you can run loop, for example-

foreach($contacts as $contact){
// Do something with the $contact
echo $contact->email;
}

// Limit the records
$contacts = Contact::where('workspace_id',$workspace_id)->limit(100)->get();
By continuing to use this site you consent to the use of cookies in accordance with our Cookie policy. close notification