Last active
December 6, 2018 05:44
-
-
Save avosalmon/0982cb7dba0b9d350091880407f3cf6c to your computer and use it in GitHub Desktop.
ProductController before refactoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ProductController extends Controller | |
{ | |
public function show($id) | |
{ | |
$product = $this->products->findOrFail($id); | |
$data = [ | |
'head' => $this->generateHeadTagsArray([ | |
'title' => $product->search_engine_title, | |
'keywords' => $product->product_name, | |
'description' => $product->search_engine_description, | |
'ogp_type' => 'product', | |
'ogp_title' => $product->ogp_title, | |
'ogp_image' => $product->image_url, | |
'ogp_url' => 'https://example.com/products/' . $id, | |
'canonical_url' => 'https://example.com/products/' . $id | |
]), | |
'product' => $product, | |
]; | |
return view('product.show', $data); | |
} | |
/** | |
* Generate head tags array. | |
* | |
* @param array $attributes | |
* @return array | |
*/ | |
protected function generateHeadTagsArray($attributes) | |
{ | |
// some formatting logic | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment