AKmahato

AKmahato

Member Since 7 Months 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
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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
15 Mar
6 months ago

AKmahato started a new conversation How To Fetch Data In Mail Template From Database.

I created one mail template which is in HTML by using sendgrid templates but the problem is when I trying to fetch data from the database it is not coming into the template. I've no idea what i have to do. Please help

Here is my code


 <table class="module" role="module" data-type="text" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;background-color:#ffffff;padding:15px 0px 10px 5px">
      <tr>
        
        <th>User Id</th>
        <th>User Name</th>
        <th>Email</th>
        
      </tr>
      <tr style="text-align: left;">
        @foreach($count as $item)
            <td>{{$item->id}}</td>
            <td>{{$item->name}}</td>
            <td>{{$item->email}}</td>
       @endforeach
        
      </tr>
      
    </table>
   

AKmahato left a reply on Uploading Different Types Of Files

@CRONIX - We just want to show the file in the browser no matter what file type it is.

AKmahato left a reply on How To Fetch Data From Database And Send Through The Automated Mail

@CHRISTOPHHARMS - Thanks for the reply... There was no issue I was using the wrong reference.

12 Mar
6 months ago

AKmahato started a new conversation How To Design The Mail Template In Laravel5.5

I want to design the mail template for that I saw some tutorial everywhere they are using markdown. Is there any other way to design mail template in laravel5.5

AKmahato started a new conversation How To Fetch Data From Database And Send Through The Automated Mail

I have created an automated mail that is scheduled, and the mail contains the count of users, but we want to show the content of table( id, name) which will go as mail to the email id provided.

Here is my code


public function handle()
    {
        $data1 = DB::table('users')->select('id','created_at')->get();
       
        foreach($data1 as $data){
            $fromData = $data->created_at;
          
                $date = Carbon\Carbon::now();
                $difference = $date->diffInDays($fromData);
                if($difference>=7){
                    $totalUsers = \DB::table('users')
                          ->whereRaw('Date(created_at) = CURDATE()')
                          ->count();
                        Mail::to('[email protected]')
                        //->subject($subject)
                        ->cc('[email protected]')
                        ->send(new SendMailable($totalUsers));
        
                }
         }

This is my SendMailable class


public $count;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($count)
    {
        $this->count = $count;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.registeredcount')
        ->subject('This is Demo Email');
    }

This is my view

<div>
    Total number of registered users for today is: {{ $count }}
</div>

11 Mar
6 months ago

AKmahato left a reply on Call To A Member Function Diff() On String

@DRAGONEYES96 - Thanks for the reply. yes it is working now

AKmahato left a reply on Call To A Member Function Diff() On String

@DRAGONEYES96 - After modifying this error is coming

A non-numeric value encountered

AKmahato left a reply on Call To A Member Function Diff() On String

@DRAGONEYES96 - Thanks for reply I tried as of your instruction but now I'm getting this error

DateTime::diff() expects parameter 1 to be DateTimeInterface, string given

AKmahato started a new conversation Call To A Member Function Diff() On String

I want to calculate the difference between the current date and some date which is stored in my database. When I run my code I got this(Call to a member function diff() on a string) error. Can you please tell me how to resolve this error?

This is my code


$users = DB::table('customer_grievance_forms')->select('cg_id','created_at')->get();
        $count= count($users);
        foreach($users as $data){
            $fromData = $data->created_at;
           // print_r($fromData);

           echo "Previous Date Is :".$fromData;
           echo "</br>";
        }

        $date = Carbon\Carbon::now()->toDateTimeString();
        echo "Current Dtae is :".$date;

        $difference = $date->diff($fromData);

        echo "Difference is :"+$difference;

06 Mar
6 months ago

AKmahato started a new conversation Uploading Different Types Of Files

How to view multiple types of file e.g. pdf/doc/txt while restricting them to download.?

AKmahato started a new conversation How To Add Multiple Authentication In Laravel 5.5

We have a requirement in which 3 to 4 Roles authentication(login) are there. Actually, we got a tutorial where authentication sign-in is happening with two roles where they've used boolean in the database. Example: Admin and User. But we want more than two authentication sign-in. Please help!

01 Mar
6 months ago

AKmahato left a reply on How To Insert Records In Two Tables From Single Form

@MUSHOOD - Thanks for the reply but i already tried whatever snippet code you send. It's not inserting multiple data

AKmahato left a reply on How To Insert Records In Two Tables From Single Form

@MUSHOOD - ```php

My Form

@extends('layouts.master')

@section('title') Add Category @endsection

@section('content')

$(function () { $('.add').click(function () {
        var tr = '<tr>' +
                '<td><input type="text" class="name form-control" name="sc_name[]" value="{{ old('sc_name') }}"></td>'+
                '<td><input type="text" class="fname form-control" name="sc_desc[]" value="{{ old('sc_desc') }}"></td>'+
                                 
                '<td><input type="button" class="btn btn-danger delete" value="Remove"></td></tr>';
        $('.resultbody').append(tr);
    });

    $('.resultbody').delegate('.delete', 'click', function () {
        $(this).parent().parent().remove();
    });

});

@if ($errors->any())

@endif Add Category
            <div class="card-body">
                <form method="POST" class="form" role="form" action="{{route('category.store')}}">
                    @csrf
                    <div class="form-row">
                        <div class="form-group col-md-4">
                            <label for="c_id">Category ID</label>
                            <input class="form-control" name="" type="text">
                        </div>
                        <div class="form-group col-md-4">
                            <label for="c_date">Category Date</label>
                            <!-- <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea> -->
                            <input class="form-control" name="c_date" type="text" value="{{date('Y-m-d')}}"
                                required>
                        </div>
                        <div class="form-group col-md-4">
                            <label for="c_name">Category Name</label>
                            <!-- <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea> -->
                            <input class="form-control" name="c_name" type="text" required>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="c_desc">Category Description</label>
                            <textarea name="c_desc" class="form-control" rows="3" required></textarea>
                        </div>

                        <div class="card-header">Add Sub Category</div>
                        <table class="table">
                            <thead>
                                <tr>
                                
                                <th>SubCategory Name</th>
                                <th>Subcategory Description</th>
                                    
                                </tr>
                            </thead>
                            <tbody class="resultbody">
                                <tr>
                                  
                                    <td>
                                        <input type="text" class="name form-control" name="sc_name[]" value="{{ old('sc_name') }}">
                                    </td>
                                    <td>
                                        <input type="text" class="fname form-control" name="sc_desc[]" value="{{ old('sc_desc') }}">
                                    </td>
                                    <td>
                                        <input type="button" class="btn btn-danger delete" value="Remove">
                                    </td>
                                </tr>

                            </tbody>
                        </table>    
                        <input type="button" class="btn btn-lg btn-primary add" value="Add New Item">

                    <button class="btn btn-success btn-lg " type="submit">SUBMIT</button>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection

```php

Controller
----------------------

dd($request);

        $category = new AddCategory();

        $category->c_date = $request->c_date;
        $category->c_name = $request->c_name;
        $category->c_desc = $request->c_desc;
      
        $category->save();

        $subcategory = new AddSubCategory();

        $subcategory->sc_name = $request->sc_name;
        $subcategory->sc_desc = $request->sc_desc;
        $subcategory->cat_id = $category->$id;
      
        $subcategory->save();

AKmahato started a new conversation How To Insert Records In Two Tables From Single Form

Suppose I have two tables Category(Parent table) and SubCategory(Child table). In Category table two fields c_name and c_desc and in SubCategory table sc_name, sc_desc and category_id i.e foreign key. I want to insert data in both table but while inserting data I want to send multiple data in SubCategory which is the child table. I'm sending data's from a single form. Please share some code

AKmahato started a new conversation How To Send Mail Automatically Based On Particular Time

I have one requirement i.e I have to send email automatically on a particular time I checked the documentation but I didn't get much more idea and I've checked google but everywhere I found cron job, which is only available on Linux/Unix but not on windows. I did see a video on YouTube about Task Scheduler but it's not working. If you have any tutorial or a code snippet it'll be very helpful. Thanks in advance!

28 Feb
6 months ago

AKmahato left a reply on How To Insert Multiple Records In Child Table

@TYKUS - Thanks for replying. I'm not getting errors related to this $request->input('sc_name') and $request->input('sc_desc') arrays. And also I've set $fillable in SubCategory Model. The code snippet you send doesn't contain cat_id which is a foreign key.

AKmahato started a new conversation How To Insert Multiple Records In Child Table

I have two tables Category and SubCategory I want to insert data in both tables from one single form but while inserting I want to insert multiple records in the child table. Insertion is happening but only in the parent table no data inserting in the child table.


Here is my code
--------------------------

public function store(Request $request)
    {
        //print_r($request);
        //dd($request);

        $category = new AddCategory();

        $category->c_date = $request->c_date;
        $category->c_name = $request->c_name;
        $category->c_desc = $request->c_desc;
      
        $category->save();

 $sc_name = $request->input('sc_name');
        $sc_desc = $request->input('sc_desc');

        $n = count($sc_name);
        dd($n);

        $subcategory = [];

        for($i=0; $i<$n; $i++){
            $data=[
                'sc_name' => $sc_name[$i],
                'sc_desc' => $sc_desc[$i],
                'cat_id' => $category->id 
            ];

            $subcategory[]=$data;
        }

        foreach($subcategory as $row){
            AddSubCategory::create($row);
        }
        return redirect()->back();


27 Feb
6 months ago

AKmahato started a new conversation How To Update Two Tables At A Time

I have two tables Category and Subcategory, and there one to many relations between them. I want to update category and subcategory records based on subcategory id. subcategory is my child table. I'm stuck, please help!

22 Feb
7 months ago

AKmahato started a new conversation Automated Email To Be Triggered After Certain Days.

I want to know how to get an automated email getting triggered to respective mail ids, with the data from the database, after a fixed time period.

p.s. it will be better if you would pass some code for the above

21 Feb
7 months ago

AKmahato started a new conversation SQLSTATE[42000]: Syntax Error Or Access Violation: 1068 Multiple Primary Key Defined (SQL: Alter Table `device_models` Add Primary Key `device_models_device_model_primary`(`device_model`))

I am trying to declare a varchar field as a primary key and that is a foreign key in a different table but when I migrating it's giving above error


This is my migration
--------------------------------

 public function up()
    {
        Schema::create('device_models', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->string('device_model', 32)->primary();
            $table->string('description', 100);
            $table->text('json');
            $table->timestamps();
        });
    }

And this is my child table
----------------------------------------
    
    public function up()
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->increment('id');
            $table->string('profile_name', 64);
            $table->string('device_model', 32)->nullable();
            // other fields
            $table->timestamps();
 
            $table->foreign('device_model')->references('device_model')->on('device_models');
        });
    }

This is my model
------------------------------
namespace App;

use Illuminate\Database\Eloquent\Model;

class DeviceModel extends Model
{
    protected $table = 'device_models';
 
    protected $primaryKey = 'device_model';
 
    public $incrementing = false;
    
    //public $keyType = 'string';
}


AKmahato left a reply on "Trying To Get Property 'id' Of Non-object (View: E:\LaravelProject\demoApplication-auth\resources\views\category\add_category.blade.php)"

I am trying to declare a varchar field as a primary key and that is a foreign key in a different table but when I migrating it's giving below error

SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined (SQL: alter table `device_models` add primary key `device_models_device_model_primary`(`device_model`))

This is my migration


 public function up()
    {
        Schema::create('device_models', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->string('device_model', 32)->primary();
            $table->string('description', 100);
            $table->text('json');
            $table->timestamps();
        });
    }

And this is my child table

     */
    public function up()
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->increment('id');
            $table->string('profile_name', 64);
            $table->string('device_model', 32)->nullable();
            // other fields
            $table->timestamps();
 
            $table->foreign('device_model')->references('device_model')->on('device_models');
        });
    }

This is my model
------------------------------
namespace App;

use Illuminate\Database\Eloquent\Model;

class DeviceModel extends Model
{
    protected $table = 'device_models';
 
    protected $primaryKey = 'device_model';
 
    public $incrementing = false;
    
    //public $keyType = 'string';
}


20 Feb
7 months ago

AKmahato left a reply on "Trying To Get Property 'id' Of Non-object (View: E:\LaravelProject\demoApplication-auth\resources\views\category\add_category.blade.php)"

Thanks for the help. We'll be meeting shortly because I am new to laravel and I'm facing so many issues. ?

AKmahato left a reply on Custom Sequence Number Generation For Order

@BOBBYBOUWMANN - I tried this way it's happening for the first time but when I insert the second record it should be incremented but it is not incrementing can you please help me resolve this

19 Feb
7 months ago

AKmahato left a reply on "Trying To Get Property 'id' Of Non-object (View: E:\LaravelProject\demoApplication-auth\resources\views\category\add_category.blade.php)"

@SNAPEY - ```php if ($category === null) {


 I wrote this line to check any id is available in database or not if it's there then execute if part

```php
      if ($category === null) {
        $nextId = 'MCGID0000001';
      }

which can give this value MCGID0000001

AKmahato left a reply on "Trying To Get Property 'id' Of Non-object (View: E:\LaravelProject\demoApplication-auth\resources\views\category\add_category.blade.php)"

But that error is showing in the helper file which I created for auto-populated value


Helper file 
------------------

<?php

use Illuminate\Support\Facades\Input;
use App\AddCategory;
if(!function_exists('autoincrement')) {
  function autoincrement() {

     // $student = Student::orderby('id', '=', Input::get('name'))->first();
       $category = AddCategory::orderby('id', 'desc')->first();
      $incrementid = $category->id;

      if ($category === null) {
        $nextId = 'MCGID0000001';
      }
      else {
        //$nextIntId = substr('MCGID0000001',5);
        $nextIntId = $incrementid + 1;
        //$nextId = 'MCGID'. sprintf("%07d", intval($nextIntId) + 1);
        $nextId = 'MCGID00000'.$nextIntId;
      }
      return $nextId;
    }
  }

?>
18 Feb
7 months ago

AKmahato started a new conversation "Trying To Get Property 'id' Of Non-object (View: E:\LaravelProject\demoApplication-auth\resources\views\category\add_category.blade.php)"

I am new in laravel I don't know how to resolve this error please help me to resolve this error.

Model
------------------

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class AddSubCategory extends Model
{
    protected $fillable = [
        'sc_name',
        'sc_desc',
        'cat_id'
      ];

      public function category(){
        return $this->belongTo('App\AddCategory');
      }
}


View
---------------------


@php
//$weekdays = weekdays();
$increment = autoincrement();
@endphp
@extends('layouts.app')

@extends('layouts.sidebar')

@section('title')
Add Category
@endsection

@section('content')

<div class="add_category">
    <!-- form card register -->
    <div class="card card-outline-secondary" id="card-category">
        <div class="card-header">
            <h3 class="mb-0">Add Category</h3>
        </div>
        <div class="card-body">
            <form method="POST" class="form" role="form" action="{{route('addcategory.store')}}">
                @csrf
                <div class="form-row">
                    <div class="form-group col-md-6">
                        <label for="c_id">Category ID</label>
                    <input class="form-control" name="c_id" value="{{ $increment }}" >
                    </div>
                    <div class="form-group col-md-6">
                        <label for="c_date">Category Date</label>
                        <!-- <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea> -->
                        <input class="form-control" name="c_date" type="text" value="{{date('Y-m-d')}}" required>
                    </div>
                    <div class="form-group col-md-6">
                        <label for="c_name">Category Name</label>
                        <!-- <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea> -->
                        <input class="form-control" name="c_name" type="text" required>
                    </div>
                    <div class="form-group col-md-6">
                        <label for="c_desc">Category Description</label>
                        <textarea name="c_desc" class="form-control" id="exampleFormControlTextarea1" rows="3" required></textarea>

                    </div>

                    <div class="form-group col-md-12">
                        <h3 class="mb-0 ">Add Sub Category</h3>
                    </div>


                    <!--form-row ended-->
                    <div class="form-row">
                        <div class="form-group col-md-4">
                            <label for="inputCity">Sub category name</label>
                            <input type="text" class="form-control" name="sc_name" required>
                        </div>
                        <div class="form-group col-md-4">
                            <label for="inputState">Sub category description</label>
                            <input type="text" class="form-control" name="sc_desc" required>
                        </div>
                        <div class="form-group col-md-4 btns">
                            <button class="btn btn-success " type="submit">Add</button>
                            <button class="btn btn-danger " type="submit">Remove</button>
                            
                        </div>
                        <div class="">

                        </div>
            
                <button class="btn btn-success btn-lg " type="submit">Add Category</button>

            </form>
        </div>
    </div><!-- /form card register -->
</div>
@endsection


Controller
---------------------------

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\AddCategory;
use App\AddSubCategory;
use DB;

class AddCategoryContoller extends Controller
{
    protected $category, $subcategory;

    public function __construct()
    {
        $this->category = new AddCategory();
        $this->subcategory = new AddSubCategory();
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $list= AddCategory::all();
        return view('category.categorylist', compact('list'));
    }

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

    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        // $request->validate([
        //     // 'c_id' => 'required',
        //     'c_date'=>'required',
        //     'c_name'=>'required',
        //     'c_desc'=>'required',
        //   ]);
        //   $category = new AddCategory([
        //     'c_date' => $request->get('c_date'),
        //     'c_name' => $request->get('c_name'),
        //     'c_desc'=> $request->get('c_desc'),
        //   ]);

        DB::beginTransaction();
        try
        {
            $category = $this->category->create([
                'c_id' =>$request->c_id,
                'c_date' => $request->c_date,
                'c_name' => $request->c_name,
                'c_desc' => $request->c_desc
            ]);
    
            $subcategory = $this->subcategory->create([
                'sc_name' => $request->sc_name,
                'sc_desc' => $request->sc_desc,
                'cat_id' => $category->id
            ]);
            
            if($category && $subcategory)
            {
                DB::commit();
                
            }
            else{
                DB::rollback();
            }
            return redirect()->back();
        }
        catch(Exceptio $ex){
            DB::rollback();
            return redirect()->back();
        }
       
    }

    /**
     * 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)
    {
       // $category = AddCategory::find($id);
      // echo "Id is---------------".$id;

        // $query = DB::table('add_categories')
        // ->where(['add_sub_categories.sc_id',$id])
        // ->join('add_sub_categories', 'add_categories.id', '=', 'add_sub_categories.cat_id')
        // ->where('add_categories.id', '=', '$id') //Join the child table
        //->select('add_categories.*','add_sub_categories.*' )
        // ->get();

      //  var_dump($query);
      
    //    $query=DB::table('add_categories')
    //    ->where(['add_sub_categories.sc_id',$id])
    //    ->join('add_sub_categories','add_sub_categories.cat_id' , '=' , 'add_categories.id')
    //    ->select('add_categories.*','add_sub_categories.*' );

    //    var_dump($query);
       
       //return view('category.category_edit', compact('query'));

    //    DB::table('add_categories')->where('id', $id)->orderBy('id')->chunk(100, function ($add_categories) {
    //     foreach ($add_categories as $user) {
    //         var_dump($user);
    //     }
    // });

    $query = DB::table('add_categories')
                ->where('id', $id)
                ->join('add_sub_categories','add_sub_categories.cat_id' , '=' , 'add_categories.id')
                ->select('add_categories.*','add_sub_categories.*' )
                ->get();

                //var_dump($query);

                return view('category.category_edit', compact('query'));

    }
    

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
     
        echo "This is the id :". $id;
        
            $request->c_name =$_POST['c_name'];
            $request->c_desc =$_POST['c_desc'];
            $request->sc_name =$_POST['sc_name'];
            $request->sc_desc =$_POST['sc_desc'];
        
        $category = AddCategory::find($id);

        AddCategory::where('id', $id)->update(array(
            'c_name' =>  $request->c_name,
            'c_desc' =>  $request->c_desc
        ));
        AddSubCategory::where('cat_id', $id)->update(array(
            'sc_name' =>  $request->sc_name,
            'sc_desc' =>  $request->sc_desc
        ));
       // return Redirect::route('all-customers')->with('message', 'You have successfully updated');
    
        
   
    }

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


Helper file where this error is occuring
---------------------------------------------------------------

<?php

use Illuminate\Support\Facades\Input;
use App\AddCategory;
if(!function_exists('autoincrement')) {
  function autoincrement() {

     // $student = Student::orderby('id', '=', Input::get('name'))->first();
       $category = AddCategory::orderby('id', 'desc')->first();
      $incrementid = $category->id;

      if ($category === null) {
        $nextId = 'MCGID0000001';
      }
      else {
        //$nextIntId = substr('MCGID0000001',5);
        $nextIntId = $incrementid + 1;
        //$nextId = 'MCGID'. sprintf("%07d", intval($nextIntId) + 1);
        $nextId = 'MCGID00000'.$nextIntId;
      }
      return $nextId;
    }
  }

?>