Допустим, у нас есть Post модель, которая выглядит примерно так: <?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* Class Post
*
* @package App
*/
class Post extends Model
{
/**
* @return string
*/
public function getTitle()
{
return $this->getAttribute('title');
}
/**
* @param string $title
* @return $this
*/
public function setTitle(string $title)
{
$this->setAttribute('title', $title);
return $this;
}
/**
* @return string
*/
public function getPost()
{
return $this->getAttribute('post');
}
/**
* @param string $post
* @return $this
*/
public function setPost(string $post)
{
$this->setAttribute('post', $post);
return $this;
}
/**
* @param Account $account
* @return $this
*/
public function setAccount(Account $account)
{
$this->account()->associate($account);