saurabhd

Laravel Developer at Individual Contributor

Hire Me

Experience

19,490

28 Best Reply Awards

  • Member Since 1 Year Ago
  • 0 Lessons Completed
  • 0 Favorites

16th August, 2018

saurabhd left a reply on Form To URL • 1 month ago

You should try this

<form method="POST" action="{{ route('lcountries/search') }}">
    <input type="text" id="autocomplete-input" class="autocomplete" name="country_name">
    <label for="autocomplete-input">Autocomplete</label>
    <input type="submit" value="Send">
</form>

14th August, 2018

saurabhd left a reply on How To Get Third Model, Where Three Model Have Relationed Together? • 1 month ago

You should try this:

User::with('places.category')->get();

saurabhd left a reply on Method App\Http\Controllers\UserController::validate Does Not Exist. There Is The Problem With Validation Email But I Cant Find Solution • 1 month ago

You should try this:

<?php

namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Route;


class UserController extends Controller
{
    public function getSingup(){
        return view('user.singup');
    }
    public function postSingup(Request $request){
         $this->validate($request,[
            'email'=> 'required|email|unique:users',
            'password'=> 'required|min:4'
        ]);

         $input = $request->all();
        $user = new User($input);
        $user -> save();

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

3rd August, 2018

saurabhd left a reply on Laravel 5.6 Register Doesn't Work, No Redirect And No Errors (edited Register Fields) • 1 month ago

Your Mistake is the same route name in web.php

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

So, First you change your same route name.

2nd August, 2018

saurabhd left a reply on Multiple Image Uploading • 1 month ago

Please follow this link

1st August, 2018

saurabhd left a reply on Sending Request To A Post Controller Function From Another Controller Function • 1 month ago

Your barcode_approve expects a Request object, not an array. While you could instantiate a new Request object and potentially inject your fake inputs, I would consider that a bad practice.

Whenever you find yourself trying to call a controller method from another controller method, it usually means you have logic that can be extracted, either to a model, a trait, or in the case of the same controller, a separate protected function.

The purpose of a controller is to be the transport method, you shouldn't have much business logic in it, extract logic to the models when you can.

saurabhd left a reply on Package Installation • 1 month ago

Please run command as below

composer require codesleeve/laravel-stapler

Note: codesleeve/laravel-stapler package not working in laravel 5.6 version. Please see this link

31st July, 2018

saurabhd left a reply on Store Form Data To Mysql Database ?? • 1 month ago

@VikasSwami : After you should create one controller with one function and generate post route for new function like:


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Storage;
use Session;
use Config;
use Mail;
use URL;
use Response;
use Input;
class UserController extends Controller
{
    public function registerUser(Request $request)
    {
        $user = new User;

        $user->username = Input::get('username');

        $user->save();  
    }
    
   
}

saurabhd left a reply on Store Form Data To Mysql Database ?? • 1 month ago

@VikasSwami : Please display your errors

saurabhd left a reply on Store Form Data To Mysql Database ?? • 1 month ago

First, create a Model for your table:

/* app/models/User.php */ class User extends Eloquent { protected $table = 'my_users'; }

Second, insert data by instantiating your Model:

$user = new User;

$user->username = Input::get('username');

$user->save();

21st May, 2018

saurabhd left a reply on Excel In Laravel • 4 months ago

Version 3.0 of that package doesn't handle imports yet. Release date for this feature is unknown. See this post for more details: https://medium.com/@maatwebsite/laravel-excel-lessons-learned-7fee2812551

I suggest you switch to version 2.*

16th March, 2018

saurabhd left a reply on Trying To Get Property Of Non-object Sending Data To The View • 6 months ago

Please show your blade file code

20th December, 2017

saurabhd left a reply on Config::set() Database Connection Not Persisting. • 9 months ago

You will go with helper type. Let's create one in app/Helpers/DatabaseConnection.php.

namespace App\Helpers;
use Config;
use DB;

class DatabaseConnection
{
public static function setConnection($params)
{
config(['database.connections.onthefly' => [
driver' => $params->driver,
host' => $params->host,
username' => $params->username,
password' => $params->password
]]);

return DB::connection('onthefly');
}
}

And your controller file to use this.

use App\Helpers\DatabaseConnection;
...

$conParameter = Database::find( 1 );
$connection = DatabaseConnection::setConnection($conParameter);
$users = $connection->select(...); 

21st November, 2017

saurabhd left a reply on How To Show Count Of Array In Blade And If Count Equal To 1 Then Show The Value? • 10 months ago

Please show more code blade file and controller.

17th November, 2017

saurabhd left a reply on Undefined Variable: Forum • 10 months ago

Please check my updated answer

saurabhd left a reply on Gettting Un Defined Variable Error • 10 months ago

Please change you route like because same name route issue so please try this:

Route::get('/categories', function () { return view('categories'); }); 

To

Route::get('catagory/categories', function () { return view('categories'); }); 

saurabhd left a reply on Undefined Variable: Forum • 10 months ago

You should try this:

public function index()
    {
        $forum = Forum::all();
        return view('forum.index',compact('forum'));
    }

OR

public function index()
    {
        $forum = Forum::all();
        return view('forum.index')->with(['forum'=>$forum]);
    }

saurabhd left a reply on Gettting Un Defined Variable Error • 10 months ago

Please put some view code for categories.blade.php and controller function for display categories.blade.php

saurabhd left a reply on NotFoundHttpException In Compiled.php Line 8889 • 10 months ago

Please run below command in terminal/cmd:


php artisan install (if vendor folder not created)
php artisan composer dump-autoload
php artisan config:cache
php artisan config:clear
php artisan cache:clear
php artisan route:clear

Hope this work for you!!!

15th November, 2017

saurabhd left a reply on Radio Button • 10 months ago

You should try with below example:

<input type="radio" name="gateway" value="paypal" <?php if(Input::old('gateway')== "paypal") { echo 'checked="checked"'; } ?> id="paypal" checked class="gateway"> Paypal

saurabhd left a reply on How To Display Name Of Relationships Instead ID On Update? • 10 months ago

Please display AddMember and Activist model.

saurabhd left a reply on SQLSTATE[HY000]: General Error: 1005 Can't Create Table • 10 months ago

Please follow this link

saurabhd left a reply on How To Fix Undefined Variable: Task (View: C:\Users\LIlan\Desktop\acxian\resources\views\files\form.blade.php) In Laravel 5.2 • 10 months ago

Please put the function for display form.blade.php view

14th November, 2017

saurabhd left a reply on Namespace Vs Use? • 10 months ago

Please follow this link

13th November, 2017

saurabhd left a reply on Select Option Property Not Working • 10 months ago

You should try this:


<select name="notificationtype" required class="form-control">
    <option value="sms" {{($template->type=='sms') ? 'selected="selected' : ''}} > SMS </option>
    <option value="email" {{($template->type=='email') ? 'selected="selected' : ''}}> Email </option> 
</select>



saurabhd left a reply on How To WhereHas When Use BelongsToMany Relation? • 10 months ago

I think you should change your Subject model like

public function User() { return $this->belongsToMany(User::class); }

9th November, 2017

saurabhd left a reply on Blade Syntax Error With Empty String Variable • 10 months ago

Please give output as per below code:

 print('<pre style="color:red;">');
 print_r($data);
 print('</pre>');
 exit;



saurabhd left a reply on Blade Syntax Error With Empty String Variable • 10 months ago

you should try this:


<input class="form-control" type="text" id="nameEng" name="nameEng" value="{{!empty($tagTrans['en']) ? $tagTrans['en'] : ' ' }}" />



8th November, 2017

saurabhd left a reply on Undefined Property: Illuminate\Database\Eloquent\Collection::$fb_enable • 10 months ago

Please show your view file bcard_web where you put fb_enable variable.

saurabhd left a reply on Undefined Property: Illuminate\Database\Eloquent\Collection::$fb_enable • 10 months ago

Please show your settings result like:

public function getBussinesscard()
{
    $domain = $_SERVER['SERVER_NAME'];
    $user = User::where('domain', $domain)->first();

    $settings = Setting::where('user_id', $user->id)->get();

    print('<pre style="color:red;">');
    print_r($settings);
    print('</pre>');
    exit;
    
    return view('soulfy.bcard_web', ['user' => $user, 'settings' => $settings]);
    
    }

saurabhd left a reply on When The Same Attribute Name Is In Other FormRequest. • 10 months ago

Are you use name as label then you should change your lang like:

// in my image...
'attributes' => [
    'nameA' => 'Name in FormRequestA',
    'nameB' => 'Name in FormRequestB'
]


28th October, 2017

saurabhd left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'postqs_id' Cannot Be Null (SQL: Insert Into `reply_qs` (`reply`, `postqs_id`, `updated_at`, `created_at`) Values (fff, , 2017-10-28 06:03:30, 2017-10-28 06:03:30)) • 10 months ago

@sakti You are getting this error as you are not getting value of $request->get('postqs_id').

You will get it only if postqs_id is passed in URL.

So before the query, you need to check, whether $request->get('postqs_id') has some value or not. If you are not getting any value in this, you need to display error message to user.

Thanks

16th October, 2017

saurabhd left a reply on Problems With Nested Relationships • 11 months ago

You can use:

return $this->belongsTo('App\Car', 'car_id', 'id');

instead of

return $this->belongsTo('App\Car', 'car_id');

in your Rate model relationship

saurabhd left a reply on Stripe • 11 months ago

You want to try rebooting the server. If that doesn't work, you'll probably want to write into (Support)[https://support.stripe.com/email] about this

saurabhd left a reply on After Adding Socialite Package Laravel 5.5 Login Stops Working • 11 months ago

I had the same problem on localhost:8000 (php artisan serve). Maybe it's coincidence, but try on "clean browser" , other than you used with previous development. For me it worked.

It seems that the problem is with cookies from development with previous Laravel versions, on the same url.

13th October, 2017

saurabhd left a reply on How To Update From Array • 11 months ago

You should try this:

$datas = array(array('id'=>1,'person'=>20),array('id'=>2,'person'=>40),array('id'=>3,'person'=>100));
foreach($datas as $data){
     DB::table('yourtablename')->where('id',$data['id'])->update(array('person'=>$data['person']));


}

Hope this work for you

12th October, 2017

saurabhd left a reply on QueryException SQLSTATE[42S02]: Base Table Or View Not Found • 11 months ago

Please follow this link

31st August, 2017

saurabhd left a reply on Laravel Email Error Failure Code And Reason • 1 year ago

@Dry7: Thanks for reply but I need to display error code with original reason while mail sending operation getting failed as website.

Let me know if you can help me in this area.

saurabhd left a reply on Laravel Package To Get The Width And Height Of Uploaded Video • 1 year ago

For server side Have ever tried (getID3)[https://github.com/JamesHeinrich/getID3), Using this you can get every detail of video via analyze() method at server side.

For client side Let's say you have HTML like: <input type="file" id="load-file" /><button type="button" id="done-button">Get me dimensions</button>

Use jQuery FileReader like:

<script src="//cdn.jsdelivr.net/jquery/2.1.4/jquery.js"></script>
    <script>
(function ($) {
  $('#done-button').on('click', function () {//You can this even handle as you want...
    var file = $('#load-file')[0].files[0];
    var reader  = new FileReader();
    var fileType =  file.type;
    console.log("type", fileType);
    reader.addEventListener("load", function () {
      var dataUrl =  reader.result;
      var videoId = "videoMain";
      var $videoEl = $('<video id="' + videoId + '"></video>');
      $("body").append($videoEl);
      $videoEl.attr('src', dataUrl);

      var videoTagRef = $videoEl[0];
      videoTagRef.addEventListener('loadedmetadata', function(e){
        console.log(videoTagRef.videoWidth, videoTagRef.videoHeight);
      });

    }, false);

    if (file) {
      reader.readAsDataURL(file);
    }
  });

})(jQuery);
    </script>

saurabhd started a new conversation Laravel Email Error Failure Code And Reason • 1 year ago

Can anyone help me out on how to get the error code and reason when email fail to send?

I know about failures() method provided with laravel but I want is error failure code and reason.

Any help would be appreciated.

26th August, 2017

saurabhd left a reply on Trying To Get Property Of Non-object In Laravel 5.4 • 1 year ago

You should try this:

public function show()
        {
            $show=Post::latest()->first();
        return view('posts.show',compact('show'));     
    }

Hope this work for you!!!

saurabhd left a reply on How To Upload Image In Laravel • 1 year ago

You should try this:

$image = $request->file('cover_image');
$filename = $image->getClientOriginalName();

$year = Carbon::now()->year;


$uploaded = $image->move(public_path().'upload/images/products/'.$year, $filename);

$product = Product::create(array_merge($request->all(), ['cover_image' => 
          $filename]));

Hope this work for you !!!

25th August, 2017

saurabhd left a reply on Delete Method Not Allowed • 1 year ago

You should try this way:

Route::get('recherche/occasion/{occasion}', '[email protected]')->name('recherche.occasion.destroy');


<a class="glyphicon glyphicon-remove" href="{{ route('recherche.occasion.destroy', [$oc]) }}" data-method="delete"></a>

Hope this work for you!!!

saurabhd left a reply on PDOException : Could Not Find Driver. Running Wamp And Laravel 5.4 • 1 year ago

You should install PDO on your server. Edit your php.ini (look at your phpinfo(), "Loaded Configuration File" line, to find the php.ini file path). Find and uncomment the following line (remove the ; character):

;extension=pdo_mysql.so

Then, restart your Apache server. For more information, please read the documentation.

saurabhd left a reply on How To Write This Query • 1 year ago

Which query?

saurabhd left a reply on Count Only If Property Equals 1 • 1 year ago

You should try this way:

$rsltExercise = $exercise->exerciseAlternatives()->where('correct', 1)->get();

$cntExercise = count($rsltExercise);

OR

$exercise->exerciseAlternatives()->where('correct', 1)->count();

Hope this work for you!!!

saurabhd left a reply on Settings Session Flash Without $request • 1 year ago

Try this simple way:

In UserController:

public function makeAdmin($id)
{
    $user = DB::table('users')->find($id);

    $user->admin = 1;
    if ($user->save()) {
        Session::flash('success', 'User assigned admin role');
    } else {
        Session::flash('danger', 'could not be assigned admin role.');
    }

    return back();
}

In blade

<div class="flash-message">
    @foreach (['danger', 'success'] as $msg)
        @if(Session::has($msg))
            <p class="alert alert-{{ $msg }}">{{ Session::get($msg) }}</p>
        @endif
    @endforeach
</div>

That's it...

saurabhd left a reply on PDOException: SQLSTATE[HY000] [2002] Connection Refused In Unit Testing Via Phpstorm • 1 year ago

Just try with DB_HOST=localhost may this help you

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.