anibabbar

anibabbar

Member Since 2 Months Ago

Experience Points
330
Total
Experience

4,670 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
1
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
330 XP
May
22
1 week ago
Activity icon

Replied to Searching Select List In Laravel 7

It seems to be a library for datatables.

It could be useful for listing data & I would try this for sure.

But here I am looking for a ajax based select list search plugin to use in a Form.

Activity icon

Replied to Overnight Report/period

I hope this helps,

->where('COLUMN_NAME', 'OPERATOR', 'VALUE');

it should be simple like this.

->where('startdate', '>=', 'VALUE')
->where('enddate', '<=', 'VALUE')
->where('starttime', '>=', 'VALUE')
->where('endtime' , '<=',  'Value  )

Follow this: https://laravel.com/docs/7.x/queries#introduction

Activity icon

Started a new Conversation Searching Select List In Laravel 7

I wanted user to select an option in HTML select list , there will be 20k + options to choose from.

What option should I use for searching select list.

Should I use Select2 Js and ajax for live search from mysql or Laravel has some other supported library to make live search on database in HTML select list.

Any help is much appreciated. !!

Best Regards Anirudh Babbar

May
21
1 week ago
Activity icon

Replied to 404 Error On Form Update

@mkshingrakhiya thanks a lot bro !! these are simple typos that waste hours and hours...

I am just laughing over myself ... like hell ... silly mistake ... wasted my day.

and @snapey, thanks a lot bro to you too... you simply helped me lot.. and gave me several great tricks in this thread.

Regards Anirudh

Activity icon

Replied to 404 Error On Form Update

I am just simply returning $request to test. But it still dont work. Let me again share controller method and view and route

get route for edit is working fine. When I submit form... it should redirect to update method and it just breaks there.

Let me explain this again: I am just simply submitting a form to update route and instead of routing to update method, laravel gives me a 404 error.

I am developing an app with 40+ Different CRUD operations. Some of the CRUD's are working fine and some aren't working. I am adopting exact same system to all of CRUD's.

In Bank case, when I submit the form, laravel just return 404 instead of update method.

Route

Route::get('/bank/{id}/edit', '[email protected]');
Route::put('/bank/{$id}', '[email protected]')->name('bankUpdate');

Controller

 public function update(Request $request, $id)
    {   
        return $request; 
    }

View

@extends('layouts.dashboard')
@section('title', 'Update Bank')

@section('content')

<form action="/bank/{{$bank->id}}" method="POST">

@csrf
@method('put')
<div class="col-md-6">

  <div class="card">
   
  <div class="card-header">
        <h4 class="card-title">Update Details</h4>
    </div>

    <div class="card-body">
  
    <div class="form-group row">
    <label for="name" class="col-4 col-form-label">Bank name</label> 
    <div class="col-8">
      <input id="name" name="name" type="text" class="form-control" value="{{$bank->name}}">
    </div>
  </div>

  <div class="form-group row">
    <label for="Account No" class="col-4 col-form-label">Account No</label> 
    <div class="col-8">
      <input id="Account No" name="account_no" type="text" class="form-control" aria-describedby="Account NoHelpBlock" value="{{$bank->account_no}}"> 
      <span id="account_noHelpBlock" class="form-text text-muted">optional</span>
    </div>
  </div>

  <div class="form-group row">
    <label for="code" class="col-4 col-form-label">Code</label> 
    <div class="col-8">
      <input id="code" name="code" type="text" class="form-control" aria-describedby="codeHelpBlock" value="{{$bank->code}}"> 
      <span id="codeHelpBlock" class="form-text text-muted">optional</span>
    </div>
  </div>

  <div class="form-group row">
    <label for="Credit Limit" class="col-4 col-form-label">Credit Limit</label> 
    <div class="col-8">
      <input id="credit_limit" name="credit_limit" type="text" class="form-control" aria-describedby="Credit LimitHelpBlock" value="{{$bank->credit_limit}}"> 
      <span id="credit_limitHelpBlock" class="form-text text-muted">optional</span>
    </div>
  </div>

  <div class="form-group row">
    <label for="currency" class="col-4 col-form-label">Currency</label> 
    <div class="col-8">
      <input id="currency" name="currency" type="text" class="form-control" value="{{$bank->currency}}">
    </div>
  </div> 


    </div>
    <!-- card-body -->
        <div class="border-top">
            <div class="card-body">
<input type="submit" value="Update Bank" class="btn btn-primary">   
           </div>
        </div>
       
  
</div>

</div>
<!-- col-md-6 -->
</form>
@endsection
Activity icon

Replied to 404 Error On Form Update

@snapey, why do I need a get route for bank/1, I am submitting a put request to /bank/{{$id}}

Route::put('/bank/{$id}', '[email protected]')->name('bankUpdate');

Instead of running update method on submit, it just redirects to 404 page, it isnt able to find update method,

Activity icon

Replied to 404 Error On Form Update

I have bank with id of 1, & error is same with all ids

Activity icon

Replied to 404 Error On Form Update

I believe it will be a very very small error that is just not passing my eyes or may be I am doing something really stupid.

Activity icon

Replied to 404 Error On Form Update

@snapey my browser bar says : Not Found url = http://127.0.0.1:8000/bank/1

This happens when i am Updating a bank record.

On my web.php I have setup Client crud, thats working fine.

Later I added Bank & Cash crud. In bank and cash crud update and delete return Not Found, 404 error.

My routes list shows all routes - php artisan route:list

Activity icon

Replied to Updating Existing Product

this works for me !!

    'slug' => 'required|unique:content|max:255',

and I belive this should work for you

'slug' => 'required|unique:products',

Here is the link to documentation: https://laravel.com/docs/7.x/validation#introduction

Activity icon

Replied to 404 Error On Form Update

@snapey thanks for improving controller code. I am really thankful for this.

I couldn't understand this - " You might consider using named routes to make things clearer "

how could this help !! Its my first project with laravel. But I have good experience with MVC patterns. Everything is working fine. One of the crud is working fine in the same project.

But when I am creating new routes for new CRUD operations, I am stuck with Update. It just give me 404 error. I am pasting my complete web.php, There might be an error there. I hope this might help solving issue.


Route::get('/', function () {
    // return view('dashboard.index');
    // return view('layouts.dashboard');
    return view('welcome');
});

Auth::routes();

Route::get('/home', '[email protected]')->name('home');

Route::get('/client', '[email protected]')->name('client');
Route::get('/client/create', '[email protected]')->name('clientCreate');
Route::post('/client', '[email protected]');
Route::get('/client/{id}/edit', '[email protected]');
Route::put('/client/{id}', '[email protected]');

Route::delete('/client/{id}/destroy', '[email protected]');


Route::get('/business', '[email protected]')->name('business');
Route::get('/business/create', '[email protected]')->name('businessCreate');

Route::get('/bank', '[email protected]')->name('bank');
Route::get('/bank/create', '[email protected]')->name('bankCreate');
Route::post('/bank', '[email protected]');
Route::get('/bank/{id}/edit', '[email protected]');
Route::put('/bank/{$id}', '[email protected]')->name('updatebank');

Route::delete('/bank/{$id}/destroy', '[email protected]');

Route::get('/cash', '[email protected]')->name('cash');
Route::get('/cash/create', '[email protected]')->name('cashCreate');
Route::post('/cash', '[email protected]');
Route::get('/cash/{id}/edit', '[email protected]');
Route::put('/cash/{$id}', '[email protected]');



Route::get('/supplier', '[email protected]')->name('supplier');
Route::get('/supplier/create', '[email protected]')->name('supplierCreate');

Route::get('/inventory', '[email protected]')->name('inventory');
Route::get('/inventory/create', '[email protected]')->name('inventoryCreate');
Activity icon

Replied to 404 Error On Form Update

sure.. will use this !!

Activity icon

Replied to 404 Error On Form Update

almost doing same code for other Controller and things running fine. I believe there could be an error while setting up laravel routes or routes order. Not sure at all.

Activity icon

Started a new Conversation 404 Error On Form Update

Once I submit form I receive 404 error. I couldn't figure out error !! Hope someone could help.

Controller :

public function update(Request $request, $id)
    {
        // return $request;

        $bank = Bankaccounts::find($id);

        // return $bank;
        $user = Auth::user()->id;

        if($bank->user_id !== $user) {
           return  redirect('bank');
         } else { 
        $bank->name = $request->name;
        $bank->account_no = $request->account_no;
        $bank->code = $request->code;
        $bank->credit_limit = $request->credit_limit;
        $bank->currency = $request->currency;
        $bank->user_id = $parent_id;
        $bank->emp_id = $user_id;

        $bank->save();

        $redirect = $_SERVER['HTTP_REFERER'];
   
        return redirect($redirect);
         }
    }

View :

@extends('layouts.dashboard')
@section('title', 'Update Bank')

@section('content')
<form action="/bank/{{$bank->id}}" method="POST">
@csrf
@method('put')
<div class="col-md-6">
<div class="card">
    <div class="card-header">
        <h4 class="card-title">Update Details</h4>
    </div>
    <div class="card-body">
  <div class="form-group row">
    <label for="name" class="col-4 col-form-label">Bank name</label> 
    <div class="col-8">
      <input id="name" name="name" type="text" class="form-control" value="{{$bank->name}}">
    </div>
  </div>
  <div class="form-group row">
    <label for="Account No" class="col-4 col-form-label">Account No</label> 
    <div class="col-8">
      <input id="Account No" name="account_no" type="text" class="form-control" aria-describedby="Account NoHelpBlock" value="{{$bank->account_no}}"> 
      <span id="account_noHelpBlock" class="form-text text-muted">optional</span>
    </div>
  </div>
  <div class="form-group row">
    <label for="code" class="col-4 col-form-label">Code</label> 
    <div class="col-8">
      <input id="code" name="code" type="text" class="form-control" aria-describedby="codeHelpBlock" value="{{$bank->code}}"> 
      <span id="codeHelpBlock" class="form-text text-muted">optional</span>
    </div>
  </div>
  <div class="form-group row">
    <label for="Credit Limit" class="col-4 col-form-label">Credit Limit</label> 
    <div class="col-8">
      <input id="credit_limit" name="credit_limit" type="text" class="form-control" aria-describedby="Credit LimitHelpBlock" value="{{$bank->credit_limit}}"> 
      <span id="credit_limitHelpBlock" class="form-text text-muted">optional</span>
    </div>
  </div>
  <div class="form-group row">
    <label for="currency" class="col-4 col-form-label">Currency</label> 
    <div class="col-8">
      <input id="currency" name="currency" type="text" class="form-control" value="{{$bank->currency}}">
    </div>
  </div> 


    </div>
    <!-- card-body -->
        <div class="border-top">
            <div class="card-body">
<input type="submit" value="Update Bank" class="btn btn-primary">              </div>
        </div>
       
  
</div>

</div>
<!-- col-md-6 -->
</form>
@endsection

Route:

 Route::put('/bank/{$id}', '[email protected]');
Activity icon

Replied to Post Method In Route Says 404 | Not Found

Just loved this - "There is no documentation link for bad code!"