Skip to content

Commit

Permalink
seo
Browse files Browse the repository at this point in the history
  • Loading branch information
Loydtafireyi committed Aug 28, 2020
1 parent d9c647d commit 44fe0ab
Show file tree
Hide file tree
Showing 17 changed files with 178 additions and 18 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function store(CreateProductRequest $request)
'quantity' => $request->quantity,
'category_id' => $request->category_id,
'sub_category_id' => $request->sub_category_id,
'meta_keywords' => $request->meta_keywords,
'meta_description' => $request->meta_description,
'slug' => Str::slug($request->name),
]);

Expand Down Expand Up @@ -140,7 +142,7 @@ public function update(Request $request, Product $product)
'category_id' => 'required',
]);

$data = $request->only(['name', 'code', 'description', 'price', 'category_id', 'sub_category_id', 'quantity']);
$data = $request->only(['name', 'code', 'description', 'price', 'category_id', 'sub_category_id', 'quantity', 'meta_description', 'meta_keywords']);

$product->update($data);

Expand Down
21 changes: 21 additions & 0 deletions app/Http/Controllers/Admin/SystemSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\SystemSetting;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class SystemSettingsController extends Controller
{
Expand Down Expand Up @@ -63,16 +64,36 @@ public function update(Request $request, $slug)
]);
// Find settings to update
$setting = SystemSetting::where('slug', $slug)->firstOrFail();

// Allowed params for update
$data = $request->only([
'name',
'email',
'tel',
'logo',
'favicon',
'address',
'description',
'meta_keywords',
'meta_description',
]);

if($request->hasFile('logo')) {
Storage::disk('public')->delete($setting->logo);

$logo = $request->logo->store($logoPath = 'uploads/logos', 'public');

$setting->save(['logo' => $logoPath]);
}

if($request->hasFile('favion')) {
Storage::disk('public')->delete($setting->favicon);

$favicon = $request->favicon->store($favPath = 'uploads/logos', 'public');

$setting->save(['favicon' => $favPath]);
}

$setting->update($data);

session()->flash('success', 'Company info updated successfully');
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Product;
use App\SystemSetting;
use Illuminate\Http\Request;
use Gloudemans\Shoppingcart\Facades\Cart;

Expand All @@ -15,9 +16,11 @@ class CartController extends Controller
*/
public function index()
{
$systemInfo = SystemSetting::first();

$mightAlsoLike = Product::inRandomOrder()->take(4)->get();

return view('cart', compact('mightAlsoLike'));
return view('cart', compact('mightAlsoLike', 'systemInfo'));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\SystemSetting;
use Illuminate\Http\Request;

class CheckoutController extends Controller
Expand All @@ -13,7 +14,9 @@ class CheckoutController extends Controller
*/
public function index()
{
return view('checkout');
$systemInfo = SystemSetting::first();

return view('checkout', compact('systemInfo'));
}

/**
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/FrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public function show($slug)

$color = $product->attributes()->where('attribute_name', 'Color')->get();
$sizes = $product->attributes()->where('attribute_name', 'Size')->get();
// dd($color);
$pieces = $product->attributes()->where('attribute_name', 'Pieces')->first();
// dd($pieces);

return view('product.show', compact('product', 'relatedProducts', 'singleImage', 'systemName', 'color', 'sizes'));
return view('product.show', compact('product', 'relatedProducts', 'singleImage', 'systemName', 'color', 'sizes', 'pieces'));
}

public function contact()
Expand Down
2 changes: 1 addition & 1 deletion app/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Product extends Model
{
protected $fillable = ['name', 'category_id', 'sub_category_id', 'description', 'code', 'image', 'slug', 'quantity', 'price'];
protected $fillable = ['name', 'category_id', 'sub_category_id', 'description', 'code', 'image', 'slug', 'quantity', 'price', 'meta_keywords', 'meta_description'];

/**
* change key from id to slug
Expand Down
2 changes: 1 addition & 1 deletion app/SystemSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SystemSetting extends Model
{
protected $fillable = ['name', 'description', 'email', 'tel', 'address', 'logo'];
protected $fillable = ['name', 'description', 'email', 'tel', 'address', 'logo', 'favicon', 'meta_keywords', 'meta_description'];

public function getRouteKeyName()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddSeoToProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->text('meta_keywords')->nullable()->after('category_id');
$table->text('meta_description')->nullable()->after('meta_description');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('meta_keywords');
$table->dropColumn('meta_description');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddSeoToSystemSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('system_settings', function (Blueprint $table) {
$table->string('favicon')->nullable()->after('logo');
$table->text('meta_keywords')->nullable()->after('favicon');
$table->text('meta_description')->nullable()->after('meta_keywords');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('system_settings', function (Blueprint $table) {
$table->dropColumn('meta_keywords');
$table->dropColumn('meta_description');
$table->dropColumn('favicon');
});
}
}
10 changes: 10 additions & 0 deletions resources/views/admin/products/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@
@enderror
</div>
</div>
<!-- product seo start -->
<div class="form-group">
<label for="meta_description">Product Meta Description</label>
<textarea name="meta_description" class="form-control" placeholder="Make your product visible on search engine by describing your product...">{{ isset($product) ? $product->meta_description : '' }}</textarea>
</div>
<div class="form-group">
<label for="meta_keywords">Product Meta Keywords</label>
<textarea name="meta_keywords" class="form-control" placeholder="Seperate keywords using comma...">{{ isset($product) ? $product->meta_keywords : '' }}</textarea>
</div>
<!-- product seo start -->

<!-- products attributes start -->
@livewire('attribute')
Expand Down
29 changes: 27 additions & 2 deletions resources/views/admin/settings/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,29 @@
<img src="/storage/{{$setting->logo}}" style="width: 50%">
@endif
<div class="form-group">
<label for="logo">Comapny Logo</label>
<label for="logo">Company Logo</label>
<input type="file" name="logo" id="logo" class="form-control @error('logo') is-invalid @enderror" value="{{ $setting->name }}">

@error('logo')
<span class="invalid-feedback" role="alert">
<strong> {{ $message }} </strong>
</span>
@enderror
</div>
</div>
<!-- Company favicon -->
@if(isset($setting))
<img src="/storage/{{$setting->favicon}}" style="width: 50%">
@endif
<div class="form-group">
<label for="favicon">Company Favicon</label>
<input type="file" name="favicon" id="favicon" class="form-control @error('favicon') is-invalid @enderror" value="{{ $setting->name }}">

@error('favicon')
<span class="invalid-feedback" role="alert">
<strong> {{ $message }} </strong>
</span>
@enderror
</div>
<!-- Company description -->
<div class="form-group">
<label for="description">Company Description</label>
Expand All @@ -55,6 +69,17 @@
<input type="email" name="email" id="email" class="form-control" value="{{ $setting->email }}">
</div>

<!-- system seo start -->
<div class="form-group">
<label for="meta_description">System Meta Description</label>
<textarea name="meta_description" class="form-control" placeholder="Make your web application visible on search engine by describing what you do...">{{ $setting->meta_description }}</textarea>
</div>
<div class="form-group">
<label for="meta_keywords">System Meta Keywords</label>
<textarea name="meta_keywords" class="form-control" placeholder="Seperate keywords using comma...">{{ $setting->meta_keywords }}</textarea>
</div>
<!-- system seo start -->

<div class="form-group">
<button type="submit" class="btn btn-primary">Update Details</button>
</div>
Expand Down
15 changes: 15 additions & 0 deletions resources/views/cart.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
@extends('layouts.frontend')

@section('seo')

<title>
@if(auth()->check())
{{ auth()->user()->name }} 's Cart
@else
Cart
@endif
</title>
<meta charset="UTF-8">
<meta name="description" content="{{ $systemInfo->description }}">
<meta name="keywords" content="{{ $systemInfo->description }}, {{ $systemInfo->description }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

@endsection

@section('content')

Expand Down
10 changes: 10 additions & 0 deletions resources/views/checkout.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
@extends('layouts.frontend')

@section('seo')

<title>{{ $systemInfo->name }} | Checkout</title>
<meta charset="UTF-8">
<meta name="description" content="{{ $systemInfo->description }}">
<meta name="keywords" content="{{ $systemInfo->description }}, {{ $systemInfo->description }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

@endsection

@section('content')

<!-- checkout section -->
Expand Down
2 changes: 0 additions & 2 deletions resources/views/livewire/footer-detail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@
<div class="container">
<div class="social-links">
<a href="" class="instagram"><i class="fa fa-instagram"></i><span>instagram</span></a>
<a href="" class="google-plus"><i class="fa fa-google-plus"></i><span>g+plus</span></a>
<a href="" class="pinterest"><i class="fa fa-pinterest"></i><span>pinterest</span></a>
<a href="" class="facebook"><i class="fa fa-facebook"></i><span>facebook</span></a>
<a href="" class="twitter"><i class="fa fa-twitter"></i><span>twitter</span></a>
<a href="" class="youtube"><i class="fa fa-youtube"></i><span>youtube</span></a>
<a href="" class="tumblr"><i class="fa fa-tumblr-square"></i><span>tumblr</span></a>
</div>

<p class="text-white text-center mt-5">Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | Developed By <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="" target="_blank">Eloquent Geeks</a></p>
Expand Down
16 changes: 9 additions & 7 deletions resources/views/product/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<title>{{ $product->name }} | {{ $systemName->name }}</title>
<meta charset="UTF-8">
<meta name="description" content="{{ $product->description }}">
<meta name="keywords" content="{{ $product->name }}, {{ $product->description }}">
<meta name="description" content="{{ $product->meta_description }}">
<meta name="keywords" content="{{ $product->meta_keywords }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

@endsection
Expand Down Expand Up @@ -47,11 +47,13 @@
<div class="col-lg-6 product-details">
<h2 class="p-title">{{ $product->name }}</h2>
<h3 class="p-price">${{ $product->price }}</h3>
<h4 class="p-stock">Pieces:
<span>
20 Pcs
</span>
</h4>
@if($pieces->count() > 0)
<h4 class="p-stock">Pieces:
<span>
{{ $pieces->attribute_value }}
</span>
</h4>
@endif
<h4 class="p-stock">Availability:
<span>
@if($product->inStock())
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 44fe0ab

Please sign in to comment.