MetaController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers\Admin\Config\Layout;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Config;
  6. class MetaController extends Controller
  7. {
  8. private Config $configModel;
  9. public function __construct(Config $config)
  10. {
  11. $this->configModel = $config;
  12. }
  13. /**
  14. * 메타 태그
  15. * @method GET
  16. * @see /admin/config/layout/meta
  17. */
  18. public function index()
  19. {
  20. return view('admin.config.layout.meta', []);
  21. }
  22. /**
  23. * 메타 태그 저장
  24. * @method POST
  25. * @see /admin/config/layout/meta
  26. */
  27. public function store(Request $request)
  28. {
  29. $rules = [
  30. 'meta_keywords' => 'string|nullable|max:500',
  31. 'meta_description' => 'string|nullable|max:500',
  32. 'meta_author' => 'string|nullable|max:500',
  33. 'meta_viewport' => 'string|nullable|max:500',
  34. 'meta_application_name' => 'string|nullable|max:500',
  35. 'meta_generator' => 'string|nullable|max:500',
  36. 'meta_robots' => 'string|nullable|max:500',
  37. 'meta_adds_info' => 'string|nullable|max:2000'
  38. ];
  39. $attributes = [
  40. 'meta_keywords' => 'Meta keywords',
  41. 'meta_description' => 'Meta description',
  42. 'meta_author' => 'Meta author',
  43. 'meta_viewport' => 'Meta viewport',
  44. 'meta_application_name' => 'Meta Application Name',
  45. 'meta_generator' => 'Meta Generator',
  46. 'meta_robots' => 'Meta Robots',
  47. 'meta_adds_info' => 'Meta Adds Info'
  48. ];
  49. $posts = $this->validate($request, $rules, [], $attributes);
  50. $this->configModel->save($posts, $attributes);
  51. $message = '메타 정보가 저장되었습니다.';
  52. return redirect()->route('admin.config.layout.meta.index')->with('message', $message);
  53. }
  54. }