sohail49

sohail49

Member Since 2 Months Ago

Experience Points
640
Total
Experience

4,360 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
640 XP
Sep
17
1 month ago
Activity icon

Replied to Sending An Embedded Logo In Php With PHP Mailer

i did is this way but its not working

I Google It and found this way but its not working

Activity icon

Started a new Conversation Sending An Embedded Logo In Php With PHP Mailer

here is code

 public function send($data)
  {
    $this->mail->addAddress($data['to'], $data['name']);
    $this->mail->Subject = $data['subject'];
    $this->mail->addEmbeddedImage('/images/logo.png', 'logo', 'logo.png');
    $this->mail->Body = make($data['view'], array('data' => $data['body']));
    return $this->mail->send();
  }


$data = [
       'to' => user()->email,
       'subject' => 'Order Confirmation',
       'view' => 'purchase',
       'name' => user()->fullname,
       'body' => $array1
     ];
     $mail = new Mail;
     $mail->send($data);

I call the Image in purchase.php which I call in view in the upper data object

  <img src="cid:logo" width="80px" height="80px" alt="">
Sep
16
1 month ago
Activity icon

Started a new Conversation Updrading Stripe Payment Method To V3 Version

Hi guys I have created a stipe payment method a it works fine but I want to upgrade to the stripe v3 but I don't how tp convert my old method to the new one I look at the doc be they are not so clear here is my old code I am using Altorouter and illuminate for database and blade template engine Vue for front end and axious for HTTP

My route

$router->map('POST', '/cart/payment', 'App\Controllers\[email protected]', 'Payment');

my cart.blade.php file

<button @click.prevent='checkout' class="btn btn-outline-success">Checkout - <i class="fa fa-credit-card"
 aria-hidden="true"></i></button>
  <span id="proporities" class="hide" data-customer-email='{{ user()->email
  data-stripe-api='{{ \App\Classes\Session::get('stripe_key') }}'>
</span>  

after this button get click I take the information to cart.js here is the cart.js code

 var stripe = StripeCheckout.configure({
            key: $('#proporities').data('stripe-api'),
            locale: 'auto',
            token: function(token) {
                var data = $.param({
                    stripeToken: token.id,
                    stripeEmail: token.email
                });
                axios.post('/cart/payment', data).then(function(response) {
                    $('.notifty').css('display', 'block').delay(2000).slideUp(300).html(response.data.success);
                    app.showcart(10);
                }).catch(function(error) {
                    console.log(error)
                });
            }

        });
 var app = new Vue({

            el: '#cart',
            data: {
                amount: 0
            },
            methods: {

	checkout: function() {
                    stripe.open({
                        name: 'Cartzilla Store Inc.',
                        description: 'Your Shopping Cart',
                        zipCode: true,
                        amount: app.amount,
                        email: $('#proporities').data('customer-email')
                    });
	}

in the cart.js axious take to information to PHP controller which I have defined in the top route

here is the controller code

 public function payment()
  {
    $array['product'] = [];
$array['tota_amountl'] = []
$array['order_no'] = []
    if (Request::has('post')) {
      $request = Request::get('post');
      $email = $request->stripeEmail;
      $token = $request->stripeToken;

      try {


        $customer = Customer::create([
          'email' => $email,
          'source' => $token
        ]);

        $amount = convertMoney(Session::get('carttotal'));
        $charge = Charge::create([
          'customer' => $customer->id,
          'amount' => $amount,
          'description' => user()->fullname . 'Cart Purchase',
          'currency' => 'usd'
        ]);

        $orderId = strtoupper(uniqid());

        foreach ($_SESSION['user_cart'] as $items) {
          $productId = $items['product_id'];
          $quantity = $items['quantity'];
          $product = Product::where('id', $productId)->first();

          if (!$product) {
            continue;
          }
          $totalPrice = $product->price * $quantity;
          $totalPrice = number_format($totalPrice, 2);
          Order::create([
            'user_id' => user()->id,
            'product_id' => $productId,
            'unit_price' => $product->price,
            'status' => 'pending',
            'total_price' => $amount,
            'order_no' => $orderId,
            'quantity' => $quantity
          ]);

          $product->quantity = $product->quantity - $quantity;
          $product->save();

          array_push($array['product'], [
            'name' => $product->name,
            'price' => $product->price,
            'quantity' => $quantity,
            'total' => $totalPrice,
          ]);
	array_push($array['order_no'], $orderId);
	array_push($array['tota_amountl'], Session::get('carttotal'));

          Payment::create([
            'user_id' => user()->id,
            'amount' => $charge->amount,
            'status' => $charge->status,
            'order_no' => $orderId
          ]);
        }
  $data = [
           'to' => user()->email,
           'subject' => 'Order Confirmation',
           'view' => 'purchase',
           'name' => user()->fullname,
           'body' => $array
         ];
         $mail = new Mail;
         $mail->send($data);

        Session::remove('user_cart');
        echo json_encode(['success' => 'Thank You we Have Recevied Your Payment And Now Processing Your Order']);
      } catch (\Throwable $th) {
        //throw $th;
      }
    }
  }

apart from this, I have to model to for order table and payment table

and here are the model

Order.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Order extends Model
{
  use SoftDeletes;
  public $timestamp = true;
  public $fillable = ['user_id', 'product_id', 'unit_price', 'qunatity', 'total_price', 'status', 'order_no'];
  public $date = ['deleted_at'];
}

and Payment .php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Payment extends Model
{
  use SoftDeletes;
  public $timestamp = true;
  public $fillable = ['user_id', 'amount', 'status', 'order_no'];
  public $date = ['deleted_at'];
}
            	
Sep
11
1 month ago
Activity icon

Awarded Best Reply on Blade Is Not Showing Vue Data

hi guys so I found the answer and the reason I wasn't showing is that I duplicate product classes again so if you look at my home.blade.php code you will see the I

<section class="products">
//code 

</section>
and also
<section class="products  mt-5 mb-5">
//code 

</section> 

what I actually need to do is create one section with an id of root and paste the other two section in like this


<section id='root'>
<section class="products">
//code 

</section>
and also
<section class="products  mt-5 mb-5">
//code 

</section> 

</section>

and don't forget to change your id in vue

var app = new Vue({

            el: '#root',

// rest of the code

Activity icon

Replied to Blade Is Not Showing Vue Data

hi guys so I found the answer and the reason I wasn't showing is that I duplicate product classes again so if you look at my home.blade.php code you will see the I

<section class="products">
//code 

</section>
and also
<section class="products  mt-5 mb-5">
//code 

</section> 

what I actually need to do is create one section with an id of root and paste the other two section in like this


<section id='root'>
<section class="products">
//code 

</section>
and also
<section class="products  mt-5 mb-5">
//code 

</section> 

</section>

and don't forget to change your id in vue

var app = new Vue({

            el: '#root',

// rest of the code

Activity icon

Started a new Conversation Blade Is Not Showing Vue Data

Hi i am trying to display the product form database using Vue i get the response in the console.log but does not show part and the data here is the index.js code

  var app = new Vue({

            el: '.products',
            data: {
                featured: [],
                products: [],
                loading: false
            },
            methods: {
                getFeatureProduct: function() {
                    this.loading = true;
                    axios.all([
                        axios.get('/featured'), axios.get('/all-product')
                    ]).then(axios.spread(function(featuredResponse, productsResponse) {
                        app.featured = featuredResponse.data.featured;
                        app.products = productsResponse.data.products;
                        console.log(productsResponse.data.products)
                        app.loading = false;
                    }));

                },
                stringLimit: function(string, value) {
                    if (string.length > value) {
                        return string.substring(0, value) + '....'
                    } else {
                        return string
                    }
                }
            },
            created: function() {
                this.getFeatureProduct();

            }
        })

here is my controller code

 public function featureproduct()
  {
    $featured = Product::where('feature', 1)->inRandomOrder()->limit(4)->get();
    echo json_encode(['featured' => $featured]);
  }

  public function allproduct()
  {
    $products = Product::where('feature', 0)->skip(0)->take(8)->get();
    echo json_encode(['products' => $products]);
  }

and here is my home.blade.php code


<section class="products">
    <div class="title">
      <div class="firsthalf">
        <hr>
      </div>
      <div>
        <h2>Our Feature Product</h2>
      </div>
      <div class="lasthalf">
        <hr>
      </div>
    </div>
    <div class="container">
      <div class="row">
        <div class="col-md-6 col-lg-3 col-sm-12" v-for='feature in featured'>
          <a :href="'/product/'+feature.id">
            <div class="card" style="width: 18rem;">
              <img :src="'/'+feature.image" class="card-img-top" alt="...">
              <div class="card-body">
                <h5 class="card-title">@{{ stringLimit(feature . name, 18) }}</h5>
                <a :href="'/product/'+feature.id" class="btn btn-block btn-outline-info more">More</a>
                <a :href="'/product/'+feature.id" class="btn btn-block cart btn-success">Rs: @{{ feature . price }} - Add
                  To
                  Cart</a>
              </div>
            </div>
          </a>
        </div>
      </div>
    </div>
  </section>

  <section class="products mt-5 mb-5">
    <div class="title">
      <div class="firsthalf">
        <hr>
      </div>
      <div>
        <h2>Our Product</h2>
      </div>
      <div class="lasthalf">
        <hr>
      </div>
    </div>
    <div class="container">
      <div class="row">
        <div class="col-md-6 col-lg-3 col-sm-12" v-for='product in products'>
          <a :href="'/product/'+product.id">
            <div class="card" style="width: 18rem;">
              <img :src="'/'+product.image" class="card-img-top" alt="...">
              <div class="card-body">
                <h5 class="card-title">@{{ stringLimit(product . name, 18) }}</h5>
                <a :href="'/product/'+product.id" class="btn btn-block btn-outline-info more">More</a>
                <a :href="'/product/'+product.id" class="btn btn-block cart btn-success">Rs: @{{ product . price }} - Add
                  To
                  Cart</a>
              </div>
            </div>
          </a>
        </div>
      </div>
    </div>
  </section>

it shows only The feature product but does not show all the product

Sep
10
1 month ago
Activity icon

Replied to Animation To Happen When The Slide Changes

@sinnbeck

h1 {
                animation: fadeIn 2s ease-in-out;
                -webkit-animation: fadeIn 2s ease-in-out;
            }


@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

this is just a simple fade in animation I want to text to fade in on the slide when the slide changes i want the animation to happen

Activity icon

Started a new Conversation Animation To Happen When The Slide Changes

hey, guys, anyone knows to create a CSS animation on a slider the happen when the slider changes I create one but I only happen once I want the animation to happen when the slide changes every time the new slide comes the animation should happen over and over

Sep
07
1 month ago
Activity icon

Replied to Check For Duplicate When Updating Database

@michaloravec this is the oop course i am taking next is laravel when take it i will learn it then I did take a look at the doc but I did not make much sense Thanks Anyway

Activity icon

Awarded Best Reply on Check For Duplicate When Updating Database

@michaloravec Thx

I just did manually


	 $duplicate = Product::where('id' , '!=' ,$request->id)->where('name', $request->name)->count();
                if ($duplicate > 0) {
                    exit;
                }else{
		run the code ...
	}

and it works

Activity icon

Replied to Check For Duplicate When Updating Database

@michaloravec Thx

I just did manually


	 $duplicate = Product::where('id' , '!=' ,$request->id)->where('name', $request->name)->count();
                if ($duplicate > 0) {
                    exit;
                }else{
		run the code ...
	}

and it works

Activity icon

Started a new Conversation Check For Duplicate When Updating Database

hey guys I create a product table but I am updating the product and enter a new name then it works but when I enter the name that is in the database Its throws an error so far everything works

but lets I want to update the price and image not the name and when I click on an update I still throw an error instead I should be updated

here is the code

	 $duplicate = Product::where('name', $request->name)->first();
                if ($request->name == $duplicate->name) {
                    exit;
                }else{
		run the code ...
	}

I know my code I wrong but does anyone know how to do this

Sep
03
1 month ago
Activity icon

Replied to Call To Undefined Relationship [category , Subcategory] On Model

sir @sinnbeck i am new to laravel and do not understand what you mean can you clarify a little

Activity icon

Replied to Call To Undefined Relationship [category , Subcategory] On Model

i am calling the relation in a controller

here is the query

$products = Product::where('id', 1)->with(['category , subcategory'])->first();

Activity icon

Started a new Conversation Call To Undefined Relationship [category , Subcategory] On Model

hi I am new to laravel and I get this error when defining a relationship

Call to undefined relationship [category , subcategory] on model [App\Models\Product].


// Product Model code

class Product extends Model
{
    use SoftDeletes;
    public $timestamp = true;
    public $fillable =  ['name','price','quantity','category_id','sub_category_id','description', 'image'];
    public $date= ['deleted_at'];

    public function category()
    {
        return $this->belongsTo('App\Models\Category');
    }
    public function subCategory()
    {
        return $this->belongsTo('App\Models\subCategory');
    }


// category model code

class Category extends Model
{
    use SoftDeletes;
    public $timestamps = true;
    protected $fillable= ['id','name' , 'slug'];
    protected $date= ['deleted_at'];

    public function products()
    {
        return $this->hasMany(Product::class);
    }
    public function subCategories()
    {
        return $this->hasMany(SubCategory::class, 'parent_id');
    }


// subcategory mode code 


class SubCategory extends Model
{
    use SoftDeletes;
    public $timestamps = true;
    protected $fillable= ['id','name' , 'slug' ,'category_name','parent_id'];
    protected $date= ['deleted_at'];

    public function category()
    {
        return $this->belongsTo(Category::class, 'parent_id');
    }

    public function products()
    {
        return $this->hasMany(Product::class);
    }

I have three tables in the database

products

categories

sub_categories

products table have column ( category_id ) and (sub_category_id) for the relation

and

sub-categories have column (parent_id) for the relation

Aug
08
2 months ago
Activity icon

Replied to Js File Get Complie But No Working

window.$ = window.JQuery = require('jquery');

window.Vue = require = ('vue');

require('foundation-sites/dist/js/foundation.min');

require('slick-carousel/slick/slick.min');

require('../js/init');

Activity icon

Started a new Conversation Js File Get Complie But No Working

Hi I am using laravel mix to compile my sass and js the Scss work fine but js get to compile and do not work here is my webpack file code

let mix = require('laravel-mix');

mix.setPublicPath('public');

mix.sass('resources/assets/sass/app.scss', 'public/css/main.css');

mix.js('resources/assets/js/app.js', 'public/js/main.js');

and here is my app.js

window.$ = window.JQuery = require('jquery');

window.Vue = require = ('vue');

require('foundation-sites/dist/js/foundation.min');

require('slick-carousel/slick/slick.min');

require('../js/init');

and the only scenario I work is if I remove the Vue js Line Of Code