1. Go to this page and download the library: Download trexology/contactable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Add a phone number to a new model
$model = new Model;
$model->phones()->save(new \Trexology\Contactable\PhoneNumber(['number' => '123 4567']));
// Add multiple addresses to a pre-existing model
$model = Model::find(1);
$model->phones()->saveMany([
new \Trexology\Contactable\PhoneNumber(['number' => '(234) 567-8900']),
new \Trexology\Contactable\PhoneNumber(['number' => '2222222']),
]);
// Query records which have at least two addresses
Model::has('phones', '>=', 2)->get();
// Query records which have a specific phone number
$number = '(000) 011-0000';
Model::whereHas('phones', function ($query) use ($number) {
$query->where('raw_number', '=', preg_replace("/[^0-9]/", '', $number)); // query only the numbers
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.