somnathsah

Experience

9,540

13 Best Reply Awards

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

8th August, 2018

somnathsah left a reply on Concatenate The Variable Value With String Message • 1 month ago

replace your return statment with this

return redirect()->back()->with('alert-success', 'orderd successfully inserted, Amount = Rs.' . $total_price); 

means replace ',' with '.'

27th July, 2018

somnathsah left a reply on Error In Maatwebsite To Export Excel File In Laravel • 1 month ago

@AbdulBazith try changing

$sheet->fromArray($sales_array);

with this one

$sheet->fromArray($sales_array, null, 'A1', false, false);

this will add header

somnathsah left a reply on Problem In Appending Html Data After Ajax Success With Laravel • 1 month ago

@AbdulBazith can you please share the final code you are using?

somnathsah left a reply on Problem In Appending Html Data After Ajax Success With Laravel • 1 month ago

@AbdulBazith try changing below line

 $.each (data, function (value) {

with this one

 $.each (data, function (key, value) {

this will work

somnathsah left a reply on Problem In Appending Html Data After Ajax Success With Laravel • 1 month ago

@AbdulBazith can you please try console.log(data) before the loop, so that i can have a look of the data object.

26th July, 2018

somnathsah left a reply on Problem In Table Display In Javascript In Laravel • 1 month ago

you can change your code to something like this. this should work.

var res='''
 $.each (data, function (value) {
        
            res +=
            '<tr>'
        '<td>'+value.id+'</td>'
        '<td>'+value.date+'</td>'
        '<td>'+value.time+'</td>'
        '<td>'+value.no_of_litre+'</td>'
        '<td>'+value.note+'</td>'
        '</tr>';

   });

20th July, 2018

somnathsah left a reply on Laravel 5.6 "Page Not Found" Problem • 2 months ago

If you have setup new LARAVEL application then you need to generate the application key. You use the following commands

php artisan cache:clear
php artisan key:generate

4th May, 2018

somnathsah left a reply on Laracasts Forum Does Not Handle CSRF Token Expiry Gracefully; Login Fails Silently • 4 months ago

@cbj4074 we can implement a JS code which will logout from the site after the session time gets expired, redirect to login page and replace the login page with button something like "login again"

somnathsah left a reply on Laracasts Forum Does Not Handle CSRF Token Expiry Gracefully; Login Fails Silently • 4 months ago

Yes @jirdw this is about the forum :-), but in case someone want to handle this error.

somnathsah left a reply on Laracasts Forum Does Not Handle CSRF Token Expiry Gracefully; Login Fails Silently • 4 months ago

Here is the solution for handling CSRF token expiration gracefully.

https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e

somnathsah left a reply on Error While Updating Composer • 4 months ago

You need to install all the php extension required for this laravel version .

Below is the reference for installaing ext-mbstring, similarly you can install all other missing extensions. https://askubuntu.com/questions/491629/how-to-install-php-mbstring-extension-in-ubuntu

somnathsah left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 4 months ago

@nero create a validator object of input element like below

$validator = Validator::make($data, [
    'email' => 'required|email',
]);

Suppose you have any other input field like email then create the validator object and use that as below.

$validatedData =$validator->sometimes([ 'min_salary' , 'max_salary' ], 'required', function($data){
    return $data->max_salary >$data->min_salary;
});

$validatedData will have a response that it is validated or not

somnathsah left a reply on How To Validate The Maximal Salary To Be Greater Than The Minimum Salary? • 4 months ago

You can use the following validation rule.

$validatedData = $request->validate([ 'min_salary' , 'max_salary' ], 'required', function($data){
    return $data->max_salary >$data->min_salary;
});

9th January, 2018

somnathsah left a reply on Laravel Insert Method Getting Error In Sql Server • 8 months ago

Thanks @topvillas for your help. But is there any other laravel method which can insert bulk records and not using the bind param way. So that I can overcome sqlserver restriction.

7th January, 2018

somnathsah left a reply on Laravel Insert Method Getting Error In Sql Server • 8 months ago

Yes @rob897 I checked, this is the restriction from sql server side.

How can I use laravel insert method to insert large numbers of records, having more then 2100 bind params in sql server database?

5th January, 2018

somnathsah started a new conversation Laravel Insert Method Getting Error In Sql Server • 8 months ago

Hi,

I am using sql server as my database and need to insert large number of records . But while using below code

 AgentData::insert($data);

getting error

 SQL Server supports a maximum of 2100 parameters.  
SQLSTATE[IMSSP]: Tried to bind parameter number 2101.  SQL Server supports a maximum of 2100 parameters

above code is working fine when I break my array into chunk and execute insert statement for each chunk.

Thanks in advance,

26th December, 2017

somnathsah left a reply on Is There Any Method In Eloquent To Delete A Part Of Data Or Append A Part In Json Data Type Column? • 8 months ago

@insight You can cast your json to array and use that json value as normal value of object and can perform add/delete operation as a normal column.

for your reference : https://laravel.com/docs/5.5/eloquent-mutators#array-and-json-casting

somnathsah left a reply on Password Reset Route Not Found • 8 months ago

@omarsow94 verify that your App\User model implements the Illuminate\Contracts\Auth\CanResetPassword contract.

and check that you password_reset table in place.

for reference please check https://laravel.com/docs/5.5/passwords#introduction

somnathsah left a reply on Password Reset Route Not Found • 8 months ago

@omarsow94 Could you please share the link you are getting in the email?

somnathsah left a reply on Password Reset Route Not Found • 8 months ago

somnathsah left a reply on Password Reset Route Not Found • 8 months ago

Route for resetting password is

Route::post('/password/reset', 'Auth\[email protected]');

So change your

<form action="" method="post">

to

<form action="/password/reset" method="post">

This might work for you.

somnathsah left a reply on Advise On How To Approach A Situation (Jobs, Scheduler, Multi Workers ) • 8 months ago

@Yahav in cron job you can include the following command

* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

This is the beginning part of the laravel scheduler. When cron job will run this command laravel check all the due job and run those jobs.

please read this : https://laravel.com/docs/5.5/scheduling#introduction it might help you

somnathsah left a reply on Advise On How To Approach A Situation (Jobs, Scheduler, Multi Workers ) • 8 months ago

If you want to use any package you can the use the following package. https://packagist.org/packages/dusterio/laravel-aws-worker

somnathsah left a reply on Advise On How To Approach A Situation (Jobs, Scheduler, Multi Workers ) • 8 months ago

You can achieve this with laravel scheduler and cron job on linux or scheduler task on windows. What you need to do is store scheduling time and details in database for a job, and run the laravel scheduler for interval of a minute or something which will check any scheduling job and run that job at specified time.

please follow the link : https://laravel.com/docs/5.5/scheduling

20th December, 2017

somnathsah left a reply on Laravel Excel : Remove Extra Space From File Header And Values • 9 months ago

Thanks @Dry7, Yes I saw this earlier, this is good solution. But is there anything which I add in config of excel or direct call any method on my reader object to remove the extra spaces from header and values.

somnathsah left a reply on Skip Take Error • 9 months ago

Please see the bellow link, It may solve your problem. https://stackoverflow.com/questions/30805123/laravel-using-skip-and-take-limiting-query.

somnathsah started a new conversation Laravel Excel : Remove Extra Space From File Header And Values • 9 months ago

Hi,

I am using Laravel excel package to read excel file. I want to know, Does it provide any method which I can use to remove extra spaces from all header and values of the file? I don't want to use function like trim for each rows.

Thanks in advance,

4th December, 2017

somnathsah left a reply on Change End Of Line Character When Generating Code With Php Artisan Make Commands • 9 months ago

you can use php constant PHP_EOL , which is platform independent.

15th November, 2017

somnathsah left a reply on Convert Mysql Query To Laravel ORM Query • 10 months ago

You can create query something like below: {code} DB::table('payments', function($query) { $query->join('tickets') ->on('payments.receipt', '=', 'tickets.receipt'); }) ->select('payment', 'total', 'transid') ->get(); {code} reference : https://laravel.com/docs/5.5/queries

6th October, 2017

somnathsah left a reply on Inserting Multiple Records At Once • 11 months ago

@jerauf please use print_r to print the $publish_on and paste the result here, So that we can check that correct array is being created.

28th September, 2017

somnathsah left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does • 11 months ago

I think you need to pass auth object to your anonymous function as you have passed the thread.

somnathsah left a reply on Auth()->id() Doesn't Work; But If I Hardcode It, It Does • 11 months ago

Try using below instead of auth()->id(), it might work.

 Auth::id();

26th September, 2017

somnathsah left a reply on Artisan Not Working After Updating PHP • 11 months ago

I think this library is missing so you can try installing this by bellow command

composer require laravelcollective/html

somnathsah left a reply on Artisan Not Working After Updating PHP • 11 months ago

Run the below command after running composer. This might work

php artisan optimize

8th September, 2017

somnathsah left a reply on Execute Artisan Command From Code • 1 year ago

Here is the example by which you can call artisan command programmatically

https://laravel.com/docs/5.4/artisan#programmatically-executing-commands

somnathsah left a reply on How To Pass A POST Data Array From One View To Another? Or How To Correctly Submit And Display Information Simultaneously? • 1 year ago

You can send the view file from first method like something below

response()->json([view::make('viewFile', [
            'data'  => $request
]

Here you can pass the $request object to the second view file and can access in second view.

1st September, 2017

somnathsah left a reply on Problem In Route • 1 year ago

You can run the below command and verify if correct route is being created.

php artisan route:list

And also check no duplicate route has been created and you don't have any redirect call for the route localhost/quiz in method for route localhost/site/quiz

19th July, 2017

somnathsah left a reply on TokenMismatchException On Form Post From Inside A Table • 1 year ago

@kfirbe Yes, I used the same solution for for one of my previous task.

But for now there is two scenarios.

  1. One for which all the element of the table which will get posted. for this I have added form element at top before table tag.
  2. For one more case I need to post some element of the same above table not the complete table. So I want add this element into another form. something like below.
<form>
    <input type="hidden" name="_token" value="{{csrf_token()}}">
    
    <table>
        // ...
       <form>
            <input type="hidden" name="_token" value="{{csrf_token()}}">
            //input element
       </form>
    </table>
</form>

somnathsah left a reply on TokenMismatchException On Form Post From Inside A Table • 1 year ago

Thanks @kfirba for your reply. I fixed the closing tag, but issue is still persist. Actually the issue is with nesting of form inside of table. I have faced the same issue previously but that time i found some alternate way.

but this time I am unable to find any other way. So if anyone has workaround for nesting form inside a table which does not throw TokenMismatchException, that will be very helpful for me.

somnathsah started a new conversation TokenMismatchException On Form Post From Inside A Table • 1 year ago

Hi,

I am getting TokenMismatchException while posting a form which is present in table row.

below is the part of code.

   <table class="table table-hover table-bordered table-striped text-center">
            <thead style="background-color: #e0e0e0;"> 
                <th>Key Name</th>
                <th>Status</th>
            </thead>
            <tbody>
                    <tr class="goalRow">
                       <form id='clientGoalsRow' method='post' action='{{ url("client_goals/save_program_goals") }}' class="form-horizontal">
                        <input type="hidden" name="_token" value="{{ csrf_token()}}">
                        <td>
                            {{ $value['keyName'] }}
                        </td>
                        <td>
                            <div class="form-group">
                                <select id="goalStatus" name="goalStatus[]" onchange="" class="goalStatus form-control">
                                    <option value="enabled"  @if ($value['status'] == 'enabled') {{ "selected" }} @endif>Enabled</option>
                                    <option value="disabled" @if ($value['status'] == 'disabled') {{ "selected" }} @endif>Disabled</option>
                                </select>
                            </div>
                        </td>
                    </tr>
            </tbody>
        </tbale>

NOTE : Can not put form before the table. And need to post this part of code only not complete table which also has some other form element.

Thanks, Somnath

10th July, 2017

somnathsah left a reply on How To Search For Multiple Words? • 1 year ago

@derrickrozyay I tried query like below and it returned the result as you are needed

select * from table where $term like concat('%',column, '%')

So, what I wanted to say is reverse all your where clause like below

where(DB::raw(concat('%', $term, '%') , 'LIKE', 'items.description')

NOTE : I am using sql server for my database please find similar function for concat in your corresponding DB.

15th June, 2017

somnathsah left a reply on Select Statement Set Null Column Defualt Value To 0 • 1 year ago

@okawei I am not using model instance for querying. I am using DB::table() to do the query. for example I am creating a query like this.

DB::table('test')
->select(DB::raw('isnull(column, 0)'))->get();

So, isnull function is not working, My database is SQL server.

somnathsah started a new conversation Select Statement Set Null Column Defualt Value To 0 • 1 year ago

Hi,

I am creating a query and executing it in sqlserver. I want to set null column value to 0 in select statement using method like coalesce, isnull but it is throwing error. "can not access empty property".

any help will be much appreciated.

Thanks, Somnath

30th May, 2017

somnathsah left a reply on 5.4 Month Validation Error • 1 year ago

I ran the same code which you have posted. it works fine for me. Please check the data type of month field if you are getting this dynamically.

or you can try checking printing the for each value from 01 to 12 and can check if data type is same for all. you can do the var_dump for that as below.

var_dump($data['month']);

somnathsah left a reply on Blade Textarea With Php Tags • 1 year ago

put your code in tag {!! !!}. like below.

{!! !!}

Code in this tag will not get parsed.

somnathsah left a reply on Undefined Variable • 1 year ago

I Think you are missing to send variable $comments from controller to view.

somnathsah left a reply on How To Fetch Original Array Value • 1 year ago

@Vikrant if your above array is a part of Illuminate\Support\Collection object then toArray() method should work on this object.

here are list of all method which you can use on the collection object. https://laravel.com/docs/5.4/collections#available-methods

Edit Your Profile
Update

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