Neeraj1005

Neeraj1005

Member Since 7 Months Ago

Experience Points
18,180
Total
Experience

1,820 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
93
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 4
18,180 XP
Mar
24
1 week ago
Activity icon

Started a new Conversation How To Store Image Using Java Script Or Ajax?

This line shows me an error plz fix this var image = $('#clientimage' + id).prop('files')[0];

<div class="row">
    @foreach($client as $clie)
<div class="form-group" id="mydiv1">
         <label for="myid1" class="col-form-label">Myid1:</label>
               <input type="text" id="myid1" class="form-control" readonly="">
                       </div>
                <label for="clientimage">Logo #{{$loop->index+1}}</label>
            <input type="file" class="form-control-file" name="image" id="clientimage{{$clie->id}}">
        <small id="emailHelp" class="form-text text-muted">JPEG, PNG only</small>
                           </div>
       <button type="submit" class="btn btn-primary float-right" onclick="updateImage()">update</button> 
                               {{-- </form> --}}
                                   </div>
                            @endforeach
                               </div>

    @endforeach
</div>
<script>
    function updateImage(){
        // var image = myFormData.append('image', $('#clientimage' + id).prop('files')[0]));
        var id = $('#myid1').val();
        var image = $('#clientimage' + id).prop("files")[0];
         $.ajax({
            headers: {
                 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
             },
            type: 'PUT',
            dataType: 'json',
            mimeType: 'multipart/form-data',
            data: {image:image},
            // url: `/cms/companyClient/${id}`,
            url: "/cms/companyClient/"+id,
            success: function( _response ){
                console.log(_response);
                console.log("file uploaded");
            },
            error: function( _response ){
                console.log(_response);
            }
         });
    }
</script>
Mar
23
1 week ago
Activity icon

Awarded Best Reply on Auto Save Input Field In Laravel.

@snapey problem solved

    <input class="jscolor float-right" name="backgroundcolor" id="statscolor" value="{{$auto->backgroundcolor}}" autocomplete="off" style="background-image: none; background-color: rgb(0, 142, 255); color: rgb(255, 255, 255);" onChange="autoSave(this.jscolor)">
<script>  
// $(document).change(function(){  
     function autoSave(jscolor)  
     {  
            var id =$("#hid").val();
            var statscolor = $('#statscolor').val();  
 
 
               $.ajax({  
                    headers: {
                         'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                     },
                    method:"put",  
                    // url:"{{ route('companyStats.update', $auto->id) }}",   
                    url:"colorstats/"+id,   
                    data:{backgroundcolor:statscolor},  
                    dataType:"text",  
                    success:function(data)  
                    {  
      
                         console.log(data);  
               
                         $('#autoSave').fadeIn().text("color successfully updated");
                         // setInterval(function(){
               
                         //      $('#autoSave').fadeOut();


                         // }, 5000); 
                         setTimeout(function() {
                            $('#autoSave').fadeOut(3000);
                            
                        }, 5000 ); 

          
                    }  
               });  
            
     }
     // setInterval(function(){   
     //      autoSave();   
     //      }, 5000);  
// });  
</script>
Activity icon

Replied to Auto Save Input Field In Laravel.

@snapey problem solved

    <input class="jscolor float-right" name="backgroundcolor" id="statscolor" value="{{$auto->backgroundcolor}}" autocomplete="off" style="background-image: none; background-color: rgb(0, 142, 255); color: rgb(255, 255, 255);" onChange="autoSave(this.jscolor)">
<script>  
// $(document).change(function(){  
     function autoSave(jscolor)  
     {  
            var id =$("#hid").val();
            var statscolor = $('#statscolor').val();  
 
 
               $.ajax({  
                    headers: {
                         'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                     },
                    method:"put",  
                    // url:"{{ route('companyStats.update', $auto->id) }}",   
                    url:"colorstats/"+id,   
                    data:{backgroundcolor:statscolor},  
                    dataType:"text",  
                    success:function(data)  
                    {  
      
                         console.log(data);  
               
                         $('#autoSave').fadeIn().text("color successfully updated");
                         // setInterval(function(){
               
                         //      $('#autoSave').fadeOut();


                         // }, 5000); 
                         setTimeout(function() {
                            $('#autoSave').fadeOut(3000);
                            
                        }, 5000 ); 

          
                    }  
               });  
            
     }
     // setInterval(function(){   
     //      autoSave();   
     //      }, 5000);  
// });  
</script>
Activity icon

Replied to Auto Save Input Field In Laravel.

@snapey it gives me an error like this

customize:2179 Uncaught ReferenceError: autoSave is not defined
    at HTMLInputElement.onchange (customize:2179)
    at Object.fireEvent (jscolor.js:240)
    at Object.dispatchChange (jscolor.js:675)
    at HTMLDocument.<anonymous> (jscolor.js:667)
  <input class="jscolor float-right" name="backgroundcolor" id="statscolor" value="{{$auto->backgroundcolor}}" autocomplete="off" style="background-image: none; background-color: rgb(0, 142, 255); color: rgb(255, 255, 255);" onChange="autoSave()">
Activity icon

Replied to Auto Save Input Field In Laravel.

@snapey I did not clear out. plz tell me where should I have to put onchange event for this?

Activity icon

Replied to Auto Save Input Field In Laravel.

@snapey I have make some minor changes in my controller and script file. controller

	public function companyStats(Request $request, $id)
	{
		$autosave = companyStats::findOrFail($id);

		$autosave->backgroundcolor = $request->backgroundcolor;

		$autosave->save();
		// return redirect()->route('customize')->with('message','updated successfully');//before
		return response()->json(['backgroundcolor'=>$autosave->backgroundcolor]);//after

	}

blade

      <div class="form-group">
                               <label for="statscolor">Background Color</label>
<!--new input line addd-->
                               <input type="hidden" id="hid" value="{{$auto->id}}" name="hid">

                               <input class="jscolor float-right" name="backgroundcolor" id="statscolor" value="{{$auto->backgroundcolor}}" autocomplete="off" style="background-image: none; background-color: rgb(0, 142, 255); color: rgb(255, 255, 255);">
                               <div id="autoSave"></div>
                           </div>

script code modified

<script>  
$(document).ready(function(){  
     function autoSave()  
     {  
            var id =$("#hid").val();
          var statscolor = $('#statscolor').val();  
 
 
               $.ajax({  
                    headers: {
                         'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                     },
                    method:"put",  
                    // url:"{{ route('companyStats.update', $auto->id) }}",   
                    url:"cms/colorstats/"+id,   
                    data:{backgroundcolor:statscolor},  
                    dataType:"text",  
                    success:function(data)  
                    {  
      
                         console.log(data);  
          
                         setInterval(function(){  
                              $('#autoSave').hide();  
                         }, 3000);  

                         $('#autoSave').text("color is updated");
                    }  
               });  
            
     }  
     setInterval(function(){   
          autoSave();   
          }, 3000);  
});  
</script>

Now it is working properly....thanks for replying this thread. could you plz help in this script...I want to show an pop up message when I click the input field the message appears other wise not pop the message. In this case message is pop-up every seconds without clicking the input field.

Activity icon

Replied to Ajax Autosave Selection Without Submit Button

@vandan29 @jay_chauhan and what would be the controller method... because when I trying to do this...in my database it save 'success' json message not the value.

Activity icon

Replied to Auto Save Input Field In Laravel.

@snapey I have chnaged the url but getting same problem in console

PUT http://127.0.0.1:8000/cms/customize 405 (Method Not Allowed)
Activity icon

Started a new Conversation Auto Save Input Field In Laravel.

I am trying to autoupdate the value in database but in my console it thrown an error. can anyone solve this problem plz this is my route for this

Route::put('cms/colorstats/{companyStats}/','Cms\[email protected]')->name('companyStats.update');
	public function companyStats(Request $request, $id)
	{
		$autosave = companyStats::findOrFail($id);

		$autosave->backgroundcolor = $request->backgroundcolor;

		$autosave->save();

		return redirect()->route('customize')->with('message','updated successfully');

	}

blade file code

      <div class="form-group">
              <label for="statscolor">Background Color</label>
               <input class="jscolor float-right" name="backgroundcolor" id="statscolor" value="{{$auto->backgroundcolor}}" autocomplete="off" style="background-image: none; background-color: rgb(0, 142, 255); color: rgb(255, 255, 255);">
                               <div id="autoSave"></div>
                           </div>

script code

<script>  
$(document).ready(function(){  
     function autoSave()  
     {  
          var statscolor = $('#statscolor').val();  
 
          // if(statscolor != '')  
          // {  
               $.ajax({  
                    headers: {
                         'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                     },
                    url:"{{ route('companyStats.update', $auto->id) }}",   
                    method:"put",  
                    data:{backgroundcolor:statscolor},  
                    dataType:"text",  
                    success:function(data)  
                    {  
                         if(data != '')  
                         {  
                              $('#statscolor').val(data);  
                         }  
                         $('#autoSave').text("color updated");  
                         setInterval(function(){  
                              $('#autoSave').text('');  
                         }, 3000);  
                    }  
               });  
          // }            
     }  
     setInterval(function(){   
          autoSave();   
          }, 3000);  
});  
</script>
Mar
21
1 week ago
Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

@snapey same case happend. 2 row updated but it takes first row data...And the same case is happened for id 3 and 4. I have spent 3, 4 hours but not get an appropriate answer for... DO you have any solution how to update this data using without page reload.https://imgur.com/F1KaX90. USING PAGE RELOAD I HAVE DONE THIS. BUT I WANT TO THIS WITHOUT PAGE RELOAD PLZ HELP IF YOU KNOW THE ANSWER

Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

@sergiu17 Now I have updated my js function but Now what I facing.. when I update the 2 row data It save the first row data in second row..look at this image I have only id in first row all data is empty.https://imgur.com/F1KaX90 but when I second row data is store first row data look at output

{id: 2, maintext: null, subtext: null}
id: 2
maintext: null
subtext: null

This is my script function

<script>
    function updateData(id){
        var maintext = $('#maintext').val();
        var subtext =  $('#subtext').val();
         $.ajax({
            headers: {
                 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
             },
            type: 'PUT',
            dataType: 'json',
            data: {maintext:maintext,subtext:subtext},
            url: `/cms/statsupdate/${id}`,
            success: function( _response ){
                console.log(_response);
            },
            error: function( _response ){
                console.log(_response);
            }
         });
    }
</script>

ANd this is my blade file

@foreach($statsloop as $stats)
                             <div class="col-3">
{{-- <form action="" method="post" enctype="multipart/form-data">
    @csrf
    @method('put') --}}
                              <span class="badge badge-pill badge-info">Stats #{{$loop->index+1}}</span>

                              <div class="form-group">
                               <label for="maintext">Main Text</label>
                               <input type="text" class="form-control" id="maintext" name="maintext" value="{{$stats->maintext}}">
                           </div>

                           <div class="form-group">
                               <label for="subtext">Sub Text</label>
                               <input type="text" class="form-control" id="subtext" name="subtext" value="{{$stats->subtext}}">
                           </div>
                           <button type="submit" onclick="updateData({{$stats->id}})" class="btn btn-primary">Save</button>


                       {{-- </form> --}}
                       </div>
                       @endforeach
Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

@sergiu17 now i am getting this error

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
The POST method is not supported for this route. Supported methods: GET, HEAD.
Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

means function save(e, id){ event.preventDefault(); ? I think I have written correctly..

Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

@sergiu17 not working now I put again blade or script file. And now this time is reloaded, I do not want to page reload.

@foreach($statsloop as $stats)
                             <div class="col-3">
<form action="" id="form_data" method="post" enctype="multipart/form-data">
   {{--  @csrf
    @method('put') --}}
                              <span class="badge badge-pill badge-info">Stats #{{$loop->index+1}}</span>

                              <div class="form-group">
                               <label for="maintext">Main Text</label>
                               <input type="text" class="form-control" id="maintext" name="maintext" value="{{$stats->maintext}}">
                           </div>

                           <div class="form-group">
                               <label for="subtext">Sub Text</label>
                               <input type="text" class="form-control" id="subtext" name="subtext" value="{{$stats->subtext}}">
                           </div>

                           <button type="submit" id="form_button" class="btn btn-primary" onclick="save(event, {{ $stats->id }})">Save</button>


                       </form>
                       </div>
                       @endforeach

THis is script file

<script>
    // jQuery, bind an event handler or use some other way to trigger ajax call.
// $('#form_button').submit(function( event ) {
    function save(e, id) {
    event.preventDefault();
    $.ajax({
        headers: {
             'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
         },
      
        url: `/cms/statsupdate/${id}`,
        type: 'put',
        data: $('form').serialize(), // Remember that you need to have your csrf token included
        dataType: 'json',
        success: function( _response ){
            console.log(_response);
        },
        error: function( _response ){
            console.log(_response);
        }
    });
});
</script>
Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

@sergiu17 so, how can I update the values using ajax. should I have change in route or script? if it is then plz tell me how to fix?

Activity icon

Replied to 2nd Row Data Is Overwritten By First Row...?

@sergiu17 it return the

{data: "data saved"}

in console Is my blade form method is correct or script? plz help me out to fix this?

Activity icon

Started a new Conversation 2nd Row Data Is Overwritten By First Row...?

I want to update my form using ajax. it return success in console but data is not saved in database. can anyone help me where i did make mistake. THis is my route

Route::put('cms/statsupdate/{ajaxupdate}','Cms\[email protected]');

this is update function

	public function ajaxupdate(Request $request,  $id)
	{
		$data = companyStats::findOrFail($id);

		$data->maintext = $request->maintext;

		$data->subtext = $request->subtext;

		$data->save();

		return response()->json(['data' => 'data saved']);
	}

This is blade

@foreach($statsloop as $stats)
<form action="{{ url('cms/statsupdate') }}" method="post" enctype="multipart/form-data">
    @csrf
    @method('put')
                             <div class="col-3">
                              <span class="badge badge-pill badge-info">Stat {{$loop->index+1}}</span>

                              <div class="form-group">
                               <label for="maintext">Main Text</label>
                               <input type="text" class="form-control" id="maintext" name="maintext">
                           </div>

                           <div class="form-group">
                               <label for="subtext">Sub Text</label>
                               <input type="text" class="form-control" id="subtext" name="subtext">
                           </div>

                           <button type="submit" class="btn btn-primary">Save</button>


                       </div>
                       </form>
                       @endforeach

<script>
    // jQuery, bind an event handler or use some other way to trigger ajax call.
$('form').submit(function( event ) {
    event.preventDefault();
    $.ajax({
        url: '{{ url('/cms/statsupdate/'.$stats->id) }}',
        type: 'put',
        data: $('form').serialize(), // Remember that you need to have your csrf token included
        dataType: 'json',
        success: function( _response ){
            console.log('success');
        },
        error: function( _response ){
            console.log('error occured');
        }
    });
});
</script>
Activity icon

Replied to How To Update All Rows With Different Values?

@bobbybouwmann I want auto update no save button or anything else. I have input field like this

            <input class="jscolor float-right" name="backgroundcolor" id="statscolor" value="{{$auto->column1}}" autocomplete="off" style="background-image: none; background-color: rgb(0, 142, 255); color: rgb(255, 255, 255);">

how could I auto save this?

Activity icon

Replied to Autoupdate Or Auto Save In Database?

@dominict do you have any source code. plz share.

Activity icon

Started a new Conversation Autoupdate Or Auto Save In Database?

In my project, I have a column named color_picker. Now what I want. I want to update this column using autosave technique instead of update button. So, can anyone help me for this situation how can I do this?

Activity icon

Replied to How To Update All Rows With Different Values?

@bobbybouwmann ok i got it... I have an another problem.. I have an table where for id=1 only I want to save one column automatically.. Is it possible to autosave only one column for Id=1. please if it is possible.. could you plz share the code for this.

Activity icon

Replied to How To Update All Rows With Different Values?

@bobbybouwmann means for each ids we have to apply loop and create an update button?

Activity icon

Started a new Conversation How To Update All Rows With Different Values?

I have one tableA which have two column title and subtitle and I have four-row data. Now I want to update all rows or id with different values. can anyone help me out how can I do this. what would be the query for this. plz suggest me...and provide code...

Mar
12
2 weeks ago
Activity icon

Started a new Conversation How To Perform? If User(A) Status Is Active Then Other User(B,C,D...) Would Be Inactive.

In my project I have created a table. where there is a status column. I want to perform an action like if userA status is 1 then other userB, userC.... status would be 0. Can anyone tell me how to perform this action... Basically this action I want for performing theming...where in my database table 3 or 5 rows default set but one row column status is set to be 1 and other would be 0. If I set other column status 1 then all other row status column would be 0. plz help... how to write code for this... I have route like this

Route::resource('all/themes','themeController');

ANd controller like this

<?php

namespace App\Http\Controllers;

use App\Theme;
use Illuminate\Http\Request;

class themeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $theme = Theme::all();
        return view('Appreance.themes',compact('theme'));
    }

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

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * 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($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

and blade like this

    <section class="content">
<div class="row pl-2">
	@foreach($theme as $theme)
	<div class="col-md-4 p-3">
	<div class="card">
  <img src="{{asset('uploads/default/No-Image-Available-article.png')}}" class="card-img-top fit" alt="...">
  <div class="card-footer bg-dark">
<div class="float-left">{{$theme->themename}}</div>
	<div class="float-right">
		@if($theme->status == 1)
		<a href="#" class="btn btn-sm btn-primary">Activated</a>
			@else
		<a href="#" class="btn btn-sm btn-danger">Activate</a>
		@endif
		</div>
 </div>
	</div>
	</div>
	@endforeach
</section>
@endsection
Mar
10
3 weeks ago
Activity icon

Replied to How To Resolve This Null Array Instead Of Get Value?

@tykus yes I have records.. is Url is correct in blade?

Activity icon

Started a new Conversation How To Resolve This Null Array Instead Of Get Value?

This is my output. I did not understand where I did make a mistake. can anyone solve this?

^ Illuminate\Database\Eloquent\Collection {#1936 ▼
  #items: []
}

THis is my route

Route::get('print/{aslug}','[email protected]');

This is my controller code

  public function printpost($aslug)
    {
        // $articlePrint = CMSPost::where('aslug',$aslug)->orWhere('aslug','LIKE',"%{$aslug}%")->get();
        $print = CMSPost::where('aslug','LIKE',"%{$aslug}%")->get();
        dd($print);
    }

This is blade


							<span><a href="{{url('print/'.$blog->title)}}"><i class="fa fa-print" aria-hidden="true"></i> Print</a></span>
Mar
06
3 weeks ago
Activity icon

Replied to How To Get Rid Of Public URL In Your Laravel Project Deployed On Server CPanel "yourcpanelname/supportcrm/public"

@malektn I think It is not a good way to changes with framework flow...?

@takdw @snapey @malektn Also I have found another solution from stackoverflow https://stackoverflow.com/a/54275198/8455396

Create .htaccess file in root directory and place code something like below


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^ [N]

    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/ 

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ server.php
</IfModule>

In my localhost its running properly but my another problem is.. when error page occured how to hide you environment variable data...because in error page it show all data your database name with password

Activity icon

Replied to How To Get Rid Of Public URL In Your Laravel Project Deployed On Server CPanel "yourcpanelname/supportcrm/public"

@snapey @takdw could you please tell me how can I run my project without /public ? http://my_domain/supportcrm/public/ in cPanel I found some solution like this...is this good.. for security reason?

Rename server.php in your Laravel root folder to index.php
Copy the .htaccess file from /public directory to your Laravel root folder.

https://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url

Activity icon

Replied to How To Get Rid Of Public URL In Your Laravel Project Deployed On Server CPanel "yourcpanelname/supportcrm/public"

@takdw I have one confusion Is it a good idea to chane .htaccess file and index file in laravel..? I google it most of article and video tutotrial say about change .htaccess and make change in index.php file... plz let me know...

Activity icon

Started a new Conversation How To Get Rid Of Public URL In Your Laravel Project Deployed On Server CPanel "yourcpanelname/supportcrm/public"

In cPanel I have uploaded my laravel project but now when I enter my cPanel url. It list me all structure like

app
public
routes
etc...

when I click on public then it runs but I want to access directly with site name..How can I do this.. should I have to create subdomain or is any other method.. because using creating subdomain its working...please let me know it there is any other suggestion instead of subdomain..

Activity icon

Replied to SQLSTATE[HY000] [1045] Access Denied For User 'study6_support'@'localhost' (using Password: YES)

@armancodes using doublequotes...? the problem is # when i removed the # and change the password its working

Activity icon

Replied to SQLSTATE[HY000] [1045] Access Denied For User 'study6_support'@'localhost' (using Password: YES)

@sinnbeck yes, but now I am changing this.... :) My problem is solved in user password I have used the # which make confilicts so Now I am using randon generator password :)

Activity icon

Replied to SQLSTATE[HY000] [1045] Access Denied For User 'study6_support'@'localhost' (using Password: YES)

@armancodes i have give all permission to user but error still exists....

Activity icon

Started a new Conversation SQLSTATE[HY000] [1045] Access Denied For User 'study6_support'@'localhost' (using Password: YES)

I am trying to put my laravel project in cPanel but it gives me an error.. can anyone tell me how to put it cPanel..Here i show my .env file please let me know how to fix this and what other steps I have to follow...

APP_NAME="domainName"
APP_ENV=local
APP_KEY=base64:Fp6+xr6udPYo3rJSYIgMA68bZXL27QDxno6DGrojIM0=
APP_DEBUG=true
APP_URL=

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
[email protected]#325crm //Here I have used the # so don't uses the #

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync


REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
[email protected]

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Mar
04
4 weeks ago
Activity icon

Awarded Best Reply on After Die And Dump Getting Null Value ?

Problem solved...

    public function show(CMSPost $post)
    {
        // $articles = CMSPost::findOrFail($id);
        //$articles = CMSPost::find($post);

        dd($post);
        // return view('cms.post.show',compact('post));
    }
Activity icon

Replied to After Die And Dump Getting Null Value ?

Problem solved...

    public function show(CMSPost $post)
    {
        // $articles = CMSPost::findOrFail($id);
        //$articles = CMSPost::find($post);

        dd($post);
        // return view('cms.post.show',compact('post));
    }
Activity icon

Started a new Conversation After Die And Dump Getting Null Value ?

Output

^ null

Basically I want fetch record using routekeyname in url...In url key name is shown but data is not diplaying... This is my show function

    public function show($post)
    {
        // $articles = CMSPost::findOrFail($id);
        $articles = CMSPost::find($post);

        dd($articles);
        // return view('cms.post.show',array('articles' => $articles));
    }

And this is my Model

<?php

namespace App;

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

class CMSPost extends Model
{
	use SoftDeletes;


	protected $dates = ['deleted_at'];
	protected $table ='cms_posts';
    protected $primaryKey = 'id';

	protected $fillable = array('category_id','title','author','show_date','image','description','status','user_id','slug',
        'visit_count','aslug','subcategory_id','draft');   
    
    
    /**
     * Get the route key for the model.
     *
     * @return string
     */
    public function getRouteKeyName()
    {
        return 'aslug';
    }

    public function category()
     {
         return $this->belongsTo('App\CMSCategory','category_id');
     }  


     public function user(){

         return $this->belongsTo('App\User','user_id');
     }

     public function mediaLibrary(){

         return $this->belongsTo('App\mediaLibrary','image');

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


}

And this is my route

Route::group(['prefix' => 'cms',  'middleware' => 'auth'], function()
{
    Route::resource('/post','CMSPostController');
}
Mar
02
4 weeks ago
Activity icon

Replied to SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'c_m_s_post_id' In 'where Clause' (SQL: Select * From `cms_post_tag` Where `c_m_s_post_id` = 2)

@munazzil now I am getting this error

BadMethodCallException

Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::sync()

$insertedid->tag()->sync((array)$request->input('tags'));

Activity icon

Started a new Conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'c_m_s_post_id' In 'where Clause' (SQL: Select * From `cms_post_tag` Where `c_m_s_post_id` = 2)

Can anyone resolve this problem I have cms_post, cms_tag and cms_post_tag table. basically post is created but in cms_post_tag no data is inserted and it throw an error...

This is the post model database
    public function up()
    {
        Schema::create('cms_posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('category_id');
                            $table->foreign('category_id')->references('id')->on('categories');
            $table->integer('subcategory_id')->nullable();
                            $table->foreign('subcategory_id')->references('id')->on('subcategories');
            $table->unsignedInteger('user_id');
                            $table->foreign('user_id')->references('id')->on('users');
            $table->string('title',256);
            $table->string('slug',256);
            $table->string('aslug',100);
            $table->string('seo',256);
            $table->string('author',256);
            $table->date('show_date');
            $table->string('image')->nullable();
            $table->string('document',256);
            $table->text('description');
            $table->tinyInteger('status')->default('0');
            $table->tinyInteger('draft')->default('0');
            $table->tinyInteger('posts_is_active')->default('1');
            $table->integer('visit_count')->default('0');
            $table->integer('no_click');
            $table->integer('like');
            $table->integer('dislike');
            $table->softDeletes();
            $table->timestamps();
        });
    }

This is the tag databse

  public function up()
    {
        Schema::create('cms_tag', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name')->nullable();
            $table->timestamps();
        });
    }

This is the post_tag table database

    public function up()
    {
        Schema::create('cms_post_tag', function (Blueprint $table) {
            $table->bigInteger('cms_post_id')->unsigned()->nullable();
            $table->foreign('cms_post_id')->references('id')->on('cms_posts')->onDelete('cascade');

            $table->bigInteger('cms_tag_id')->unsigned()->nullable();
            $table->foreign('cms_tag_id')->references('id')->on('cms_tag')->onDelete('cascade');
        });
    }

And model are is

Post model

class CMSPost extends Model
{
    use SoftDeletes;


    protected $dates = ['deleted_at'];
    protected $table ='cms_posts';
    protected $primaryKey = 'id';

    protected $fillable = array('category_id','title','author','show_date','image','description','status','user_id','slug',
        'visit_count','aslug','subcategory_id','draft');   
    
    public function category()
     {
         return $this->belongsTo('App\CMSCategory','category_id');
     }

     public function user(){

         return $this->belongsTo('App\User','user_id');
     }

     public function mediaLibrary(){

         return $this->belongsTo('App\mediaLibrary','image');

     }
     
     public function tag()
         {
             return $this->belongsToMany('App\CMSTag', 'cms_post_tag'); //cms_post_tag => pivot table reference
         }  


}

and tag model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class CMSTag extends Model
{
    protected $table = 'cms_tag';
    protected $fillable = ['name'];
}

ANd this is post controller where error occurs show


    public function store(Request $request)
    {
        request()->validate([

            'category_id'=>'required|not_in:0',                     
            'show_date'=>'required',            
            'description'=>'required',
            'title'=>'required'

        ]);

        $records = $request->all();


        $categorySlug = CMSCategory::findOrFail($request->category_id);

        $user = Auth::user()->id;


        if ($request->hasFile('image')) {
          if ($request->file('image')->isValid()) {
            $image = $request->file('image');
                $extension = $image->getClientOriginalExtension();//Getting extension
                $originalname = $image->getClientOriginalName();//Getting original name
                $path = $image->move('uploads/media/cms/post', $originalname);//This will store in customize folder
                $imgsizes = $path->getSize();
                $size = getimagesize($path);
                $width = $size[0]; 
                $height = $size[1];
                $mimetype = $image->getClientMimeType();//Get MIME type

                $photo = mediaLibrary::create([
                  'filename'=>Str::replaceLast('\','/',$path),
                  'mime'=>$mimetype,
                  'extension'=>$extension,
                  'original_filename'=>$originalname,
                  'imgsize'=>$imgsizes,
                  'width'=>$width,
                  'height'=>$height
              ]);


                $records['image'] = $photo->id;
            }
        }


        $records['user_id'] = $user;
        $records['slug'] = $categorySlug->slug;

        $records['aslug'] = $this->createSlug($request->title);

        if ($request->has('save'))
        {
                            // draft
            $records['draft'] = 0;
        }
        else if ($request->has('publish'))
        {
                            // publish
            $records['draft'] = 1;
        } 


        $insertedid= CMSPost::create($records);


        // $tagValue = array('articleSlug' => $records['aslug'], 'name'=>$request->tags,'article_id'=>$insertedid->id);
        // DB::table('tags')->insert($tagValue);
        $insertedid->tag()->sync((array)$request->input('tags'));


        return redirect()->route('post.index')->with('success','Article created successfully.');
}
Mar
01
1 month ago
Activity icon

Replied to Show Function Show Blank File Instead Of Data

@snapey yes, basically in my route::list there is two route match like this

categories/{category}
OR
cms/category/{category}

I think this would be the reason for that data is not showing... Later I'll try with distinct route and test this...

Activity icon

Replied to Show Function Show Blank File Instead Of Data

@pickab00 yes this method above is working fine but I want use this method

public function (CMSCategory $cMSCategory)

for route model binding but no data is showing...my bad

Activity icon

Replied to Show Function Show Blank File Instead Of Data

@pickab00 yes it exists..i have three field in my database for category. I tried your $cMSCategory->created_at ...it show blank page.. okkk forgot it... Now I am using this method

Public function show($id)
{
    $data = CMSCategory::findOrFail($id);
    return view('my_blade_path',compact('data'));
}

This method run perfectly...but i did not understand the previous problem. If you found any solution then let me know it would be very helpful..

Activity icon

Replied to Show Function Show Blank File Instead Of Data

@pickab00 yes I file is reached... Where I have write Hello world..it shows but when i write code like this Hello world: {{$cMSCategory->name}} only Hello world shows.. name is not showing

I think in my web.php I have two route same like categories/{category} and cms/category/{category} Maybe this make a conflict...?

but problem is both are resource route

Activity icon

Replied to Show Function Show Blank File Instead Of Data

@pickab00 I am using the resource route Route::resource('/category','CMSCategoryController'); but when i run this route:list it shows cms/category/{category}

Activity icon

Started a new Conversation Show Function Show Blank File Instead Of Data

problem is when i visit http://localhost/supportcrm/public/cms/category/2 URL is show only Name is: and name is not print. and this is the show function

    public function show(CMSCategory $cMSCategory)
    {
        // dd($cMSCategory);
        return view('cms.category.show',compact('cMSCategory'));
    }

this is the code under my blade

Name is: {{ $cMSCategory->name }}
Activity icon

Awarded Best Reply on While Doing Multiple Delete Using Softdelete Data Is Not Deleted?

Route url for ajax

 Route::get('/delete-all-category','[email protected]')->name('delete-all-cms.category');

Delete button having some class

   <div class="border-top bg-white card-footer text-muted">
             <button class="btn btn-sm btn-outline-secondary font-weight-normal delete-all" data-url=" " data-toggle="confirmation"><i class="fa fa-trash mr-1" aria-hidden="true"></i>Delete</button>      
            </div>

Below controller function

   public function deleteallcmsCategory(Request $request)
    {

        $ids = $request->ids;
// dd($ids);
        CMSCategory::whereIn('id',explode(",",$ids))->delete();
        
        return response()->json(['status'=>true,'message'=>"Category softdeleted successfully."]);
    }

Below is the ajax call

<script type="text/javascript">

   $(document).ready(function () {
      $('#check_all').on('click', function(e) {
      if($(this).is(':checked',true))  
      {
        $(".checkbox").prop('checked', true);  

      } else {  

        $(".checkbox").prop('checked',false);  

      } 

      });
      $('.checkbox').on('click',function(){

        if($('.checkbox:checked').length == $('.checkbox').length){

           $('#check_all').prop('checked',true);

        }else{

           $('#check_all').prop('checked',false);

        }

      });

      $('.delete-all').on('click', function(e) {

       var idsArr = [];  

        $(".checkbox:checked").each(function() {  

           idsArr.push($(this).attr('data-id'));

        });  
       if(idsArr.length <=0)  
       {  
        alert("Please select atleast one record to delete.");  

       }else {  

        if(confirm("Are you sure, you want to delete the selected record?")){  
          var strIds = idsArr.join(","); 

           $.ajax({
           
            url: "{{ route('delete-all-cms.category') }}",

              type: 'GET',
              headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
              data: 'ids='+strIds,
              success: function (data) {
               
              if (data['status']==true) {
                $(".checkbox:checked").each(function() {  
  
                  $(this).parents("tr").remove();

                });
                alert(data['message']);

                } else {
                  alert('Whoops Something went wrong!!');
                }
              },

              error: function (data) {
              alert(data.responseText);

              }

              });

           }  

        }  

      });

      $('[data-toggle=confirmation]').confirmation({

       rootSelector: '[data-toggle=confirmation]',
       onConfirm: function (event, element) {
        element.closest('form').submit();
       }

    });   

  });

</script> 
Activity icon

Replied to While Doing Multiple Delete Using Softdelete Data Is Not Deleted?

Route url for ajax

 Route::get('/delete-all-category','[email protected]')->name('delete-all-cms.category');

Delete button having some class

   <div class="border-top bg-white card-footer text-muted">
             <button class="btn btn-sm btn-outline-secondary font-weight-normal delete-all" data-url=" " data-toggle="confirmation"><i class="fa fa-trash mr-1" aria-hidden="true"></i>Delete</button>      
            </div>

Below controller function

   public function deleteallcmsCategory(Request $request)
    {

        $ids = $request->ids;
// dd($ids);
        CMSCategory::whereIn('id',explode(",",$ids))->delete();
        
        return response()->json(['status'=>true,'message'=>"Category softdeleted successfully."]);
    }

Below is the ajax call

<script type="text/javascript">

   $(document).ready(function () {
      $('#check_all').on('click', function(e) {
      if($(this).is(':checked',true))  
      {
        $(".checkbox").prop('checked', true);  

      } else {  

        $(".checkbox").prop('checked',false);  

      } 

      });
      $('.checkbox').on('click',function(){

        if($('.checkbox:checked').length == $('.checkbox').length){

           $('#check_all').prop('checked',true);

        }else{

           $('#check_all').prop('checked',false);

        }

      });

      $('.delete-all').on('click', function(e) {

       var idsArr = [];  

        $(".checkbox:checked").each(function() {  

           idsArr.push($(this).attr('data-id'));

        });  
       if(idsArr.length <=0)  
       {  
        alert("Please select atleast one record to delete.");  

       }else {  

        if(confirm("Are you sure, you want to delete the selected record?")){  
          var strIds = idsArr.join(","); 

           $.ajax({
           
            url: "{{ route('delete-all-cms.category') }}",

              type: 'GET',
              headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
              data: 'ids='+strIds,
              success: function (data) {
               
              if (data['status']==true) {
                $(".checkbox:checked").each(function() {  
  
                  $(this).parents("tr").remove();

                });
                alert(data['message']);

                } else {
                  alert('Whoops Something went wrong!!');
                }
              },

              error: function (data) {
              alert(data.responseText);

              }

              });

           }  

        }  

      });

      $('[data-toggle=confirmation]').confirmation({

       rootSelector: '[data-toggle=confirmation]',
       onConfirm: function (event, element) {
        element.closest('form').submit();
       }

    });   

  });

</script> 
Feb
29
1 month ago
Activity icon

Replied to What's Wrong With This Method?

@tykus @sinnbeck @ma And I am using the sofdelete functionality for this... if i click on delete button deleted_at column updated. when I edit the destroy function like this

public function destroy($id)
{
    $CMSCategory::destroy($id);

    return redirect()->route('category.index');
}

THis will run perfectly... but i am confused why this is not running

public function destroy(CMSCategory $category)
{
    $category->delete();

    return redirect()->route('category.index');
}

and this is the blade delete column

            <td>
                    <form action="{{ route('category.destroy',$category->id) }}" method="POST">

                        @csrf
                        @method('DELETE')
            
                        {{-- <button type="submit" class="btn-text-delete deletebutton"  >Delete</button> --}}
                        <button type="submit" class="btn btn-danger deletebutton">Delete</button>

            
                    </form>
                </td>
Activity icon

Replied to What's Wrong With This Method?

@ma I am using the ajax call for multiple delete. but I have still problem on this ...