asadsajjad

asadsajjad

Member Since 4 Years Ago

Experience Points
710
Total
Experience

4,290 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
0
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
710 XP
Jun
28
1 month ago
Activity icon

Awarded Best Reply on Checkbox Value In Controller In Laravel

this is the updated code as but now this is not taking all values and passing to the database to update. The code seems to be fine. Am I doing something wrong in the view file?

@snapey @jlrdw

Controller

 $commissionValue = Input::get('commission');

            $checked = $request->input('checked');
     
        foreach($checked as $c) {

            $findPaymentId = Payment::where('id', '=', $c)->get();

            // echo $findPaymentId->commission_value;
            // die();

            foreach($findPaymentId as $f) {
                if($f->commission_value == $commissionValue) {
                    $updateStatus = Payment::where('id', $f->id)->update([
                            
                        // 'status' => '1',
                        'sellet_commission_paid' => '1',
                        
                    
                    ]);


    
                } elseif($findPaymentId->agent_commission == $commissionValue) {
                    $updateStatus = Payment::where('id', $id)->update([
                                
                        // 'status' => '1',
                        'agent_commission_paid' => '1',
                    
                    ]);


                    
                }
             
            }

                    Session::flash("message", "You confirmed that you have received the commission.");
                    return redirect()->back();
        }

View

          @if(count($sellerID)>0)
                            <form action="/paid" method="post" enctype="multipart/form-data">

                                @foreach($sellerID as $p)
                                    <tr>
                                            @csrf
                                            <td><input type="checkbox" name="checked[]" value="{{ $p->id }}"></td>
                                            <td> {{ $p->order_number }} </td>
                                            <td>
                                                <input id="commission" type="text" class="form-control" name="commission"
                                                                value="{{ $p->commission_value }}" readonly  autocomplete="notes" style="width: 15%;" autofocus>
                                            </td>
                                        
                                            <td> {{$p->product_name}} </td>
                                            <td> 
                                                @if($p->sellet_commission_paid == '0')
                                                    <button type="submit" class="btn btn-default" style="background-color:red">
                                                        <b><em>UNPAID</b></em>
                                                    </button>
                                                @else
                                                    <a href="#" class="btn btn-default" style="background-color:green"><b><em>PAID</b></em></a>
                                                @endif                                    
                                            <td>   
                                    
                                    </tr>
                                @endforeach
                            </form>

                        </tbody>  
                        @endif
Activity icon

Replied to Checkbox Value In Controller In Laravel

return redirect()->back(); this is more appropriate way of doing it. This worked for me. Thanks though

Thank you everyone @snapey @jlrdw @meeshal

Activity icon

Replied to Checkbox Value In Controller In Laravel

@meeshal thank you for your answer but what if none is selected and redirect on the same page on null values?

Activity icon

Replied to Checkbox Value In Controller In Laravel

@snapey I did changed that to get and it got fixed. I think its their server issue which is delaying the messages from both ends

Activity icon

Replied to Checkbox Value In Controller In Laravel

it got fixed @snapey and @jlrdw. I was returning it to the page before the loop processes all of the inputs. Thank you for your messages and help. I really appreciate it.

Now the only problem that is left is that when I update seller payment it should redirect back to seller payment page but because of this foreach loop I cant seem that to be possible

Activity icon

Replied to Checkbox Value In Controller In Laravel

@snapey sorry about it. Those error already got fixed with your suggestion on taking the form out of the foreach loop. But now on controller I have checked everything it is passing every value but when I click on PAY it just update one row

Activity icon

Replied to Checkbox Value In Controller In Laravel

@jlrdw I am just trying to update the rows based on the checkboxes checked by the user.

Activity icon

Replied to Checkbox Value In Controller In Laravel

how can I share an image here may that'll be for you to understand my problem?

Activity icon

Replied to Checkbox Value In Controller In Laravel

this is the updated code as but now this is not taking all values and passing to the database to update. The code seems to be fine. Am I doing something wrong in the view file?

@snapey @jlrdw

Controller

 $commissionValue = Input::get('commission');

            $checked = $request->input('checked');
     
        foreach($checked as $c) {

            $findPaymentId = Payment::where('id', '=', $c)->get();

            // echo $findPaymentId->commission_value;
            // die();

            foreach($findPaymentId as $f) {
                if($f->commission_value == $commissionValue) {
                    $updateStatus = Payment::where('id', $f->id)->update([
                            
                        // 'status' => '1',
                        'sellet_commission_paid' => '1',
                        
                    
                    ]);


    
                } elseif($findPaymentId->agent_commission == $commissionValue) {
                    $updateStatus = Payment::where('id', $id)->update([
                                
                        // 'status' => '1',
                        'agent_commission_paid' => '1',
                    
                    ]);


                    
                }
             
            }

                    Session::flash("message", "You confirmed that you have received the commission.");
                    return redirect()->back();
        }

View

          @if(count($sellerID)>0)
                            <form action="/paid" method="post" enctype="multipart/form-data">

                                @foreach($sellerID as $p)
                                    <tr>
                                            @csrf
                                            <td><input type="checkbox" name="checked[]" value="{{ $p->id }}"></td>
                                            <td> {{ $p->order_number }} </td>
                                            <td>
                                                <input id="commission" type="text" class="form-control" name="commission"
                                                                value="{{ $p->commission_value }}" readonly  autocomplete="notes" style="width: 15%;" autofocus>
                                            </td>
                                        
                                            <td> {{$p->product_name}} </td>
                                            <td> 
                                                @if($p->sellet_commission_paid == '0')
                                                    <button type="submit" class="btn btn-default" style="background-color:red">
                                                        <b><em>UNPAID</b></em>
                                                    </button>
                                                @else
                                                    <a href="#" class="btn btn-default" style="background-color:green"><b><em>PAID</b></em></a>
                                                @endif                                    
                                            <td>   
                                    
                                    </tr>
                                @endforeach
                            </form>

                        </tbody>  
                        @endif
Activity icon

Replied to Checkbox Value In Controller In Laravel

yes @jlrdw I am trying to update the selected payments to PAID. I have updated my code with the help of @snapey but now its not updating all of it. Below is my updated code

View

                      @if(count($sellerID)>0)
                            <form action="/paid" method="post" enctype="multipart/form-data">

                                @foreach($sellerID as $p)
                                    <tr>
                                            @csrf
                                            <td><input type="checkbox" name="checked[]" value="{{ $p->id }}"></td>
                                            <td> {{ $p->order_number }}
                                            <td>
                                                <input id="commission" type="text" class="form-control" name="commission"
                                                                value="{{ $p->commission_value }}" readonly  autocomplete="notes" style="width: 15%;" autofocus>
                                            </td>
                                        
                                            <td> {{$p->product_name}} </td>
                                            <td> 
                                                @if($p->sellet_commission_paid == '0')
                                                    <button type="submit" class="btn btn-default" style="background-color:red">
                                                        <b><em>UNPAID</b></em>
                                                    </button>
                                                @else
                                                    <a href="#" class="btn btn-default" style="background-color:green"><b><em>PAID</b></em></a>
                                                @endif                                    
                                            <td>   
                                    
                                    </tr>
                                @endforeach
                            </form>
                            </tbody>  
                        @endif

Controller

              // $findPaymentId = Payment::find($id);
            
            $commissionValue = Input::get('commission');

            $checked = $request->input('checked');
     
        foreach($checked as $c) {

            $findPaymentId = Payment::where('id', '=', $c)->first();

            // echo $findPaymentId->commission_value;
            // die();

            if($findPaymentId->commission_value == $commissionValue) {
                $updateStatus = Payment::where('id', $c)->update([
                            
                    // 'status' => '1',
                    'sellet_commission_paid' => '1',
                    
                
                ]);

                Session::flash("message", "You confirmed that you have received the commission.");
                return redirect('/seller-payments');
       }
Activity icon

Replied to Checkbox Value In Controller In Laravel

I got it but I tried to move the form tag outside the foreach loop and then it gives error on id Property [id] does not exist on this collection instance

Activity icon

Replied to Checkbox Value In Controller In Laravel

@snapey I am only getting one item from the checkbox in the array not all what are selected. I tried what you suggested but its still the same

Activity icon

Started a new Conversation Checkbox Value In Controller In Laravel

I am trying to get all the payments that is been selected through the checkboxes and then update the value in the database by '1' which means its paid. But when I try to get the values of checkbox array I only get 1 data in the array and not all selected. Any help?

View

@foreach($sellerID as $p)
     <form action="/paid/{{$p->id}}" method="post" enctype="multipart/form-data">   
         @csrf
 <td><input type="checkbox" name="checked[]" value="{{ $p->id }}"></td>
 <td> {{$p->order_number}} </td>
 <td>
     <input id="commission" type="text" class="form-control" name="commission" 
     value="{{ $p->commission_value }}" readonly  autocomplete="notes" style="width: 15%;" autofocus>
 </td>
                                    
 <td> {{$p->product_name}} </td>
 <td> 
     @if($p->sellet_commission_paid == '0')
        <button type="submit" class="btn btn-default" style="background-color:red">
            <b><em>UNPAID</b></em>
        </button>
     @else
        <a href="#" class="btn btn-default" style="background-color:green"><b><em>PAID</b></em></a>
     @endif                                    
 <td>   
  </form>
   @endforeach

Controller

 $checked = $request->input('checked');
 //   $checkboxes = $request->checked;

 dd($checked);
 die();
//    dd(che
Apr
03
4 months ago
Activity icon

Replied to Getting Array Index To Delete

@frankincredible I want it done dynamically so the index you chose I am not getting that in my code

Activity icon

Replied to Getting Array Index To Delete

@frankincredible I want to delete a whole index from an array so lets say I have an array

array[] = {'a.jpg', 'b.jpg', 'c.jpg'} 

so now from this array I want to delete b.jpg which is index 1 in this case. I am trying to delete the whole index from an array based on user selection.

Activity icon

Started a new Conversation Getting Array Index To Delete

I am trying to get the index from the array but cant get it loaded. Below is my controller. I want to delete the index from the array. Any help ?

@foreach (json_decode($p->filename) as $picture)
        <ul>
               <a href="/delete-product-image-name/{{$p->id}}?index={{ $loop->index }}">Delete</a>
    @endforeach

public function deleteProductImageName($id, Request $request) {

if(Auth::check()) {

        $products = Product::where('id', $id)->first();

        $index = $request->query('index'); // getting the index
        echo $index;

        foreach($products as $p) {
            if(($products->user_id == Auth::user()->id) && ($products->id == $id)) {
                $findProductImageName = Product::where('user_id', Auth::user()->id)
                                        ->where('id', $id)->first();

                // echo $findProductImageName ;
                $filename_index = $findProductImageName ->filename;
                
                echo $filename_index; '<br/>'; // getting the index here
                echo $filename_index[$index]; // not getting index loaded in here

                // array_splice($filename_index);
                // echo array_splice($filename_index);

                // echo $filename_index;
                    // $request->forget($product->filename[$index]);
                //     dd($filename_index->delete());
                die();
                }
                
                Session::flash("message", "Your item has been deleted.");
                return redirect()->action('[email protected]', ['id' => Auth::check()]);
        //     }  else {
        //         Session::flash("message", "You dont have permission to update this product.");
        //         return redirect()->action('[email protected]', ['id' => Auth::user()->id]);
        }
    } else {
        Session::flash("message", "OOPS! You dont have permission to delete the items. Please login first.");
        return redirect("/register-user");

    }
}

UPDATED

Apr
02
4 months ago
Activity icon

Started a new Conversation Undefined Variable: Data And Limit Uploading Items To Max 3

  1. I am trying to update the product and for that I am updating the pictures. I meant if user want to add more pictures to it but when I do this I get below error

Undefined variable: data

  1. Also I want to restrict the total uploading pictures to max 3 pictures or 2 pictures and 1 video
  2. When I add a video it does not show like it does not play

Any help would be great. Thank for the help in advance

public function editProduct($id, Request $request) {
    if(Auth::check()) {

        $pn = Input::get('pn');
        $desc = Input::get('desc');
        $price = Input::get('price');

        // $products = Product::all();

        $products = Product::where('id', $id)->first();

        // foreach($products as $p) {
        if(($products->user_id == Auth::user()->id) && ($products->id == $id)) {

            $this->validate($request, [
    
                'filename.*' => 'required|max:5000',
                // 'filename.*' => 'image|mimes:jpeg,png,jpg,mp4|max:5000'

        ]);
        
        if($request->hasfile('filename'))
        {
            foreach($request->file('filename') as $image)
            {
                $name = $image->getClientOriginalName();
               
                $filename = time(). '-' . $image;
                $file_path = $image->move(public_path().'/assets/images/', $name);

                $data[] = $name;  

            }
         }

            $new_name = json_encode($data);
            $products = Product::where('user_id', Auth::user()->id)
                                ->where('id', $id)->update([
                                
            'product_name' => $pn,
            'description' => $desc,
            'price' => $price,
            'filename' => $new_name,
        ]);
}
} else {
        Session::flash("message", "OOPS! You dont have permission to edit the items. Please login first.");
        return redirect("/register-user");

    }
Apr
01
4 months ago
Activity icon

Replied to The DELETE Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

you can also do something like

<a href="#" onclick="return confirm('Are you sure you want to delete this item?');"><button></button>
Activity icon

Replied to These Credentials Do Not Match Our Records. (Log In) (Laravel)

@daniel1836 try doing it manual way then. Try this

use Input;
use App\User;

class RegisterController extends Controller
{
	public function create() {
		$username = Input::get('name');
		$email= Input::get('email');
		$password= Input::get('password');

		$encrypted_password = bcrypt($password);

		$users = new User();
		$users->username = $username;
		$users->email = $email;
		$users->password = $encrypted_password;

		$users->save()
	}
	
}
Activity icon

Awarded Best Reply on Data Is Not Displaying On Heroku But On Localhost

@bobbybouwmann yes it does. I got it fixed as this condition if($findLikes->likes == '1') was returning null for some new records so fixed that part and all's good now

Activity icon

Replied to Data Is Not Displaying On Heroku But On Localhost

@bobbybouwmann yes it does. I got it fixed as this condition if($findLikes->likes == '1') was returning null for some new records so fixed that part and all's good now

Activity icon

Awarded Best Reply on Trying To Get Property 'likes' Of Non-object (View: /app/resources/views/products/productView.blade.php)

fixed it. The error was in the view as it was not taking the value from following table. Thanks everyone.

Activity icon

Replied to Trying To Get Property 'likes' Of Non-object (View: /app/resources/views/products/productView.blade.php)

fixed it. The error was in the view as it was not taking the value from following table. Thanks everyone.

Activity icon

Replied to These Credentials Do Not Match Our Records. (Log In) (Laravel)

try this

protected function create(array $data) { 
return User::create([ 
	'name' => $data['name'], 
	'email' => $data['email'], 
	'password' => bcrypt($data['password']),
]); 
}
Activity icon

Replied to These Credentials Do Not Match Our Records. (Log In) (Laravel)

try echoing the username and password and see if its getting both inputs or not

Do below in your controller and see if its getting username and password same as your database (if you are using hashing then comment that part to check the password match)

echo $username; echo $password; die;

Mar
31
4 months ago
Activity icon

Started a new Conversation Data Is Not Displaying On Heroku But On Localhost

I have been guided by one of the people here and I did make the change to it and now I am not getting anything displayed as the value is null on the heroku server. Any help would be greatly appreciated. Thank you in advance

link to previous post: https://laracasts.com/discuss/channels/laravel/trying-to-get-property-likes-of-non-object-view-appresourcesviewsproductsproductviewbladephp

Query $findLikes = Comment::where('user_id', Auth::user()->id)->where('product_id', $id)->first();

View

@if((Auth::check()) && $findLike)

	`@if ($findLikes->likes == '1') `
            	 `<a href="/unlike-product/{{$p->id}}" id="myNumber" name="likes" value="0" onclick="myFunction()"><i class="fa fa-heart-o"></i> UnLike</a> </small>`

    	`@elseif($findLikes->likes == '0')`
            	 `<a href="/liked-product/{{$p->id}}" id="myNumber" name="likes" value="1" onclick="myFunction()"><i class="fa fa-heart-o"></i> Like it</a> </small>`
     	`@endif`
`@endif`
Activity icon

Replied to Trying To Get Property 'likes' Of Non-object (View: /app/resources/views/products/productView.blade.php)

@tykus I tried that now its not displaying anything. Is it because of the NULL passing ?

Activity icon

Started a new Conversation Trying To Get Property 'likes' Of Non-object (View: /app/resources/views/products/productView.blade.php)

on my local server this is working and on hosting it is giving error. I dont know where I am doing this wrong

Trying to get property 'likes' of non-object (View: /app/resources/views/products/productView.blade.php)

Query $findLikes = Comment::where('user_id', Auth::user()->id)->where('product_id', $id)->first();

View @if((Auth::check()) && ($findLikes->likes == '1'))

<a href="/unlike-product/{{$p->id}}" id="myNumber" name="likes" value="0" onclick="myFunction()"><i class="fa fa-heart-o"></i> UnLike</a> </small>

@elseif((Auth::check()) && ($findLikes->likes == '0'))

<a href="/liked-product/{{$p->id}}" id="myNumber" name="likes" value="1" onclick="myFunction()"><i class="fa fa-heart-o"></i> Like it</a> </small>

@endif

Any help would be great

Activity icon

Awarded Best Reply on Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

yes I did. It got fixed. It was taking 0 as a value for follow users. Fixed that.

Activity icon

Replied to Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

yes I did. It got fixed. It was taking 0 as a value for follow users. Fixed that.

Mar
30
4 months ago
Activity icon

Started a new Conversation Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

Trying to access array offset on value of type null (View: /app/resources/views/products/productView.blade.php) can anyone help me with this error? my project is working fine on local server but when I push to heroku it gives me the below error. Any help ?

I am using php version 7.3.7 and laravel version 6.18.3 Also I am using heroku to host my project

http://catalogworks.herokuapp.com/

Trying to access array offset on value of type null (View: /app/resources/views/products/productView.blade.php)

Activity icon

Replied to Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

@tykus I am still getting the same error.

You can click any of the items from the link below and check I am getting the same error but you wont get any error if you click on 3rd item from the list unless until you like or comment on it

http://catalogworks.herokuapp.com/

Activity icon

Replied to Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

This is the controller for like, unlike and comment

public function likedProduct($id) {

    if(Auth::check()) {

        $product = Product::where('id', $id)->first();

        $userLikes = new Comment();
        $userLikes->user_id = Auth::user()->id;
        $userLikes->product_id = $product->id;
        $userLikes->likes = '1';

        $userLikes->save();

        if($product->total_likes == 0) {
            $product->total_likes = 1;
        } else {
            $product->total_likes = $product->total_likes + 1;
        }

        $product->save();
        return redirect()->action('[email protected]', ['id' => $id]);
    } else {
        Session::flash("message", "OOPS! You dont have permission to upload the items. Please register first.");
        return redirect("/register-user");
    }
}

public function unlikeProduct($id) {

    if(Auth::check()) {
        $comments = Comment::where('user_id', Auth::user()->id)
                                ->where('product_id', $id)->delete();

        
        $product = Product::where('id', $id)->get('total_likes')->count();
        
        // echo $product;
        // die();
       
        if($product>0) {
            $productLikes = Product::where('id', $id)->first();
            $productLikes->total_likes = $productLikes->total_likes - 1;
            $productLikes->save();
        }
        
        // Session::flash("message", "OOPS! You dont have permission to upload the items. Please register first.");
        return redirect()->action('[email protected]', ['id' => $id]);
    } else {
        Session::flash("message", "OOPS! You dont have permission to upload the items. Please register first.");
        return redirect("/register-user");
    }
    

}
public function productComment($id) {
    if(Auth::check()) {

        $c = Input::get('comment');

        $product = Product::where('id', $id)->first();

        $user_comments = new Comment();
        $user_comments->user_id = Auth::user()->id;
        $user_comments->product_id = $product->id;
        $user_comments->comments = $c;

        $user_comments->save();

        if($product->total_comments == 0) {
            $product->total_comments = 1;
        } else {
            $product->total_comments = $product->total_comments + 1;
        }

        $product->save();
        
        Session::flash('message', 'Your comment has been added successfully');
        return redirect()->action('[email protected]', ['id' => $id]);
       

    }  else {
        Session::flash("message", "OOPS! You dont have permission to upload the items. Please register first.");
        return redirect("/register-user");
    }     
}
Activity icon

Replied to Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

This is the whole code for productView

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<!-- SITE META -->
<title>Catalog | Responsive Marketplace Showcase Template</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="keywords" content="">

<!-- FAVICONS -->
<link rel="shortcut icon" href="{{asset('assets/images/favicon.ico')}}" type="image/x-icon">
<link rel="apple-touch-icon" href="{{asset('assets/images/apple-touch-icon.png')}}">
<link rel="apple-touch-icon" sizes="57x57" href="{{asset('assets/images/apple-touch-icon-57x57.png')}}">
<link rel="apple-touch-icon" sizes="72x72" href="{{asset('assets/images/apple-touch-icon-72x72.png')}}">
<link rel="apple-touch-icon" sizes="76x76" href="{{asset('assets/images/apple-touch-icon-76x76.png')}}">
<link rel="apple-touch-icon" sizes="114x114" href="{{asset('assets/images/apple-touch-icon-114x114.png')}}">
<link rel="apple-touch-icon" sizes="120x120" href="{{asset('assets/images/apple-touch-icon-120x120.png')}}">
<link rel="apple-touch-icon" sizes="144x144" href="{{asset('assets/images/apple-touch-icon-144x144.png')}}">
<link rel="apple-touch-icon" sizes="152x152" href="{{asset('assets/images/apple-touch-icon-152x152.png')}}">

<!-- TEMPLATE STYLES -->
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/font-awesome.min.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/bootstrap.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/style.css')}}">

<!-- CUSTOM STYLES -->
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/prettyPhoto.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/animate.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/responsive.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/custom.css')}}">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- START SITE -->
<div id="wrapper">
    <header class="header">
        <div class="container-menu">
            <nav class="navbar navbar-default yamm">
                <div class="container">
                    <div class="navbar-table">
                        <div class="navbar-cell">
                            <div class="navbar-header">
                                <a class="navbar-brand" href="/"><i class="fa fa-hashtag"></i> Catalog</a>
                                <div class="open-menu">
                                </div>
                            </div><!-- end navbar-header -->
                        </div><!-- end navbar-cell -->
                        <div class="navbar-cell stretch">
                            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                                <div class="navbar-cell">
                                    <ul class="nav navbar-nav navbar-center">
                                        <li><a class="active" href="/" title="">Home</a></li>
                                        <li class="dropdown megamenu yamm-half hovermenu"><a href="#" data-toggle="dropdown" class="dropdown-toggle">Categories <b class="fa fa-angle-down"></b></a>
                                            <ul class="dropdown-menu">
                                                <li>
                                                    @foreach($category as $c)
                                                        <div class="col-md-4 col-sm-6">
                                                            <div class="box">
                                                                <ul>  
                                                                    <li><a href="/show-category/{{$c->category_name}}">{{$c->category_name}}</a></li>
                                                                </ul>
                                                            </div><!-- end box -->
                                                        </div><!-- end col -->
                                                    @endforeach     
                                                </li>
                                            </ul>
                                        </li><!-- end mega menu -->
                                        
                                        @if(Auth::check())
                                        <li><a href="/contact" title="">Contact</a></li>
                                        <li><a href="/add-new-product" title="">Upload Item</a></li>
                                        @else
                                        <li><a href="/contact" title="">Contact</a></li>
                                        <li><a href="/add-new-product" title="">Upload Item</a></li>
                                        <li><a href="/register-user" title="">Login/Register</a></li>
                                        @endif
                                    </ul>

                                @if(Auth::check())
                                    <ul class="nav navbar-nav navbar-right">
                                        <li><a href="/show-cart" title="">Cart ({{$carts}})</a></li>
                                    </ul>

                                    <ul class="nav navbar-nav navbar-right">
                                        <li class="dropdown membermenu hovermenu">
                                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img src="upload/member.png" alt="" class="img-circle"> <span class="caret"></span></a>
                                            <ul class="dropdown-menu">
                                                <li class="dropdown-header">Profile</li>
                                                <li><a href="/edit-profile/{{Auth::user()->id}}">Edit Account</a></li>
                                                <li>
                                                <a class="dropdown-item" href="{{ route('logout') }}"
                                                    onclick="event.preventDefault();
                                                                    document.getElementById('logout-form').submit();">
                                                    {{ __('Logout') }}
                                                </a>

                                                <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                                    @csrf
                                                </form>
                                                </li>
                                                
                                                <li><hr></li>
                                                <li class="dropdown-header">Dashboard</li>
                                                <li><a href="/user-profile/{{Auth::user()->id}}">Public profile</a></li>
                                                <li><a href="/add-new-product">Upload Item</a></li>
                                            </ul>
                                        </li>
                                    </ul>
                                    @else 
                                        <ul class="nav navbar-nav navbar-right">
                                            <li><a href="/show-cart" title="">Cart (0)</a></li>
                                        </ul>
                                    @endif
                                    
                                    </ul>
                                </div><!-- end navbar-cell -->
                            </div><!-- /.navbar-collapse -->        
                        </div><!-- end navbar cell -->
                    </div><!-- end navbar-table -->
                </div><!-- end container fluid -->
            </nav><!-- end navbar -->
        </div><!-- end container -->
    </header>

    <center>
        @if(Session::has('message'))
            <div class="alert alert-success"><span class="glyphicon glyphicon"></span><em> "{!! session('message') !!}"</em></div>
        @endif
    </center>

    @foreach($products as $p)
    <section class="section single-wrap">
        <div class="container">
            <div class="page-title">
                <div class="row">
                    <div class="col-sx-12 text-center">
                    
                        <h3>{{$p->product_name}}</h3>
                    
                    </div>
                </div>
            </div>

            <div class="content-top">
                <div class="row">
                    <div class="col-sx-6 col-sm-6">
                        
                    </div> 

                    <div class="col-sm-6 col-xs-12 cen-xs text-right">
                        <div class="bread">
                            <ol class="breadcrumb">
                              <li><a href="/">Home</a></li>
                              <li><a href="#">Shop</a></li>
                              <li class="active">{{$p->product_name}}</li>
                            </ol>
                        </div>
                    </div>
                </div><!-- end row -->
            </div><!-- end content top -->
            
            <div class="row">
                <div id="singlewrapper" class="col-md-8">
                    <div class="content nopad">
                        <div class="item-single-wrapper">
                            <div class="item-box">
                                <div class="item-media text-center">
                                    <div id="slider" class="flexslider clearfix">
                                        
                                        <ul class="slides">
                                            <li><img src="{{ asset('assets/images/'.array_first(json_decode($p->filename))) }}"style="width:700px; height:400px;" alt="" class="img-responsive"></li>
                                        </ul>
                                        
                                    </div>
                                    <div id="carousel" class="flexslider clearfix">
                                        <ul class="slides">
                                            <li>
                                                @foreach (json_decode($p->filename) as $picture)
                                                    <img src="{{ asset('assets/images/'.$picture) }}" style="height:120px; width:200px"/>       
                                                @endforeach
                                            </li>
                                        </ul>
                                    </div>  
                                </div><!-- end item-media -->

                                <div class="item-desc">
                                    <b>Description</b>
                                    <p> {{$p->description}} </p>
                                </div><!-- end item-desc -->

                                <center>
                                    <p>__________</p>
                                </center>

                                <div class="item-desc">
                                <b>Comments</b>
                                    @foreach($comments as $c)
                                        <p> {{$c->comments}} </p>
                                        {{$c->users['username']}}
                                        <h6> by <b>{{$c->user['username']}}</b> at <b>{{$c->created_at}}</b> </h6>  <br/>
                                    @endforeach
                                </div><!-- end item-desc -->
                               
                            </div><!-- end item-box -->

                            
                        </div><!-- end item-single-wrapper -->
                    </div><!-- end content -->
                </div><!-- end singlewrapper -->

                <div id="sidebar" class="col-md-4">
                    <div class="boxes boxs">
                        <div class="item-price text-center">
                            <p>${{$p->price}}</p>
                            <em><a href="#">Regular License</a></em>
                            <!-- <div class="rating">
                                <i class="fa fa-star"></i>
                                <i class="fa fa-star"></i>
                                <i class="fa fa-star"></i>
                                <i class="fa fa-star"></i>
                                <i class="fa fa-star"></i>
                            </div> -->
                            <hr>
                            <small> 
                            @if((Auth::check()) && ($findLikes == true))
                                <a href="/unlike-product/{{$p->id}}" id="myNumber" name="likes" value="0" onclick="myFunction()"><i class="fa fa-heart-o"></i> UnLike</a> </small>
                            @else
                                <a href="/liked-product/{{$p->id}}" id="myNumber" name="likes" value="1" onclick="myFunction()"><i class="fa fa-heart-o"></i> Like it</a> </small>
                            @endif
                            <hr>
                            <a href="/add-to-cart/{{$p->id}}" class="btn btn-primary">Add to Cart</a>
                            
                            <button type="button" data-toggle="modal" data-target="#myModal">Comment</button></a>

                            <!-- Modal -->
                            <div class="modal fade" id="myModal" role="dialog">
                                <div class="modal-dialog">
                                
                                <!-- Modal content-->
                                <div class="modal-content">
                                    <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    <h4 class="modal-title">Add your comments here <span class="fa fa-comment"></span></h4>
                                    </div>
                                    <div class="modal-body">
                                        <div class="login-form">
                                            <form method="post" action="/product-comment/{{$p->id}}">

                                            @csrf
                                                <div class="form-group">
                                                    <input type="text" name="comment" required class="form-control" placeholder="comment here" />
                                                </div>
                                                
                                                <button type="submit" name="go" class="btn btn-primary">Add Comment</button>
                                            </form>
                                        </div><!-- end login-form -->
                                    </div>
                                    <!-- <div class="modal-footer">
                                    <a href=""></a>
                                        <button type="button" class="btn btn-default" data-dismiss="modal">Add Comment</button>
                                 </div> -->
                                </div>
                                
                            </div>
                        </div>

                            <ul class="list-inline social">
                                <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                                <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                                <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                                <li><a href="#"><i class="fa fa-dribbble"></i></a></li>
                                <li><a href="#"><i class="fa fa-behance"></i></a></li>
                                <li><a href="#"><i class="fa fa-pinterest"></i></a></li>
                            </ul>
                        </div><!-- end price -->
                    </div><!-- end boxes -->

                    <div class="boxes boxs">
                        <div class="desiger-details text-center">
                            <img src="upload/member_05.jpg" class="img-circle" alt=""></a>
                            <h4><a href="public-profile.html">{{$p->username}}</a></h4>
                            <small><a href="/follow-user/{{$p->user_id}}"><i class="fa fa-user-plus">
                            @if((Auth::check()) && ($findFollow == true))
                                </i> Unfollow</a> </small>
                            @else
                                </i> Follow {{$p->username}}</a> </small>
                            @endif
                        </div><!-- end designer -->
                    </div><!-- end boxes -->

                    <div class="boxes boxs">
                        <div class="item-details">
                            <table>
                                <tr>
                                    <td>Created on:</td>
                                    <td>{{$p->created_at}}</td>
                                </tr>

                                <tr>
                                    <td>Category</td>
                                    <td>{{$p->category['category_name']}}</td>
                                    {{$p->categoryList}}
                                </tr>

                                <tr>
                                    <td>Followers:</td>
                                    <td>{{$p->user->followers}}</td>
                                </tr>

                                <tr>
                                    <td>Likes:</td>
                                    <td>{{$p->total_likes}}</td>
                                </tr>

                                <tr>
                                    <td>Comments:</td>
                                    <td>{{$p->total_comments}}</td>
                                </tr>
                                

                            </table>
                        </div><!-- end item-details -->
                    </div><!-- end boxes -->
                </div><!-- end sidebar -->
            </div><!-- end row -->
        </div><!-- end container -->
    </section>

    @endforeach
    
    <footer class="footer">
        <div class="container">
            <div class="row">
                <div class="col-md-6 col-lg-5">
                    <div class="media cen-xs">
                        <p>
                            &copy; Catalog INC. 2016 - All Rights Reserverd.<br>
                            Idea by <a class="madeby" href="http://showwp.com">Show WP</a> made with <i class="fa fa-heart"></i> coded with <i class="fa fa-html5"></i>
                        </p>
                    </div>
                </div>
                <div class="col-md-6 col-lg-7">
                    <ul class="list-inline text-right cen-xs">
                        <li><a href="#">Home</a></li>
                        <li><a href="#">Site Terms</a></li>
                        <li><a href="#">Copyrights</a></li>
                        <li><a href="#">License</a></li>
                        <li><a href="#">Legal</a></li>
                        <li><a class="topbutton" href="#">Back to top <i class="fa fa-angle-up"></i></a></li>
                    </ul>
                </div>
            </div><!-- end row -->
        </div><!-- end container -->
    </footer><!-- end footer -->
</div><!-- end wrapper -->
<!-- END SITE -->

<script src="{{asset('assets/js/jquery.min.js')}}"></script>
<script src="{{asset('assets/js/bootstrap.js')}}"></script>
<script src="{{asset('assets/js/custom.js')}}"></script>
<!-- FlexSlider JavaScript
================================================== -->
<script src="{{asset('assets/js/flexslider.js')}}"></script>
<script>
    (function($) {
    "use strict";
    $(window).load(function() {
        $('#carousel').flexslider({
            animation: "slide",
            controlNav: false,
            directionNav: false,
            animationLoop: true,
            slideshow: true,
            itemWidth: 92,
            itemMargin: 0,
            asNavFor: '#slider'
        });
   
        $('#slider').flexslider({
            animation: "fade",
            controlNav: false,
            animationLoop: false,
            slideshow: true,
            sync: "#carousel"
        });
    });
    })(jQuery);
</script>
Activity icon

Replied to Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

I feel like this is the relevant code as whenever I perform likes or comments functionality this error occurs

@if((Auth::check()) && ($findLikes == true)) UnLike @else Like it @endif Add to Cart

                            <button type="button" data-toggle="modal" data-target="#myModal">Comment</button></a>

                            <!-- Modal -->
                            <div class="modal fade" id="myModal" role="dialog">
                                <div class="modal-dialog">
                                
                                <!-- Modal content-->
                                <div class="modal-content">
                                    <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    <h4 class="modal-title">Add your comments here <span class="fa fa-comment"></span></h4>
                                    </div>
                                    <div class="modal-body">
                                        <div class="login-form">
                                            <form method="post" action="/product-comment/{{$p->id}}">

                                            @csrf
                                                <div class="form-group">
                                                    <input type="text" name="comment" required class="form-control" placeholder="comment here" />
                                                </div>
                                                
                                                <button type="submit" name="go" class="btn btn-primary">Add Comment</button>
                                            </form>
                                        </div><!-- end login-form -->
                                    </div>
                                    <!-- <div class="modal-footer">
                                    <a href=""></a>
                                        <button type="button" class="btn btn-default" data-dismiss="modal">Add Comment</button>
                                 </div> -->
                                </div>
Activity icon

Started a new Conversation Trying To Access Array Offset On Value Of Type Null (View: /app/resources/views/products/productView.blade.php)

can anyone help me with this error? my project is working fine on local server but when I push to heroku it gives me the below error. Any help ?

I am using php version 7.3.7 and laravel version 6.18.3 Also I am using heroku to host my project

http://catalogworks.herokuapp.com/

Trying to access array offset on value of type null (View: /app/resources/views/products/productView.blade.php)