Skip to content

Commit

Permalink
Add condition
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesChou committed Aug 17, 2023
1 parent faf5f8f commit b22e3e5
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 66 deletions.
22 changes: 22 additions & 0 deletions app/Console/Commands/OperationActivate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Laravel\Pennant\FeatureManager;

class OperationActivate extends Command
{
protected $signature = 'app:operation:activate';

protected $description = 'Activate operation';

public function handle(FeatureManager $feature): int
{
$feature->activate('operation');

$this->line('Activated');

return self::SUCCESS;
}
}
22 changes: 22 additions & 0 deletions app/Console/Commands/OperationDeactivate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Laravel\Pennant\FeatureManager;

class OperationDeactivate extends Command
{
protected $signature = 'app:operation:deactivate';

protected $description = 'Deactivate operation';

public function handle(FeatureManager $feature): int
{
$feature->deactivate('operation');

$this->line('Deactivated');

return self::SUCCESS;
}
}
22 changes: 22 additions & 0 deletions app/Console/Commands/OperationStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Laravel\Pennant\FeatureManager;

class OperationStatus extends Command
{
protected $signature = 'app:operation:status';

protected $description = 'Check operation status';

public function handle(FeatureManager $feature): int
{
$status = $feature->when('operation', fn() => 'Active', fn() => 'Inactive');

$this->line($status);

return self::SUCCESS;
}
}
18 changes: 18 additions & 0 deletions app/Features/Operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Features;

class Operation
{
public readonly string $name;

public function __construct()
{
$this->name = 'operation';
}

public function resolve(): bool
{
return true;
}
}
2 changes: 2 additions & 0 deletions app/Providers/FeatureFlagsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace App\Providers;

use App\Features\Operation;
use Illuminate\Support\ServiceProvider;
use Laravel\Pennant\Feature;

class FeatureFlagsServiceProvider extends ServiceProvider
{
public function boot(): void
{
Feature::define(Operation::class);
}
}
62 changes: 33 additions & 29 deletions resources/views/inc/app/navigation-bar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
<li>
<a href="call:4222022">Call us:+4222022</a>
</li>
@feature('operation')
<li>
<a href="{{route('register')}}">Sign up</a>
<a href="{{ route('register') }}">Sign up</a>
</li>
<li>
<a href="{{route('login')}}">Login</a>
<a href="{{ route('login') }}">Login</a>
</li>
<li class="active">
<a href="{{route('myOrder.index')}}">Track my order</a>
<a href="{{ route('myOrder.index') }}">Track my order</a>
</li>
@endfeature
</ul>
</div>
</section>
Expand All @@ -23,62 +25,64 @@
<section class="header-main border-bottom">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-3 col-sm-6 col-md-3 col-5">
<a href="{{route('shop.index')}}" class="brand-wrap" data-abc="true">
<div class="col-lg-3 col-sm-6 col-md-3 col-5">
<a href="{{ route('shop.index') }}" class="brand-wrap" data-abc="true">
{{-- <img class="logo" width="50px" src="{{asset('logo.png')}}"> --}}
<span class="logo">Mart</span>
<span class="logo">Mart</span>
</a> </div>
<div class="col-lg-6 col-sm-8 col-md-6 col-xl-5 d-none d-md-block">
<form action="{{route('shop.catalog')}}" class="search-wrap">
<form action="{{ route('shop.catalog') }}" class="search-wrap">
@csrf
<div class="input-group w-100">
<div class="input-group w-100">
<input type="text" class="form-control search-form" name="filter[title]" placeholder="Search">
<div class="input-group-append">
<button type="submit" class="btn btn-primary search-button"> <i class="fa fa-search"></i>
</button>
<div class="input-group-append">
<button type="submit" class="btn btn-primary search-button"> <i class="fa fa-search"></i>
</button>
</div>
</div>
</form>
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xl-4 col-7">
<div class="d-flex justify-content-end">
<a class="nav-link nav-user-img text-white" href="{{route('cart.index')}}"> <i class="fas fa-shopping-cart"></i></a>
@guest
<a class="nav-link nav-user-img text-white" href="{{route('login')}}"> LOGIN</a>
@endguest
@auth
<a class="nav-link nav-user-img text-white" href="{{route('home.index')}}"> Account</a>
@endauth
@feature('operation')
<div class="col-lg-3 col-sm-6 col-md-3 col-xl-4 col-7">
<div class="d-flex justify-content-end">
<a class="nav-link nav-user-img text-white" href="{{ route('cart.index') }}"> <i class="fas fa-shopping-cart"></i></a>
@guest
<a class="nav-link nav-user-img text-white" href="{{ route('login') }}"> LOGIN</a>
@endguest
@auth
<a class="nav-link nav-user-img text-white" href="{{ route('home.index') }}"> Account</a>
@endauth
</div>
</div>
</div>
@endfeature
</div>
</div>
</section>

<nav class="navbar navbar-expand-md navbar-main border-bottom shadow bg-light">
<div class="container">
<form action="{{route('shop.catalog')}}" class="d-md-none my-2">
<div class="input-group">
<div class="input-group">
<input type="search" name="filter[title]" class="form-control" placeholder="Search" required="">
<div class="input-group-append">
<button type="submit" class="btn btn-secondary"> <i class="fa fa-search"></i> </button>
<div class="input-group-append">
<button type="submit" class="btn btn-secondary"> <i class="fa fa-search"></i> </button>
</div>
</div>
</form>
</form>
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#dropdown6" aria-expanded="false"> <span class="navbar-toggler-icon"></span> </button>
<div class="navbar-collapse collapse" id="dropdown6" style="">
<ul class="navbar-nav mr-auto">

@foreach($navbarCategories as $category)
<li class="nav-item dropdown small"> <a class="nav-link dropdown-toggle" href="" data-toggle="dropdown" data-abc="true" aria-expanded="false">{{$category->category_name}}</a>
<ul class="dropdown-menu">
<ul class="dropdown-menu">
@foreach($category->subCategory as $item)
<a class="dropdown-item" href="{{'/catalog?filter[subCategory]='.$item->subCategory_name}}" style="font-size:.8rem" class="text-sm" data-abc="true">{{$item->subCategory_name}}</a>
@endforeach
<a class="dropdown-item" href="{{'/catalog?filter[subCategory]='.$item->subCategory_name}}" style="font-size:.8rem" class="text-sm" data-abc="true">{{$item->subCategory_name}}</a>
@endforeach
</ul>
</li>
@endforeach

</ul>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<!-- Styles -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
@stack('css')
</head>
Expand All @@ -28,8 +28,8 @@
@yield('content')
@include('inc.app.footer')
</div>


@include('sweetalert::alert')
<script src="{{ asset('js/app.js') }}"></script>
<script src="{{ asset('js/shop.js') }}"></script>
Expand Down
22 changes: 12 additions & 10 deletions resources/views/shop/catalog.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div class="text-md-left text-center float-md-left mb-3 mt-3 mt-md-0 mb-md-0">
@if(request()->get('q'))
<h4>Showing results for "{{request()->get('q')}}"</h4>
<h4>Showing results for "{{ request()->get('q') }}"</h4>
@endif
</div>
{{-- <div class="dropdown text-md-right text-center float-md-right mb-3 mt-3 mt-md-0 mb-md-0">
Expand All @@ -26,7 +26,7 @@
<a class="dropdown-item" href="#">Best Selling</a>
</div>
</div> --}}

</div>
</div>
<div class="row">
Expand All @@ -45,7 +45,9 @@
<p class="text-orange py-0 my-0 h5">Rs.{{number_format($product->price)}}</p>
@endif
</div>
@feature('operation')
<button class="btn btn-orange btn-block">Add to cart</button>
@endfeature
</div>
</a>
</div>
Expand All @@ -56,12 +58,12 @@
<div class="text-center">
<h4>Search No Result.</h4>
<p>We're sorry. We cannot find any matches for your search term.</p>
<img src="{{asset('images/demo/empty.svg')}}" class="w-100" alt="">
<img src="{{ asset('images/demo/empty.svg') }}" class="w-100" alt="">
</div>
</div>
</div>
@endif

</div>
<div class="row sorting my-5">
<div class="col-12">
Expand All @@ -75,17 +77,17 @@
<div class="col-md-4 order-md-1 col-lg-3 sidebar-filter">
{{-- <h3 class="mt-0 mb-5">Showing <span class="text-primary">12</span> Products</h3> --}}
<h6 class="text-uppercase font-weight-bold mb-3">Categories</h6>
<form action="{{route('shop.catalog')}}">
<form action="{{ route('shop.catalog') }}">
@csrf
<div class="my-2 pl-2">
@foreach($productCategories as $category)
<div class="custom-control custom-checkbox my-1">
<input type="checkbox" class="custom-control-input" id="{{$category->subCategory_name}}" name="filter[subCategory]" value="{{$category->subCategory_name}}">
<label class="custom-control-label" for="{{$category->subCategory_name}}">{{$category->subCategory_name}}</label>
<input type="checkbox" class="custom-control-input" id="{{ $category->subCategory_name }}" name="filter[subCategory]" value="{{ $category->subCategory_name }}">
<label class="custom-control-label" for="{{ $category->subCategory_name }}">{{ $category->subCategory_name }}</label>
</div>
@endforeach
</div>

<div class="divider mt-5 mb-5 border-bottom border-secondary"></div>
<h6 class="text-uppercase mt-5 mb-3 font-weight-bold">Price</h6>
<div class="d-flex align-items-center">
Expand All @@ -99,5 +101,5 @@
</div>

</div>
</div>
@endsection
</div>
@endsection
50 changes: 26 additions & 24 deletions resources/views/shop/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,34 @@
<p>{{ $product->product_code }}</p>
</div>

<div class="my-3">
<h4>Quantity:</h4>
<div class="d-flex">
<button onclick="cartDecrement()" class="btn btn-outline-primary px-3">-
</button>
<input type="text" value="1" id="cartCount" name="quantity" placeholder="1"
class="pl-3 border" disabled style="width: 50px">
<button onclick="cartIncrement()" class="btn btn-outline-primary px-3">+
</button>
@feature('operation')
<div class="my-3">
<h4>Quantity:</h4>
<div class="d-flex">
<button onclick="cartDecrement()" class="btn btn-outline-primary px-3">-
</button>
<input type="text" value="1" id="cartCount" name="quantity" placeholder="1"
class="pl-3 border" disabled style="width: 50px">
<button onclick="cartIncrement()" class="btn btn-outline-primary px-3">+
</button>
</div>
</div>
</div>

<p>&nbsp;</p>

@if ($product->stock > 0)
<form action="{{ route('cart.store') }}" id="addToCartForm" method="POST">
@csrf
<input type="hidden" name="product_id" value="{{ $product->id }}">
<input type="hidden" id="stockVal" value="{{ $product->stock }}">
<input type="hidden" id="quantity" name="quantity" value="">
<button id="addToCartBtn" type="submit" class="btn btn-orange">Add to Cart
</button>
</form>
@else
<button id="addToCartBtn" class="btn btn-secondary">Out of stock</button>
@endif
<p>&nbsp;</p>

@if ($product->stock > 0)
<form action="{{ route('cart.store') }}" id="addToCartForm" method="POST">
@csrf
<input type="hidden" name="product_id" value="{{ $product->id }}">
<input type="hidden" id="stockVal" value="{{ $product->stock }}">
<input type="hidden" id="quantity" name="quantity" value="">
<button id="addToCartBtn" type="submit" class="btn btn-orange">Add to Cart
</button>
</form>
@else
<button id="addToCartBtn" class="btn btn-secondary">Out of stock</button>
@endif
@endfeature

<p>&nbsp;</p>

Expand Down
Loading

0 comments on commit b22e3e5

Please sign in to comment.