anilkumarthakur60

anilkumarthakur60

Member Since 1 Month Ago

Experience Points
1,050
Total
Experience

3,950 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
1,050 XP
Oct
20
1 week ago
Activity icon

Replied to Integrity Constraint Violation: 1048 Column 'user_id' Cannot Be Null

add user_id to fillable property to your model,

Activity icon

Replied to I Want To Update Specific Column Data

here is my migration table

Schema::create('banners', function (Blueprint $table) {
            $table->id();
            $table->string('image');
            $table->string('title');
            $table->text('content');
            $table->timestamp('published_at');
            $table->enum('status',['active','deactive'])->default('deactive');
            $table->timestamps();
        });
Oct
18
1 week ago
Activity icon

Started a new Conversation I Want To Update Specific Column Data

i have update controller for whole row ...next one is i want to update specific column data help me please

here is my index.blade.php file

 @foreach ($banners as $banner) 
                        <tr>
                          <td>{{$banner->id}}</td>
                          <td>{{$banner->title}}</td>
                          <td>{{$banner->content}}</td>
                          <td> <img src="{{asset('/storage/'.$banner->image)}}" alt="" height="100px"></td>
                            <td>{{$banner->published_at}}</td>


                              @if ($banner->status=="active")
                              <td>
                                 <form action="{{route('?',$banner->id)}}" method="POST">
                                       @csrf
					  @if (isset($banner))
                                       @method('PUT')
                                           
                                       @endif
                                     <select name="status" id="">
                                        <option value="deactive" selected>{{$banner->status}}</option>
                                     </select>
                                     <br>
                                       <button type="submit" class=" btn btn-success btn-sm">Make deactive</button>
                           
                                 </form>
                            </td>
                            @else

                            <td>
                              <form action="{{route('?',$banner->id)}}" method="POST">
                                    @csrf
					  @if (isset($banner))
                                       @method('PUT')
                                           
                                       @endif
                                   
                                    <select name="status" id="">
                                       <option value="active" selected>{{$banner->status}}</option>
                                    </select>
                                    <br>
                                    <button type="submit" class=" btn btn-success btn-sm">Make active</button>
                        
                              </form>
                         </td>
                              @endif

                              <td>
                             <a href="{{route('banners.edit',$banner->id)}}" class="btn btn-add btn-sm" > <i class="fa fa-pencil"></i>  </a> 
                              <button type="submit" class="btn btn-danger btn-sm" onclick="handleDelete({{$banner->id}})" data-toggle="modal" data-target="#deleteModal">
                                <i class="fa fa-trash-o"></i>
                             </button>
                                 </td>
                        </tr>
                        @endforeach

my controller is

 public function index()
    {
        return view('banners.index')->with('banners',Banner::all());
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()

    
    { return view('banners.create');
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(BannerCreateRequest $request)
    {
        $image=$request->image->store('banners');
        Banner::create(['title'=>$request->title,'content'=>$request->content,'image'=>$image,'published_at'=>$request->published_at]);
        toastr()->success('Banner Created Successfully');
        return redirect(route('banners.index'));
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit(Banner $banner)
    {
        return view('banners.create')->with('banner',$banner);

        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(BannerUpdateRequest $request, Banner $banner)
     { 
          $data=$request->only(['title', 'content','published_at','status']);
          
        if($request->hasFile('image')){
            $image= $request->image->store('banners');
       
          $banner->delete_image();
            $data['image']=$image;
            }
        

         $banner->update($data);

         toastr()->success('Banner Updated Successfully');
         return redirect(route('banners.index'));   
        
        
        
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy(Banner $banner)
    {
        $banner->delete_image();
        $banner->delete();

        toastr()->success('Banner deleted Successfully');
         return redirect(route('banners.index'));

        //
    }

how can i make update functionality for make active and deactive

Oct
17
1 week ago
Activity icon

Replied to Undefined Variable Error Exception Occur

i did silly mistake and got stucked ...thank you so much

Activity icon

Replied to Undefined Variable Error Exception Occur

my error is undefined variable $categories.....if categories is undefined then data should't show in table ...its showing in table

Activity icon

Replied to Undefined Variable Error Exception Occur

i am passing vairable ($category->id)from

<button type="submit" class="btn btn-danger btn-sm" onclick="handleDelete({{$category->id}})" data-toggle="modal" data-target="#deleteModal">
                                <i class="fa fa-trash-o"></i>
                             </button>

to delet emodal form that may not be error to

<form action="{{route('categories.destroy',['category'=>$category->id])}}" method="POST" id="deleteCategoryForm">
Activity icon

Started a new Conversation Undefined Variable Error Exception Occur

when i create the category it shows error as

ErrorException
Undefined variable: categories (View: C:\xampp\htdocs\laravel_ecommerce\resources\views\category\index.blade.php)
http://laravelecommerce.com/categories

but when i refresh the page ....category is created what may be the problem help me

my blade file is

@extends('admin.layouts.master')

@section('title')

All Products    
@endsection

@section('content')
   
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
       <div class="header-icon">
          <i class="fa fa-users"></i>
       </div>
       <div class="header-title">
          <h1>categories</h1>
          <small>categories List</small>
       </div>
    </section>
    <!-- Main content -->
    <section class="content">
       <div class="row">
          <div class="col-sm-12">
             <div class="panel panel-bd lobidrag">
                <div class="panel-heading">
                   <div class="btn-group" id="buttonexport">
                      <a href="{{route('categories.create')}}">
                         <h4>Add categories</h4>
                      </a>
                   </div>
                </div>
                <div class="panel-body">
                <!-- Plugin content:powerpoint,txt,pdf,png,word,xl -->
                   <div class="btn-group">
                      <div class="buttonexport" id="buttonlist"> 
                         <a class="btn btn-add" href="{{route('categories.create')}}"> <i class="fa fa-plus"></i> Add category
                         </a>  
                      </div>
                    
                     
                   </div>
                  
                   <div class="table-responsive">
                      @if ($categories->count()>0)
                    <table id="dataTableExample1" class=" myTable table table-bordered table-striped table-hover display">
                     <thead>
                        <tr class="info">
                           <th>id</th>
                           <th>Name</th>
                          
                           <th>Action</th>
                        </tr>
                     </thead>
                     <tbody>
                        
                        @foreach ($categories as $category)
                            
                       
                        <tr>
                          <td>{{$category->id}}</td>
                          <td>{{$category->name}}</td>
                          
                           <td>
                             <a href="{{route('categories.edit',$category->id)}}" class="btn btn-add btn-sm" > <i class="fa fa-pencil"></i>  </a> 
                              <button type="submit" class="btn btn-danger btn-sm" onclick="handleDelete({{$category->id}})" data-toggle="modal" data-target="#deleteModal">
                                <i class="fa fa-trash-o"></i>
                             </button>
                                 </td>
                        </tr>
                        @endforeach
                     </tbody>
                  </table>

                                                        <!-- Modal -->
                     <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
                        <div class="modal-dialog" role="document">
                           <form action="{{route('categories.destroy',['category'=>$category->id])}}" method="POST" id="deleteCategoryForm">
                           @csrf
                                 @method('DELETE')

                                 
                                 
                                 <div class="modal-content">
                                    <div class="modal-header">
                                       <h5 class="modal-title " id="deleteModalLabel" >Delete Post</h5>
                                             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">&times;</span>
                                             </button>
                                    </div>
                                    <div class="modal-body text-center">
                                       Are you sure you want to delete this Product
                                    </div>
                                    <div class="modal-footer">
                                       <button type="button" class="btn btn-secondary" data-dismiss="modal">No, Go back</button>
                                       <button type="submit" class="btn btn-danger">Yes, Delete</button>
                                    </div>
                                 </div>
                           </form>
                           </div>
                     </div>
          {{-- end of delete modal --}}


                    @else    

                    <div class="text-center">
                       <h3>No Category Avialable</h3>
                    </div>
                    @endif






                   </div>
                </div>
             </div>
          </div>
       </div>
     




    </section>
    <!-- /.content -->
 </div>

@endsection



@section('script')
{{-- delete modal --}}
<script>
   function handleDelete(id){
     
       var form=documement.getElementById('deleteCategoryForm')
       form.action='/categories/'+id
       $('#deleteModal').modal('show')
   }

</script>

{{-- jquery datatable --}}

<script src="//cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script>
   $(document).ready( function () {
    $('.myTable').DataTable();
} );
</script>

{{-- toastr --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

@toastr_js
@toastr_render
  
@endsection


@section('css')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
    
@endsection

my controller is

<?php

namespace App\Http\Controllers;

use App\Category;
use App\Http\Requests\Category\CategoryCreateRequest;
use App\Http\Requests\Category\CategoryUpdateRequest;
use Illuminate\Http\Request;

class CategoryController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('category.index')->with('categories',Category::all());
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('category.create');
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CategoryCreateRequest $request)
    {
        Category::create(['name'=>$request->name]);
        toastr()->success('Category Created Successfully');
        return view('category.index');

        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit(Category $category)
    {
        return view('category.create')->with('category',$category);
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(CategoryUpdateRequest $request, Category $category)
    {
        $category->name=$request->name;
        $category->save();
        toastr()->success('Category Updated Successfully');
        return redirect(route('categories.index'));

        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy(Category $category)
    {
        $category->delete();
        toastr()->success('Category Deleted Successfully');
        return redirect(route('categories.index'));
        //
    }
}
Oct
14
2 weeks ago
Activity icon

Started a new Conversation Select2() JQuery Library For Multiple Select Issue Laravel

i am using the select2 library but i am not getting the multiple dropdown select function ...help me to get rid of this

here is my view file

   @if($tags->count()>0)
           <div class="form-group">
               <label for="post_tag">Tags</label>
           
                   <select name="tags[]" id="tags" class="tag_selector form-control" multiple>
                       @foreach ($tags as $tag)
                           <option value="{{$tag->id}}"
                             @if (isset($product))
                                   @if ($product->hasTag($tag->id))
                                   selected  
                                   @endif
                                 
                             @endif
                               >
                               
                               {{$tag->name}}</option>                            
                       @endforeach
                   </select>

            
           </div>
           @endif



@endsection


@section('css')
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
@endsection






@section('script')


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>


<script>
      
 $(document).ready(function() {
    $('.tag_selector').select2();
});
</script>

@endsection

and controller is

  public function create()
    {
        return view('products.create')->with('categories',Category::all())->with('tags',Tag::all());
        //
    }

and product model is


    protected $fillabe=[
        'name','withoutdiscount','withdiscount','description','image','category_id','tag_id','published_at'
    ];

    
  
    

        public function category(){
            return $this->belongsToMany(Category::class); //post model belongs to category model  and laravel try to find the category_id in the post model
        }

        public function tags(){
            return $this->belongsToMany(Tag::class);
        }

        // checks if post has tag return bool
        public function hasTag($tagId)
        {
            return in_array($tagId,$this->tags->pluck('id')->toArray());
            # code...
        }


        public function hasCategory($categoryId){
            return in_array($categoryId,$this->category->pluck('id')->toArray());
        }

Tag model is

  public function products()
    {
        return $this->belongsToMany(Product::class);
        # code...
    }

help me here please

Activity icon

Awarded Best Reply on Toastr Notification Not Working

my problem got solved while doing these...anyone who want to integrate in their project can use this....and if anyone has problem integrating this feature can comment here ...i will help them

composer require yoeunes/toastr

in the confi/app.php

'providers' => [
    ...
    Yoeunes\Toastr\ToastrServiceProvider::class
    ...
];

linking the css and js file of toastr in the app.blade.php like

  <link rel="stylesheet" href="{{ asset('css/toastr.min.css') }}">
 @toastr_css
{{-- body content--}}

  {{-- toastr js file above </body> --}}
    <script src="{{ asset('js/toastr.min.js') }}"></script>
    @jquery
    @toastr_js
    @toastr_render
  

using toastr in the controller

toastr()->info('notification message?')
Activity icon

Replied to Toastr Notification Not Working

my problem got solved while doing these...anyone who want to integrate in their project can use this....and if anyone has problem integrating this feature can comment here ...i will help them

composer require yoeunes/toastr

in the confi/app.php

'providers' => [
    ...
    Yoeunes\Toastr\ToastrServiceProvider::class
    ...
];

linking the css and js file of toastr in the app.blade.php like

  <link rel="stylesheet" href="{{ asset('css/toastr.min.css') }}">
 @toastr_css
{{-- body content--}}

  {{-- toastr js file above </body> --}}
    <script src="{{ asset('js/toastr.min.js') }}"></script>
    @jquery
    @toastr_js
    @toastr_render
  

using toastr in the controller

toastr()->info('notification message?')
Oct
13
2 weeks ago
Activity icon

Started a new Conversation Toastr Notification Not Working

i included the minified toastr css and js file but its not working help me to get toastr notification

here is my view

<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>


      @yield('title')

    </title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    
   
    
    @yield('css')
    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link rel="stylesheet" href="{{asset('css/style.css')}}">


    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" integrity="sha512-vKMx8UnXk60zUwyUnUPM3HbQo8QfmNx7+ltw8Pm5zLusl1XIfwcxo8DbWCqMGKaWeNxWA8yrx5v3SaVpMvR3CA==" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css" integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g==" crossorigin="anonymous" />


</head>
<body>
    <div id="app">
        <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
            <div class="container">
                <a class="navbar-brand btn btn-sm btn-primary p-1" style="font-size: 1rem;color: white" href="{{ url('/') }}" >
                   home
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav mr-auto">

                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <!-- Authentication Links -->
                        @guest
                            <li class="nav-item pr-1">
                                <a class="nav-link btn btn-sm btn-primary" style="font-size: 1rem;color: white"  href="{{ route('login') }}">{{ __('Login') }}</a>
                            </li>
                            @if (Route::has('register'))
                                <li class="nav-item ">
                                    <a class="nav-link btn btn-sm btn-primary" style="font-size: 1rem;color: white" href="{{ route('register') }}">{{ __('Register') }}</a>
                                </li>
                            @endif
                        @else
                            <li class="nav-item dropdown">
                                <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                    {{ Auth::user()->name }} <i class="fa fa-angle-down" aria-hidden="true"></i>
                                </a>


                                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                    <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" class="d-none">
                                        @csrf
                                    </form>
                                </div>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        <main >
            @auth
            <div class="wrapper">
                <!-- Sidebar  -->
                <nav id="sidebar">
                    
            
                    <ul class="list-unstyled components">
                        <li>
                            <a href="{{route('home')}}" ><i class="fas fa-tachometer-alt"></i> Dashboard</a>
                        </li>
                        <li>
                            <a href="{{route('products.index')}}">Products</a>
                        </li>
                        <li>
                            <a href="{{route('categories.index')}}">Category</a>
                        </li>
                        <li>
                            <a href="">Tag</a>
                        </li>
                        <li>
                            <a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle">
                                <i class="fas fa-home"></i> Home
                            </a>
                            <ul class="collapse list-unstyled" id="homeSubmenu">
                                <li>
                                    <a href="#">Home 1</a>
                                </li>
                              
                            </ul>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fas fa-briefcase"></i> About
                            </a>
                            <a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle">
                                <i class="fas fa-copy"></i> Pages
                            </a>
                            <ul class="collapse list-unstyled" id="pageSubmenu">
                                <li>
                                    <a href="#">Page 1</a>
                                </li>
                               
                            </ul>
                        </li>
                       
                       
                    </ul>
            
                   
                </nav>
            
                <!-- Page Content  -->
                <div id="content">
            
                    <nav class="navbar navbar-expand-lg navbar-light bg-light">
                        <div class="container-fluid">
            
                            <button type="button" id="sidebarCollapse" class="btn btn-info">
                                <i class="navbar-toggler-icon "></i>
                              
                            </button>
                            <button class="btn btn-dark d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                <i class="fas fa-align-justify"></i>
                            </button>
            
                            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                                <ul class="nav navbar-nav ml-auto">
                                    <li class="nav-item active">
                                        <a class="nav-link" href="#">Page</a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link" href="#">Page</a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link" href="#">Page</a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link" href="#">Page</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </nav>
                 

                    @yield('content')
                </div>
            </div>

            @else

            @yield('content')
           
            @endauth
            
                
          


        </main>
    </div>
   

  
    @yield('script')

    

    <script>
        $(document).ready(function() {
            $('#sidebarCollapse').on('click', function() {
                $('#sidebar').toggleClass('active');
            });
        });
        
    </script>
@if (session()->has('success'))
<script>
    toastr.success("{!! session()->get('success')!!}");
</script>
    
@endif

<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw==" crossorigin="anonymous"></script> 
  
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script defer src="https://use.fontawesome.com/releases/v5.0.13/js/solid.js" integrity="sha384-tzzSw1/Vo+0N5UhStP3bvwWPq+uvzCMfrN1fEFe+xBmv1C/AtVX5K0uZtmcHitFZ" crossorigin="anonymous"></script>
    <script defer src="https://use.fontawesome.com/releases/v5.0.13/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous">
  





</body>
</html>

here is my controller

    */
    public function update(UpdateCategoryRequest $request, Category $category)
    {
        $category->name=$request->name;
        $category->save();
     
      session()->flash('success','category updated');
        return redirect(route('categories.index'));

        
    }
Oct
09
2 weeks ago
Activity icon

Replied to Driver [facebok] Not Supported Issue Occur In Laravel 7

i am using XAMPP as local server on windoes how can i make please help me

Activity icon

Replied to Driver [facebok] Not Supported Issue Occur In Laravel 7

thanks for helping...but still getting new error for facebook

Laravel\Socialite\Two\InvalidStateException
http://laravelblog.com/login/facebook/callback?error_code=1349187&error_message=Insecure%20Login%20Blocked%3A%20You%20can%27t%20get%20an%20access%20token%20or%20log%20in%20to%20this%20app%20from%20an%20insecure%20page.%20Try%20re-loading%20the%20page%20as%20https%3A%2F%2F
Oct
08
2 weeks ago
Activity icon

Started a new Conversation Driver [facebok] Not Supported Issue Occur In Laravel 7

i am using socialite package ,i am able to signup/login using github and google but while logging with facebook it show error

blade file

<a href="{{route('githublogin','facebook')}}" class="btn btn-primary">faceook</a>
                   <a href="{{route('githublogin','google')}}" class="btn btn-primary">google</a>
                   <a href="{{route('githublogin','github')}}" class="btn btn-primary">github</a>
                   

respective route is

Route::get('login/{website}', 'Auth\[email protected]')->name('githublogin');
Route::get('login/{website}/callback', 'Auth\[email protected]');

controller is

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\User;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Laravel\Socialite\Facades\Socialite;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }


    public function redirectToProvider($website)
    {
        return Socialite::driver($website)->redirect();
    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return \Illuminate\Http\Response
     */
    public function handleProviderCallback($website)
    {
       $user= $githubuser = Socialite::driver($website)->user();
        $user=User::where('provider_id',$githubuser->getId())->first();
        if(!$user){
            $user= User::create([
                'name'=> $githubuser->getName(),
                'email'=> $githubuser->getEmail(),
                'provider_id'=>$githubuser->getId()
                
                ]);

        }
      
auth()->login($user,true);
return redirect('/home');
        // $user->token;
    }


}

and services.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Third Party Services
    |--------------------------------------------------------------------------
    |
    | This file is for storing the credentials for third party services such
    | as Mailgun, Postmark, AWS and more. This file provides the de facto
    | location for this type of information, allowing packages to have
    | a conventional file to locate the various service credentials.
    |
    */

    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
        'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
    ],

    'postmark' => [
        'token' => env('POSTMARK_TOKEN'),
    ],

    'ses' => [
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],

    'github' => [
        'client_id' => '94963c1a233ffbd2969e',
        'client_secret' => '12f9c5c346e9ccd0dcdf9fce68e70e83a2da1df9',
        'redirect' => 'http://laravelblog.com/login/github/callback',
    ],
    'facebook' => [
        'client_id' => '1242232086176521',
        'client_secret' => '7057f026e551de6c4241d91782d70da5',
        'redirect' => 'http://laravelblog.com/login/facebok/callback',
    ],
    'google' => [
        'client_id' => '355555850224-sd36iloqrstscqti0n8n6m5rvhchpch2.apps.googleusercontent.com',
        'client_secret' => 'MVtT3qO9rtF0yxBku8kLCKjq',
        'redirect' => 'http://laravelblog.com/login/google/callback',
    ],

];
Oct
07
3 weeks ago
Activity icon

Replied to Memory Error Trying To Use Socialite/passport

i did COMPOSER_MEMORY_LIMIT=-1 "C:\ProgramData\ComposerSetup\bin\composer.phar" and says not recognized

Oct
06
3 weeks ago
Activity icon

Started a new Conversation Memory Error Trying To Use Socialite/passport

i was trying to do auth by composer require laravel/passport

and error show PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223 how can this be solved

Activity icon

Awarded Best Reply on Storage Folder Is Not Showing In The Public Folder After Linking The Path

i edited .env file and by putting

FILESYSTEM_DRIVER=public got solved problem

Activity icon

Replied to Storage Folder Is Not Showing In The Public Folder After Linking The Path

i edited .env file and by putting

FILESYSTEM_DRIVER=public got solved problem

Oct
04
3 weeks ago
Activity icon

Replied to Storage Folder Is Not Showing In The Public Folder After Linking The Path

i agree with you....but why content inside storage/app is not showing inside public/storage

Activity icon

Started a new Conversation Storage Folder Is Not Showing In The Public Folder After Linking The Path

i used php artisan storage:link i linked storage folder and public folder but its not showing in the public folder directory ,just storage folder is showing and rest of the folder inside the storage directory is not showing

Sep
27
1 month ago
Activity icon

Started a new Conversation Issues Closing Dropdown Menu

When I click outside the dropdown menu then dropdown menu must close. How can I close the dropdown menu? Here is my code:

<div class="pull-right srch-box">
     <button onclick="search_function()" class="dropbtn"><i class="fa fa-search" aria-hidden="true"></i></button>
     <div id="myDropdown" class="dropdown-content">
          <form>
              <div class="input-group search-box form-group">
                 <input type="text" id="search" class="form-control" placeholder="Search here...">
                 <button type="button" class="btn btn-primary ">Search</i></button>
              </div>
          </form>
     </div>
</div>

js script for the open dropdown menu:

function search_function() {
    document.getElementById("myDropdown").classList.toggle("show");
}

What would be the js script to close the dropdown menu?

Sep
25
1 month ago
Activity icon

Awarded Best Reply on Trying To Get Property 'id' Of Non-object

i dont know the error but...i just did php artisan migrate:refresh --seed and got solved

Activity icon

Replied to Trying To Get Property 'id' Of Non-object

i dont know the error but...i just did php artisan migrate:refresh --seed and got solved

Activity icon

Started a new Conversation Trying To Get Property 'id' Of Non-object

my project was working but suddenly i got error what could be the solution

@extends('layouts.app')

@section('title')
    Post
@endsection

@section('content')

<div class="d-flex justify-content-end mb-2"> 
    <a href="{{route('posts.create')}}" class="btn btn-primary">Add Post</a>
</div>

<div class="card card-default">
    <div class="card-header">
        Posts list
    </div> 
    <div class="card-body">
        @if ($posts->count()>0)
        <table class="table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Title</th>
                    <th>Category name</th>
                    <th>Description</th>
                    <th>Image</th>
                    <th>published Date</th>
                    <th>Update</th>
                  
                    <th>Delete</th>
                    
                  
                </tr>
            </thead>
            <tbody>
                 
                  
                    @foreach ($posts as $post)
                    <tr>  
                        <td>{{$post->id}}</td>
                        <td>{{$post->title}}</td>

                        <td> <a href="{{route('categories.edit',$post->category->id)}}">{{$post->category->name}} </a>
                        </td> {{-- category is the funtion post model--}}




                        <td>{{$post->description}}</td>
                        <td> <img src="{{asset('/storage/'.$post->image)}}" alt="" height="60px" width="60px"></td>
                        <td>{{$post->published_at}}</td>
                        
                                @if ($post->trashed())
                                
                               <td>
                                    <form action="{{route('restore-posts',$post->id)}}" method="POST">
                                        @csrf
                                        @method('PUT')
                                        <button  type="submit" class="btn btn-info" > Restore  </button> 
                                    </form>

                               </td>
                                @else
                                <td> <a href="{{route('posts.edit',$post->id)}}" class="btn btn-info" > Update  </a> </td>

                                @endif

                            
                            
                        
                        {{-- <td><button onclick="handleDelete({{$post->id}})" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal">Trash </button> </td> 
                       --}}
                        <td> 
                        <form action="{{route('posts.destroy',$post->id)}}" method="POST">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger">
                                {{$post->trashed()? 'Delete':'trash' }}    
                            </button>                            
                        </form>
                        </td>
                      
                     
                    </tr>
                    @endforeach
                
               
            </tbody>
        </table>
            @else
            <h3 class="text-center">No Post Availabe</h3>
        @endif

    </div>
</div>

{{-- 
<!-- Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <form action="{{route('posts.destroy',['post'=>$post->id])}}" method="POST" id="deleteCategoryForm">
       @csrf
        @method('DELETE')

        
        
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title " id="deleteModalLabel" >Delete Category</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
            </div>
            <div class="modal-body text-center">
                Are you sure you want to delete this Post
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">No, Go back</button>
                <button type="submit" class="btn btn-danger">Yes, Delete</button>
            </div>
        </div>
      </form>
    </div>
</div> --}}

@endsection

@section('scripts')
{{-- <script>
    function handleDelete(id){
      
        var form=documement.getElementById('deleteCategoryForm')
        form.action='/posts/'+id
        $('#deleteModal').modal('show')
    }

</script> --}}





@endsection

respective model is

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;

class Post extends Model
{
   use SoftDeletes;

   protected $fillable=['title','description','content','image','published_at','category_id'];
   //

   /**
    *  
    * @retun void
    */

   public function delete_image(){
       Storage::delete($this->image);
   }
   public function category(){
       return $this->belongsTo(Category::class); //post model belongs to category model  and laravel try to find the category_id in the post model
   }
}

and repective controller is


namespace App\Http\Controllers;

use App\Category;
use Illuminate\Http\Request;


use App\Post;
use App\Http\Requests\post\UpdatePostRequest;
use App\Http\Requests\post\CreatePostRequest;

class PostController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index() 
    { 
        return view('posts.index')->with('posts',Post::all());
        //
    }
 
    /** 
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()

    {return view('posts.create')->with('categories',Category::all());
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CreatePostRequest $request)
    {   $image=$request->image->store('posts');
        Post::create(['title'=>$request->title,'description'=>$request->description,'content'=>$request->content,'image'=>$image,'published_at'=>$request->published_at,'category_id'=>$request->category]);
        session()->flash('success','Post created successfully');
       return redirect(route('posts.index'));
    
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit(Post $post)
    {
        
        return view('posts.create')->with('post',$post)->with('categories',Category::all());
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(UpdatePostRequest $request, Post $post)
    {   $data=$request->only(['title','description','content','published_at']);

          if($request->hasFile('image')){
          $image= $request->image->store('posts');
        //   Storage::delete($post->image);
        $post->delete_image();
          $data['image']=$image;
          }
          $post->update($data);
          
          session()->flash('success','Post Updated  Successfully');
          return redirect(route('posts.index'));

        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {   $post=Post::withTrashed()->where('id',$id)->firstOrFail();
        
        if($post->trashed()){
            // Storage::delete($post->image); used in the Post model due to code refractoring 
            $post->delete_image();
            $post->forceDelete();
            session()->flash('success','Post deleted  permanently');
        }
        else{
            $post->delete();
            session()->flash('success','Post trashed successfully');
        }
      
        return  redirect(route('posts.index'));
        //
    }

    /**
     * display list of all trashed post.
     *
     * @return \Illuminate\Http\Response
     */
    public function treashed(){
        $trashed=Post::onlyTrashed()->get();
        return view('posts.index')->with('posts',$trashed);
    }
    public function restore($id){
        $post=Post::withTrashed()->where('id',$id)->firstOrFail();
        $post->restore();
        session()->flash('success','Post Restored successfully');
        return redirect()->back();

    }
}
Sep
20
1 month ago
Activity icon

Started a new Conversation How To Keep Highlighted The Active Page

how can i keep the highlighted the active navlink while viewing the specific page On every page load, i have to filter out link of current page from your navigation bar and then apply class active in parent. I have posted code here.

   <nav class="navbar navbar-fixed-top">

                <div class="container-fluid">

                    <div class="vesco-nav-wrapper">

                        <div class="navbar-header">

                            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#vesco-menu">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                       </button>

                            <a class="navbar-brand" href="index.html">
                                <img class="top_logo" src="img/logo1.png" alt="Dentistry Explorer">
                            </a>
                        </div>

                        <div class="collapse navbar-collapse floattab" id="vesco-menu">
                            <ul class="nav navbar-nav pull-left floattab ">
                                <li><a class="sooth-scroll active" href="index.html">Home</a></li>
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    article <i class="fa fa-angle-down"></i>
                                    </a>
                                    <div class="dropdown-menu sp" aria-labelledby="navbarDropdown">
                                        <a class="dropdown-item " href="trending.html">TRENDING</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item " href="covid_update.html">COVID-19 UPDATE</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item " href="health_and_follow_link.html">HEALTH FACT</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item " href="#">HEALTH</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item " href="">PREVENTIVE DENTAL CARE</a>
                                    </div>
                                </li>
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        entrance <i class="fa fa-angle-down"></i>
                                    </a>
                                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                        <a class="dropdown-item" href="extrance_exam.html">CCE MDS</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item " href="extrance_exam.html">NMCLE</a>
                                    </div>
                                </li>
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    study material <i class="fa fa-angle-down"></i>
                                    </a>
                                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                         <a class="dropdown-item" href="articles.html">QUESTIONS</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item" href="study_material.html">SOLUTIONS</a>
                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item" href="study_material.html">SLIDES</a>

                                        <div class="dropdown-divider sp"></div>
                                        <a class="dropdown-item" href="study_material.html">DEWNLOAD BOOKS</a>
                                    </div>
                                </li>
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                video <i class="fa fa-angle-down"></i>
                                </a>
                                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                        <a class="dropdown-item" href="videosectioning.html">INTERVIEWS</a>
                                    </div>
                                </li>
                                <li>

                                    <a href="" data-toggle="modal" data-target="#exampleModal"><i class="fa fa-search" aria-hidden="true"></i></a>




                                </li>


                                <li><a class="smooth-scroll btn btn-sm  btn-outline-primary    " style="border-radius: 28px;margin-left: 10px;margin-top: 5px; padding-top: 10px;padding-bottom: 5px;" data-toggle="modal" href="javascript:void(0)" onclick="openLoginModal();"
                                        href="">Login</a></li>
                                <li><a class="smooth-scroll btn btn-sm  btn-primary    " style="border-radius: 28px;margin-left: 10px;margin-top: 5px; padding-top: 10px;padding-bottom: 5px;" data-toggle="modal" href="javascript:void(0)" onclick="openRegisterModal();"
                                        href="">Sign Up</a></li>

                            </ul>


                        </div>

                    </div>

                </div>
            </nav>
Sep
12
1 month ago
Activity icon

Awarded Best Reply on Image Not Showing In Laravel 7

problem solved while writing src=" {{ asset('/storage/'.$post->image) }}"

Activity icon

Replied to Login/register Not Showing While Yield Belolow @auth

post ,category anchor tag should only show when i am logged in .....where i did the mistake

Activity icon

Started a new Conversation Login/register Not Showing While Yield Belolow @auth

login/register page is not showing what should i do to show the login/register page

    @auth
            <div class="container-fluid">
               <div class="row">
                   <div class="col-md-2">
                       <ul class="list-group">
                           <li class="list-group-item">
                               <a href="{{route('posts.index')}}">Post</a>
                           </li>
                           <li class="list-group-item">
                               <a href="{{route('categories.index')}}">Category</a>
                           </li>
                       </ul>

                   </div>
                   <div class="col-md-10">
                       @yield('content')
                   </div>
               </div>
           </div>
           @else
           
           @endauth
'''
Activity icon

Replied to Image Not Showing In Laravel 7

problem solved while writing src=" {{ asset('/storage/'.$post->image) }}"

Activity icon

Replied to Image Not Showing In Laravel 7

in the directory public/storage/post , there is image file of respective post

Activity icon

Replied to Image Not Showing In Laravel 7

i looped through the posts foreach($posts as $post) imagetag src="{{asset($post->image)}}" endforeach

Activity icon

Replied to Image Not Showing In Laravel 7

public/storage/posts

Activity icon

Replied to Image Not Showing In Laravel 7

i updated the post please check once

Activity icon

Started a new Conversation Image Not Showing In Laravel 7

i linked the php artisan storage:link ...but i am getting problem while displaying in the index.blade.php

                 imagetag   src="{{asset($post->image)}}"