saurabhd

Member Since 2 Years Ago

Ahmedabad

Laravel Developer at Individual Contributor

Experience Points 174,280
Experience Level 35

720 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 1495
Lessons
Completed
Best Reply Awards 34
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.

13 Aug
1 week ago

saurabhd left a reply on Index View Isn't Showing

Your layout file path like:

resources/views/layouts/frontLayout/front_design.blade.php

And your index file path like:

/resources/views/index.blade.php
12 Aug
1 week ago

saurabhd left a reply on Adding Items To An Array In A Collection

You should try this:

$coll = new Collection([
    'metrics' => [],
    'dimensions' => [],
]);

$newArray = ["test"=>"details"];

$coll = array_merge($coll,$newArray);
08 Aug
1 week ago

saurabhd left a reply on Getting The Selected Value In A Form Dropdown.

You should try this:

<select name="speakers_id" id="selPsgSpeaker">
                            <option value="" ></option>
                            @foreach($rsltSpeaker AS $krySpkr => $dataSpkr)
                              <option value="{{$dataSpkr->spkrID}}" >{{$dataSpkr->speakerRealName}}</option>
                            @endforeach
                          </select>

saurabhd left a reply on How To Display In Blade Views A Single Record Only (Laravel)

You should try this:

Controller file

$counter2 = Call::where('counter_id', '2')
                    ->latest('updated_at')
                    ->first();

View File

<div style="border-bottom:1px solid #ddd">
          @forelse($counter2 as $two)
          <span id="num2" style="font-size:85px; font-weight:bold;line-height:1.45">
          @if(isset($two->letter))
          {{ $two->letter }}[email protected]{{ $two->number }}</span><br>
          <small id="cou2" style="font-size:35px">Counter 2</small>
          @empty
          <span id="num1" style="font-size:85px;font-weight:bold;line-height:1.45">N/A</span><br>
          @endforelse
        </div>

saurabhd left a reply on How Can I Use Two Different Template For Same Route In Laravel

You should try this:

use Auth;

if(Auth::check()){ 
  return view('loginview');
} else {
  return view('normalview');
}

saurabhd left a reply on Don't Create Field In Database

You should try this:

if(isset($request['repair_report_buro']) && !empty($request['repair_report_buro'])){
$delivery->comments_buro()->create([
        'name' => auth()->user()->firstname,
        'user_id' => auth()->user()->id,
        'message' => $request['repair_report_buro'],
        'icon' => 'fa fa-commenting-o',
        'style' => $position->style,
    ]);
}
05 Aug
2 weeks ago

saurabhd left a reply on How To Delete Item From Session

Please use forget() for remove item from session like:

$request->session()->forget('abc.xyz.124');

// or use global helper
session()->forget('abc.xyz.124');

Please review this link

saurabhd left a reply on How To Use A Trait In Another Trait ?

You should try like this:

trait A {
    function a() {
        echo "a trait\n";
    }
}

trait B {
    use A;
    function b() {
        echo "b trait\n";
    }

    function a() {
        echo "a fcn from trait B\n";
    }
}

trait C {
    use B;
    function a() {
        echo "a fcn from C trait\n";
    }

    function b() {
        echo "b fcn from C trait\n";
    }
}


class AClass {
    use A;
}
01 Aug
2 weeks ago

saurabhd left a reply on Laravel Controller

You should try this:

Route::resource('admin/tbooking','TbookingController', ['except' => 'store']);

saurabhd left a reply on Ignore Blank Field On Update

You should try this:

// All posted data except token and id
$data = request()->except(['_token','id']);

// Remove empty array values from the data
$result = array_filter($data);

// update record
DB::table($table)->where('id', $arr)->update($result);

saurabhd left a reply on Route In Http

Please follow this link

saurabhd left a reply on Get Parent Of Parent In Laravel Eloquent

You should try this:

$departments= Departments::with(['organizations','divisions'])->get();

foreach($departments as $department){

    echo $department->organizations->title;

}
31 Jul
2 weeks ago

saurabhd left a reply on Compare Only Month And Year In Db And Fetch Records

You should try like this:

$post = Mjblog::whereYear('created_at', '=', $year)
              ->whereMonth('created_at', '=', $month)
              ->get();

saurabhd left a reply on ERR_TOO_MANY_REDIRECTS

Because you have to created same name route (i.e software_new/public/) so please update route and also please follow this link

30 Jul
3 weeks ago

saurabhd left a reply on "Undefined Offset: 0"

You should try this:

public function store(Request $request, SiteSetting $sitesetting){

  foreach(array_except($request->toArray() , ['_token'  , 'submit']) as $key => $req) {
      $sitesettingupdate = $sitesetting->where('nomsetting' , $key)->get();
      $sitesettingupdate->fill(['valeur'=>$req])->save(); 

  }
          return Redirect::back()->withFlasMessage('les parametres sont bien modifieé');

}

saurabhd left a reply on Personal Access Token

jwt.php in config folder

29 Jul
3 weeks ago

saurabhd left a reply on Personal Access Token

Please set your expiration time in jwt.php file in ttl variable.

'ttl' => 60,

saurabhd left a reply on Redirect After Login

You should try this like:

public function redirectTo(Request $request)
    {
        if(Auth::check()) {
            if(Auth::user()->is_admin) {
                return redirect('admin');
            }
            if(Auth::user()->user) {
                return redirect('home');
            }
        }
        return redirect('/');
    }

saurabhd left a reply on Checking If Unique Comination Of Fields Exist In Database

Please update your validation with unique field.

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

        'authorName'=>'required|min:3|unique:author',
        'authorAge'=>'required|numeric|min:16|max:120|unique:author',
        'authorAddress'=>'required|min:3|unique:author',
        'bookName'=>'required|min:2',
        'date'=>'required|date',

    ]);
---------------------
---------------------
}
26 Jul
3 weeks ago

saurabhd left a reply on Object Of Class Illuminate\Routing\Redirector Could Not Be Converted To String

You should try this like:

ob_start();
include 'test.php';
$string = ob_get_clean();

saurabhd left a reply on Route Not Defined

Please update link like:

\ create.blade.php

<a class="btn btn-primary" href="{{ route('client.createjobs.jobs') }}"<> Back</a>
25 Jul
3 weeks ago

saurabhd left a reply on Dynamic Prefix Routing

You should try this:

Route::group(['prefix' => 'front'], function() {
    authRoutes(); 
    Route::get('/', '[email protected]');
});

Route::group(['prefix' => 'front1'], function() {
    authRoutes(); 
    Route::get('/', '[email protected]');
});

Route::group(['prefix' => 'admin'], function() {
    authRoutes(); 
    Route::get('/', '[email protected]');
});

function authRoutes()
{
    Route::get('login', 'Auth\[email protected]')->name('login');
}

saurabhd left a reply on Laravel Passport

You should follow this link

23 Jul
4 weeks ago

saurabhd left a reply on Filter Model Entry Laravel Collection

You should try this:

$allUsers = Users::query();
        foreach ( array_keys($arrayColumns) as $key ) {
            if ($key === 'column' || $key === 'Two' || $key === 'Three') {
        $allUsers->where($key, 1)
        }
            if ($key === 'date' || $key === 'dateTwo' ) {
        $allUsers->where($key, '!=',null)
        }
    }

$allUsers->all();
22 Jul
4 weeks ago

saurabhd left a reply on Route [fileUpload] Not Defined. (View: C:\wamp64\www\ckcmain12\resources\views\layouts\dashboard.blade.php)

Your route like:

Route::group(['middleware' => 'web'], function () { 
 Route::get('fileUpload', function () { return view('fileUpload'); }); Route::post('fileUpload', ['as'=>'fileUpload','uses'=>'[email protected]'])->name('fileUpload');

});
15 Jul
1 month ago

saurabhd left a reply on If Condition Is Not Working

You should try this:

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

        'title' =>'required',
        'link'=>'required',
        'date_time'=>'required',
        'featured'=>'mimes:jpeg,pdf,docx,png:5000',
        'file'=>'mimes:jpeg,pdf,docx,png:5000',
        'content'=>'required',
        'category_id'=>'required',
    ]);

  
    $data = [

        //'link'=>$request->link,
        'title'=>$request->title,
        //'content'=>$request->content,
        'category_id'=>$request->category_id,
        'slug'=>str_slug($request->title),
        'date_time'=>Carbon::parse(strtotime($request->date_time))->format('Y-m-d'),
        ];

    if($request->link)
    {
        $link=request('link');
        $data['link']=Post::create($data);
    }
    if($request->content)
    {
        $link=request('content');
        $data['content']=Post::create($data);
    }

    if ($request->featured)
    {
        $featured = request('featured');
        $file_name = time() . $featured->getClientOriginalName();
        $featured->move('uploads/posts', $file_name);
        $data['featured'] = 'uploads/posts/'.$file_name;
    }
   
    if ($request->hasFile('file')) {
        $file = $request->file('file');
        $file_name = time() . $file->getClientOriginalName();
        $file->move('uploads/posts', $file_name);
        $data['file'] = 'uploads/posts/'.$file_name;
    }
  
   $post = Post::create($data);
    Session::flash('success', 'New Blog has been Published on Website for Particular Menu');
    return redirect()->back();

}
12 Jul
1 month ago

saurabhd left a reply on Display Name Based On User ID

Your function code like:

$vqosces = Vqosce::with('users')->get();

Your view file code like:

 @foreach ($vqosces->reverse() as $vqosce)

                            <th class="min-width-60"><a href="\vqosces\{{ $vqosce->id }}">{{ $vqosce->candidate }}</a></th>
                            <th class="min-width-60">{{ $vqosce->name }}</th>
                            <th class="min-width-80">{{ $vqosce->result }}</th>
                            <th class="min-width-80">{{ $vqosce->created_at->format(config('app.date_format')) }}</th>
                            <th class="min-width-80"><a href="\vqosces\{{ $vqosce->id }}\edit">Edit</a></th> 
                        </tr>
                    </tr>
                @endforeach


11 Jul
1 month ago

saurabhd left a reply on All() Vs Get() - Laravel Eloquent

User::all() and User::get() will do the exact same thing.

all() is a static method on the Eloquent\Model. All it does is create a new query object and call get() on it. With all(), you cannot modify the query performed at all (except you can choose the columns to select by passing them as parameters).

get() is a method on the Eloquent\Builder object. If you need to modify the query, such as adding a where clause, then you have to use get(). For example, User::where('name', 'David')->get();

saurabhd left a reply on Undefined Variable: Products For PDF

You should try this:

public function downloadPdf()
{

    $products = Product::all();

    $pdf = PDF::loadView('admin.pdf.product-pdf', compact('products'));

    return $pdf->download('catalogue.pdf');
}

saurabhd left a reply on Redirecting A Route

You should try this:


return view('restaurants.show',compact($restaurant));

Note: restaurants.show is not route but it's path for view show file

10 Jul
1 month ago

saurabhd left a reply on StoreAs Not Working

You should try this:

$relPathAndName = $file->storePubliclyAs('/public/products', $product_id.'.jpg');

return str_replace('public', 'storage', $relPathAndName);

//Then to use it later: 
asset('storage/products/product_id.jpg')
27 Feb
5 months ago

saurabhd left a reply on Call To Undefined Method Illuminate\Database\Query\Builder::on()

You should try this:

$user = Users::where(function($q) use ($username) {

$q->where('username', $username)

->orWhere('email', $username);

})

->where('isactive', 1);

Note: You can use on method with Advanced Join Clauses

saurabhd left a reply on Undefined Variable Only Showing Online Server, But On Localhost Works Good

You should try this:


 $role_permissions = DB::table('role_user')
            ->where('user_id', '=', $user_id)
            ->get();

 $user_role = '';
$user_status = '';

if(!empty( $role_permissions)){

        foreach ($role_permissions as $role) {
            $user_role = $role->role_id;
        }

        if ($user_role == 1) {
            $user_status = 'Admin';
        } else {
            $user_status = 'User';
        }
} else {
     $user_status = 'User';
}

saurabhd left a reply on Method Not Allowed When Delete Record In Laravel

You should try this:

<form action="{{ url('product/destroy', [$row->id]) }}" method="post">
          {!! csrf_field() !!}
     <button type="submit" class="btn btn-outline-danger btn-block">Delete</button>
</form>
26 Feb
5 months ago

saurabhd left a reply on Typeahead.js:36 Uncaught TypeError: $(...)

It have nothing to do with the amount of data but the fact that typeahead.js is not found

You should add your js like:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/js/typeahead.js"></script>
<script>
  // ...
21 Feb
5 months ago

saurabhd left a reply on One To Many - First Results And Foreach For Subobjects

@greeenone : Ohh sorry

just put directly your below code without foreach in your view file like:

     {{$folder->name}}

Note : name field use just for example so put your original field

saurabhd left a reply on One To Many - First Results And Foreach For Subobjects

@greeenone : this name field use for example so please put your original field and try

saurabhd left a reply on One To Many - First Results And Foreach For Subobjects

You should try this:

In your controller

$folder = ManagementFolders::where('reference', $reference)->first();

In your view file

@foreach($folder as $property)

     {{$property->name}}
@endforeach  

saurabhd left a reply on Use POST Request For Update Routes

POST

HTTP.POST can be used when the client is sending data to the server and the server will decide the URI for the newly created resource. The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.

PUT

HTTP.PUT can be used when the client is sending data to the server and the client is determining the URI for the newly created resource. The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI.

PATCH

HTTP.PATCH can be used when the client is sending one or more changes to be applied by the server. The PATCH method requests that a set of changes described in the request entity be applied to the resource identified by the Request-URI. The set of changes is represented in a format called a patch document.

20 Feb
6 months ago

saurabhd left a reply on How To Use Json Encode On Following Data

You should try this:

$arrResult = array (
    ['_method'] => PATCH,
    ['_token'] => pp7bjIqWRL8hatrNyh4ZPtNeb8i6lpjD51QCzFMw,
    ['permission'] => Array
        (
            ['Admission'] => Array
                (
                    ['listing'] => 'on',
                    ['Edit'] => 'on',
                    ['Delete'] => 'on',
                    ['Add'] => 'on',
                    ['Print'] => 'on',
                    ['Pdf'] => 'on'
                ),

            ['Announcement'] => Array
                (
                    ['listing'] => 'on',
                    ['Edit'] => 'on',
                    ['Delete'] => 'on',
                    ['Add'] => 'on',
                    ['Print'] => 'on',
                    ['Pdf'] => 'on',
                ),

            ['Blogs'] => Array
                (
                    ['listing'] => 'on',
                    ['Edit'] => 'on',
                    ['Delete'] => 'on',
                    ['Add'] => 'on',
                    ['Print'] => 'on',
                    ['Pdf'] => 'on'
                )
      )
);

$arrResult = json_encode($arrResult);

14 Feb
6 months ago

saurabhd left a reply on How I Search Data From Multiple Colunm In Database Using Array

Your query like:

$admission = Admission::where('name','like','%'.$search.'%')
                                           ->orWhere('city','like','%'.$search.'%')
                                          ->orWhere('present_school','like','%'.$search.'%')
                                             ->paginate($records);

saurabhd left a reply on "The File "/public/plots/20180807_10.56.01_raster11x21_1549956869_FGD.png" Does Not Exist"

Your function like this:

public function download($id){
        $graph=graph::find($id); 
        $file_path = public_path().'/plots/'.$graph->DateiName;
         return response()->download($file_path );
}

saurabhd left a reply on How To Search Data From More Then One Field In Laravel

You should try this:

public function index(Request $request)
    {
        $search = \Request::get('search');
        
        $records = config('constant.displayPageRecords');
        $admission = Admission::where('name','like','%'.$search.'%')->orWhere('address','like','%'.$search.'%')->orWhere('phone','like','%'.$search.'%')->paginate($records);
        return view('admin.admission.index',['admission'=>$admission,'records'=>$records]);
    }

saurabhd left a reply on How To Use Constant Value In Laravel Controller

You should try this:

Please add use Config; in your controller and please check

13 Feb
6 months ago

saurabhd left a reply on Get Number Of Week Day In Carbon

You should try this:

use Carbon\Carbon;

$dayOfTheWeek = Carbon::now()->dayOfWeek;

saurabhd left a reply on Mysql Connection Problems

You should try this:

please update .env file for database configuration

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=dbuser
DB_PASSWORD=dbpass