Skip to content

Instantly share code, notes, and snippets.

View saeedhajinasiri's full-sized avatar

Saeed Nasiri saeedhajinasiri

View GitHub Profile
<ul class="submenu">
<li><a href="/courses?type=2">مدارس بین المللی</a></li>
<li><a href="/courses?type=1">دوره‌های زبان</a></li>
<li><a href="/courses?type=3">دانشگاه‌ها</a></li>
<li><a href="/courses?type=4">دوره‌های کاربردی و تابستانی</a></li>
</ul>
<?php
use Illuminate\Database\Eloquent\Model;
/**
* Class Member
* @package App
*/
class Member extends Model
{
/**
<?php
public function getFirstNameAttribute($value)
{
return ucfirst($value);
}
<?php
$user = App\Member::create([
'first_name' => 'saeed',
'last_name' => 'nasiri',
'email' => 'saeed.nasiri@gmail.com',
'password' => '!supersecretpassword!',
'last_login' => Carbon\Carbon::now(),
'settings' => ['two_factor_aut' => false, 'session_time' => 1200],
'created_at' => Carbon\Carbon::now(),
'updated_at' => Carbon\Carbon::now()
<?php
/**
* Get members full name
*
* @return string
*/
public function getFullNameAttribute()
{
return ucfirst($this->first_name) . ' ' . ucfirst($this->last_name);
}
<?php
$member = App\Member::find(1);
echo $member->full_name;
<?php
/**
* Custom format for the last login date
*
* @param $value
* @return string
*/
public function getLastLoginAttribute($value)
{
return \Carbon\Carbon::parse($value)->format('d.m.Y.');
<?php
$member = App\Member::find(1);
echo $member->last_login;
<?php
/**
* Make sure that first name is capitalized BEFORE saving it to the database
*
* @param $value
* @return string
*/
public function setFirstNameAttribute($value)
{
$this->attributes['first_name'] = ucfirst($value);
<?php
public function setPasswordAttribute($value) {
$this->attributes['password'] = Hash::make($value);
}