PHP code example of timmcleod / laravel-view-model
1. Go to this page and download the library: Download timmcleod/laravel-view-model 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/ */
// Inside of EditProfileViewModel class:
/**
* Returns true if the user's timezone is the same as the given timezone.
*
* @param Timezone $timezone
* @return bool
*/
public function isSelectedTimezone(Timezone $timezone)
{
return $this->user->timezone === $timezone->code;
}
// Inside of EditProfileViewModel class:
/**
* Returns the first half of cities from the cities array.
*
* @return array
*/
public function citiesCol1()
{
$len = count($this->cities);
return $this->cities->slice(0, round($len / 2));
}
/**
* Returns the second half of cities from the cities array.
*
* @return array
*/
public function citiesCol2()
{
$len = count($this->cities);
return $this->cities->slice(round($len / 2));
}