Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Iftakharul Alam committed Feb 18, 2024
2 parents 9882b66 + 7b515fc commit e98852d
Show file tree
Hide file tree
Showing 84 changed files with 14,375 additions and 7,513 deletions.
16 changes: 11 additions & 5 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ APP_NAME=Snapovia
APP_ENV=local
APP_KEY=
APP_DEBUG=false
APP_URL=http://snapovia.local
APP_URL=http://snapovia.test

LOG_CHANNEL=daily

DB_CONNECTION=mysql
DB_HOST=mysqldb
DB_HOST=snapovia_db
DB_PORT=3306
DB_DATABASE=snapoviadb
DB_USERNAME=snapovia
DB_PASSWORD=password
DB_DATABASE=snapovia
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand Down Expand Up @@ -47,6 +47,12 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

LARAVEL_WEBSOCKETS_HOST=127.0.0.1
LARAVEL_WEBSOCKETS_PORT=6001
LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=
LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=
LARAVEL_WEBSOCKETS_SSL_PASSPHRASE=

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ yarn-error.log
storage/tmp/
.idea/
public/dist/
docker/db
docker/mysql
.phpunit.cache
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
21 changes: 17 additions & 4 deletions app/Events/CustomerRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace App\Events;

use App\Models\Customer;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -17,12 +16,26 @@ class CustomerRegistered
{
use Dispatchable, InteractsWithSockets, SerializesModels;

public function __construct(private readonly Customer $customer)
/**
* @var Customer
*/
public $customer;

/**
* Create a new event instance.
*/
public function __construct(Customer $customer)
{
//
$this->customer = $customer;
}


public function broadcastOn(): Channel
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Helpers/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function toOrder(): ?Order
if ($this->check()) {
$quote = $this->get();

$order = new Order();
$order = new Order;
$order->customer_ip = request()->ip();
$order->customer_id = \App\Facades\Customer::check() ? \App\Facades\Customer::user()->id : 0;
$order->status = 'processing';
Expand Down
4 changes: 1 addition & 3 deletions app/Helpers/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ public function logout(): void

/**
* Get customer object
*
* @return \App\Models\Customer
*/
public function user(): ?\App\Models\Customer
{
if (! $this->check()) {
if (!$this->check()) {
return null;
}
$customer = \App\Models\Customer::find(session(self::CUSTOMER_SESSION_KEY)->customer_id);
Expand Down
2 changes: 0 additions & 2 deletions app/Helpers/Vendor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public function logout(): void

/**
* Get vendor object
*
* @return \App\Models\Vendor
*/
public function user(): ?\App\Models\Vendor
{
Expand Down
14 changes: 8 additions & 6 deletions app/Http/Controllers/Admin/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ public function login()
return view('admin.auth.login');
}

protected function credentials(Request $request): array
{
return ['email' => $request->email, 'password' => $request->password, 'status' => 1];
}

public function loginPost(AdminLoginRequest $request)
{
$credentials = [
'email' => $request->email,
'password' => $request->password,
];
if (Auth::attempt($credentials)) {
if (Auth::attempt($this->credentials($request))) {
return redirect()->route('admin.dashboard');
}

return redirect()->back();
return redirect()->route('admin.login')
->with('error', 'Invalid email or password');
}

public function logout()
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/Admin/RefundController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class RefundController extends Controller
{
public function index()
{
return view('admin.sales.order.index');
$orders = collect([]);

return view('admin.sales.order.index')
->with(compact('orders'));
}
}
5 changes: 1 addition & 4 deletions app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

class UserController extends Controller
{
/**
* @var UserRepositoryInterface
*/
private $userRepository;
private UserRepositoryInterface $userRepository;

public function __construct(UserRepositoryInterface $userRepository)
{
Expand Down
19 changes: 12 additions & 7 deletions app/Http/Controllers/Front/CatalogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Product;
use Illuminate\Http\Request;

class CatalogController extends Controller
{
public function category(Request $request)
public function __invoke(Request $request)
{
$query = Category::query();

Expand All @@ -20,14 +21,18 @@ public function category(Request $request)
$query = $query->where('id', 1);
}
$category = $query->select(['id', 'name', 'url_key'])
->with(['childCategories' => function ($query) {
$query->withCount('products');
}])
->with([
'childCategories' => function ($query) {
$query->withCount('products');
},
])
->firstOrFail();

$products = \App\Models\Product::with(['categories' => function ($query) {
$query->select(['name', 'url_key']);
}])->front($sort_by, $category->id)
$products = Product::with([
'categories' => function ($query) {
$query->select(['name', 'url_key']);
},
])->front($sort_by, $category->id)
->paginate(18);

return view('front.catalog.category', compact('category', 'products'));
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/Front/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CheckoutController extends Controller

public function index()
{
if (! Cart::count()) {
if (!Cart::count()) {
return redirect()->route('cart');
}

Expand All @@ -39,7 +39,7 @@ public function submit(OrderSubmitRequest $request)

public function cart()
{
if (! Cart::check()) {
if (!Cart::check()) {
Cart::create();
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public function submitWithPayment()
'product_data' => [
'name' => config('app.name'),
'description' => 'Order Total Amount',
'images' => [route('welcome').'/snapovia.png'],
'images' => [route('welcome') . '/snapovia.png'],
],
],
'quantity' => 1,
Expand All @@ -89,7 +89,7 @@ public function submitWithPayment()
//'livemode' => false,
'mode' => 'payment',
'success_url' => route('checkout.success'),
'cancel_url' => route('checkout').'?payment=failed',
'cancel_url' => route('checkout') . '?payment=failed',
]);

return view('user.payment.index', ['session_id' => $session->id]);
Expand Down
12 changes: 4 additions & 8 deletions app/Http/Controllers/Front/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
namespace App\Http\Controllers\Front;

use App\Http\Controllers\Controller;
use App\Models\Product;
use Illuminate\Http\Request;

class SearchController extends Controller
{
public function index(Request $request)
public function __invoke(Request $request)
{
$products = \App\Models\Product::whereStatus(1)
->where('name', 'LIKE', '%'.$request->search.'%')
$products = Product::whereStatus(1)
->where('name', 'LIKE', '%' . $request->search . '%')
->select(['name', 'id', 'price', 'sku'])
->paginate(18);
$categories = [];

return view('front.search.index', compact('products', 'categories'));
}

public function view(Request $request)
{

}
}
12 changes: 8 additions & 4 deletions app/Http/Controllers/Traits/MediaUploadingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
namespace App\Http\Controllers\Traits;

use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;

trait MediaUploadingTrait
{
/**
* @throws ValidationException
*/
public function storeMedia(Request $request)
{
// Validates file size
if (request()->has('size')) {
$this->validate(request(), [
'file' => 'max:'.request()->input('size') * 1024,
'file' => 'max:' . request()->input('size') * 1024,
]);
}

Expand All @@ -29,16 +33,16 @@ public function storeMedia(Request $request)
$path = storage_path('tmp/uploads');

try {
if (! file_exists($path)) {
mkdir($path, 0755, true);
if (!file_exists($path) && !mkdir($path, 0755, true) && !is_dir($path)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path));
}

} catch (\Exception $e) {
}

$file = $request->file('file');

$name = uniqid().'_'.trim($file->getClientOriginalName());
$name = uniqid('', true) . '_' . trim($file->getClientOriginalName());

$file->move($path, $name);

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Traits/OrderProcessTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace App\Http\Controllers\Traits;

use App\Facades\Cart;
use App\Models\Order;
use App\Models\Shipping;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

trait OrderProcessTrait
{
protected function processOrder(Request $request)
protected function processOrder(Request $request): ?Order
{
try {
DB::beginTransaction();
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Livewire/Front/Catalog/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ public function addToCart($sku)
*/
public function addToWishlist($sku)
{
if (! Customer::check()) {
if (!Customer::check()) {
return redirect()->route('customer.login');
}
session()->flash('success', 'Product added to your wishlist 😀');

return null;
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Front/CheckoutCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function applyCoupon()
Cart::applyCoupon($rule->id);
$this->cart = Cart::get();
$this->cartCalculate();
session()->flash('success', 'Coupon code: <strong>'.$this->coupon_code.'</strong> Applied successfully');
session()->flash('success', 'Coupon code: <strong>' . $this->coupon_code . '</strong> Applied successfully');
} else {
session()->flash('error', 'Sorry, Invalid Coupon applied');
}
Expand Down
7 changes: 4 additions & 3 deletions app/Http/Livewire/Front/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

namespace App\Http\Livewire\Front;

use App\Models\Product;
use Livewire\Component;

class Search extends Component
{
public $search = '';
public string $search = '';

protected $updatesQueryString = ['search'];
protected array $updatesQueryString = ['search'];

public function render()
{
$response = \App\Models\Product::search($this->search);
$response = Product::search($this->search);

return view('livewire.front.search', compact('response'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Front/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function subscribe()
]);

\App\Models\Subscription::create(['email' => $this->email]);
Mail::to($this->email)->queue(new SubscriptionMail());
Mail::to($this->email)->queue(new SubscriptionMail);
$this->reset();
session()->flash('success', 'Subscription completed successfully');

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Authenticate extends Middleware
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
if (!$request->expectsJson()) {
return route('login');
}
}
Expand Down
Loading

0 comments on commit e98852d

Please sign in to comment.