AKmahato

AKmahato

Member Since 3 Months Ago

Experience Points 1,050
Experience Level 1

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 Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

15 Mar
3 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
3 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
3 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
3 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
3 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 left a reply on How To Insert Records In Two Tables From Single Form

@MUSHOOD - ```php

This is my view

@extends('layouts.master')

@section('title') Add Category @endsection

@section('content')

{{-- ----------------------------------------------- --}}

$(function () { $('.add').click(function () { //var n = ($('.resultbody tr').length - 0) + 1; var tr = '' + ''+ ''+ //''+ // ''+ //''+
                '<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();
    });

    // $('.resultbody').delegate('.obtainedmarks , .totalmarks', 'keyup', function () {
    //     var tr = $(this).parent().parent();
    //     // var obtainedmarks = tr.find('.obtainedmarks').val() - 0;
    //     var totalmarks = tr.find('.totalmarks').val() - 0;

    //     // var percentage = (obtainedmarks / totalmarks) * 100;
    //     // tr.find('.percentage').val(percentage);
    // });
});

{{-- ------------------------------------------------------------- --}} @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="form-group col-md-12">
                            <h3 class="mb-0 ">Add Sub Category</h3>
                        </div>

                    </div>
                    <!--form-row ended-->

                    <div class="form-row" id="afterAddMore">
                        <div class="form-group col-md-4">
                            <label for="sc_name">Sub category name</label>
                            <input type="text" class="form-control" name="sc_name[]" required>
                        </div>
                        <div class="form-group col-md-4">
                            <label for="sc_desc">Sub category description</label>
                            <input type="text" class="form-control" name="sc_desc[]" required>
                        </div>
                        <div class="form-group col-md-4 btns">
                            <input type="button" value="Add" id="addMore" class="btn btn-success add_field_button">
                        </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

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
3 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();


AKmahato left a reply on "Argument 1 Passed To Illuminate\Database\Grammar::parameterize() Must Be Of The Type Array, Null Given, Called In E:\LaravelProject\metrofeedback_v1\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php On Line 853

@MUNAZZIL - After using dd($request) this I got this response


Request {#42 ▼
  #json: null
  #convertedFiles: null
  #userResolver: Closure($guard = null) {#219 ▶}
  #routeResolver: Closure() {#227 ▶}
  +attributes: ParameterBag {#44 ▶}
  +request: ParameterBag {#43 ▼
    #parameters: array:6 [▼
      "_token" => "MLQQDDm6dd4r5tyGj3XZPwT5Z6nmunp3pSP0LxmD"
      "c_date" => "2019-02-28"
      "c_name" => "Dog"
      "c_desc" => "Pet Animal"
      "sc_name" => array:1 [▼
        0 => "Husky"
      ]
      "sc_desc" => array:1 [▼
        0 => "Siberian Dog"
      ]
    ]
  }
  +query: ParameterBag {#50 ▶}
  +server: ServerBag {#46 ▶}
  +files: FileBag {#47 ▶}
  +cookies: ParameterBag {#45 ▶}
  +headers: HeaderBag {#48 ▶}
  #content: null
  #languages: null
  #charsets: null
  #encodings: null
  #acceptableContentTypes: null
  #pathInfo: "/category"
  #requestUri: "/category"
  #baseUrl: ""
  #basePath: null
  #method: "POST"
  #format: null
  #session: Store {#264 ▶}
  #locale: null
  #defaultLocale: "en"
  -isHostValid: true
  -isForwardedValid: true
  basePath: ""
  format: "html"
}

AKmahato started a new conversation "Argument 1 Passed To Illuminate\Database\Grammar::parameterize() Must Be Of The Type Array, Null Given, Called In E:\LaravelProject\metrofeedback_v1\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php On Line 853

I'm trying to insert data into two different tables from one single form but it showing above error.


This is my controller
-----------------------------------
public function store(Request $request)
    {
        $input = $request->all();

        $category = new AddCategory();
        $category->c_date = $input['c_date'];
        $category->c_name = $input['c_name'];
        $category->c_desc = $input['c_desc'];

        $subcategory = new AddSubCategory();
        $subcategory->sc_name = $input['sc_name'];
        $subcategory->sc_desc = $input['sc_desc'];
        $subcategory->cat_id = $category->id;
     
        $category->save($request->all());
        $category->subCategory()->save($subcategory);
}

27 Feb
3 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
3 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
3 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 below 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
3 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
3 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
4 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