Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
eusonlito committed May 5, 2018
2 parents 51f0b44 + 349a1e9 commit 3d10d7c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ abstract class Controller extends BaseController

# Default robots
Meta::set('robots', 'index,follow');

# Default image
Meta::set('image', asset('images/logo.png'));
}
}
```
Expand Down Expand Up @@ -96,6 +99,11 @@ class HomeController extends Controller
# Section description
Meta::set('title', 'This is a detail page');
Meta::set('description', 'All about this detail page');

# Remove previous images
Meta::unset('image');

# Add only this last image
Meta::set('image', asset('images/detail-logo.png'));

return view('detail');
Expand Down
24 changes: 24 additions & 0 deletions src/Eusonlito/LaravelMeta/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ public function set($key, $value)
return $this->metas[$key] = self::cut($value, $key);
}

/**
* @param string $key
*
* @return void
*/
public function unset($key)
{
$method = 'unset'.$key;

if (method_exists($this, $method)) {
$this->$method();
} else {
unset($this->metas[$key]);
}
}

/**
* @param string $value
*
Expand Down Expand Up @@ -152,6 +168,14 @@ private function setImage($value)
return $value;
}

/**
* @return void
*/
private function unsetImage()
{
$this->metas['image'] = [];
}

/**
* @param string $key
* @param string|array $default
Expand Down

0 comments on commit 3d10d7c

Please sign in to comment.