Inquisitive

Inquisitive

Member Since 1 Year Ago

Experience Points 7,530
Experience Level 2

2,470 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 34
Lessons
Completed
Best Reply Awards 5
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.

06 Jun
1 month ago

Inquisitive started a new conversation How To Make Payment And Booking Concurrent.

I am trying to make a futsal booking system. Here, a user selects the date as his/her preference and make payments to book it.

But, here I got a problem what if the payment is failed? How can I make this transaction atomic?

This means, book the system if payment is successful or make the payment if the booking is successful. What is the best approach for dealing with this? Any idea would be appreciated.

01 Oct
9 months ago
22 Sep
9 months ago

Inquisitive left a reply on Introducing FOREIGN KEY Constraint 'my_list_user_user_id_foreign' On Table 'my_l Ist_user' May Cause Cycles Or Multiple Cascade Paths. Specify ON DELETE NO ACTION Or ON UPDATE NO ACTION, Or Modify Other FOREIGN KEY Constraints.

@ssquare I have seen that you are using cascade on delete even for the user who access it. I don't think you need to delete the list even if the user who is not the creator but only have access to it. So update following

$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

with no action

$table->foreign('user_id')->references('id')->on('users')->onDelete('no action');

Inquisitive left a reply on Refering To Public Path

You could use

{{url('/images/icon-check.png')}}

Even if you are accessing through localhost/project/public.

And if this is already solved, please mark it as solved.

Inquisitive left a reply on Introducing FOREIGN KEY Constraint 'my_list_user_user_id_foreign' On Table 'my_l Ist_user' May Cause Cycles Or Multiple Cascade Paths. Specify ON DELETE NO ACTION Or ON UPDATE NO ACTION, Or Modify Other FOREIGN KEY Constraints.

It might be saying this because it is connected to the user's table by two means creating a cycle. What about removing created by from my_lists and instead adding a is_owner column to the pivot table?

21 Sep
10 months ago

Inquisitive left a reply on SQLSTATE[08001]: [Microsoft][ODBC Driver 13 For SQL Server]TCP Provider: No Connection Could Be Made Because The Target Machine Actively Refused It. (SQL: Select Top 1 * From [settings] Where [name] = Site_title And [settings].[deleted_at] Is Null)

down vote To resolve this problem, change the Server authentication from Windows Authentication mode to SQL Server.

To change the authentication mode to SQL Server and Windows, follow these steps:

  1. On the computer that is running Microsoft SQL Server, open SSMS.
  2. In the Server name box, type the name of the instance of SQL Server. For default, you can use dot(.) or (local)
  3. After connecting, in the Object Explorer window pane, right-click the SQL Instance and select Properties.
  4. Click Security under the select a page options.
  5. Change Server Authentication to SQL Server and Windows Authentication and click ok.
  6. Click ok to the prompt message about changes not taking effect until the instance is restarted.
  7. Right-click the SQL Instance in the Object Explorer and select Restart. Click Yes to restart the instance and if prompted to restart the SQL Server Agent.

After these changes have been applied and the SQL Instance has been restarted, attempt to verify the ODBC connection with the ‘sa’ account credentials.

Then try to connect through

<?php
$serverName = ".";
$connectionInfo = array( "Database"=>"kpi_db","UID"=>"sa", "PWD"=>"");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

If it successfully connected, remove port and fill other credentials.

Also, make sure you have copied extensions to ext folder and php.ini both in apache and php folder. As one is responsible for command and other is for the server. Let me know if any error arises.

13 Sep
10 months ago

Inquisitive left a reply on Image Horizontal Alignment Appears Disordered, After Browser Refreshes

@ralphdns there are different possible ways, from inline-block, float, grid, etc. You need to provide your code. So, other can shows you where are you doing it wrong. You can inspect those elements and look is these images taking a full row, or the parent container is taking a full row or pushing another element to next row.

Also, you are saying you are facing this problem only on foreach case. So, also don't forget to check if you are missing to close any tags on those foreach case.

Inquisitive left a reply on Jquery Datatable Throws Error As Soon As I Implement Laravel Pagination Links

Try script:


$('#datatableID').DataTable({
                "paging":   false,
            });

And remove that customer links from and place it below the table. As

........
........
........
</table>
{{ $users->links() }}
22 Aug
10 months ago

Inquisitive started a new conversation Bet Way To Retrieve Count Of Total Rows With And Without Limit

I am doing something like:

$rows = DB('table_name')
        ->where..... 
        ->where.....
        .....
        .....
        ....
        ->offset(0)
        ->limit(50)
        ->get()

I am integrating this with jquery serverside datatable. So, instead of repeating this whole code as follows to get count. Is there any other best way, so that I can stop myself from repeating things. As this where clasue has a very big list.

$count= DB('table_name')
        ->where..... 
        ->where.....
        .....
        .....
        ....
        ->count();
20 Aug
11 months ago

Inquisitive left a reply on Need Help To Convert General Sql Query To Query Builder

If I were you, at first I would start with something like $data = $request->all() and pass $data instead of $request. Looking surfacely, I think that imploding is the one that is making it string. And you can't pass string when it is looking for an array.

$street_arr_str = implode("','",$street_arr);
$query->whereIn('base_voters.home_street_address_1',$street_arr_str)
                          ->orWhereIn('base_voters.home_street_address_2',$street_arr_str);

While fixing, start with just one join and related query with that join. Gradually increase join and query. I think in this way you could get what you are looking quite easily.

17 Aug
11 months ago

Inquisitive left a reply on Unable To Query Through Many To Many Relationship

@Tray2 Thank you for your time and suggestion. I will consider that from now on.

Inquisitive left a reply on Unable To Query Through Many To Many Relationship

I have fixed it. I need to replace hasMany with belongsToMany

    public function custom_lists()
    {
        return $this->belongsToMany('App\Models\Custom_list','custom_pivot_users', 'custom_list_id', 'user_id');
    }

Inquisitive left a reply on Unable To Query Through Many To Many Relationship

Okay, I have figured this out. I need to changed the order of user_id and custom_list_id

    public function custom_lists()
    {
        return $this->hasMany('App\Models\Custom_list','custom_pivot_users', 'user_id', 'custom_list_id');
    }

Inquisitive left a reply on Unable To Query Through Many To Many Relationship

Could you point me exactly what I might be doing wrong. I get that it is looking for column custom_pivot_users inside custom_lists table. But, could you tell me why is it looking inside custom_lists table. It might not be with exact naming conventions such as two table singular name in alphabetical order separated by underscore which could be custom_list_user but besides that could you point me where I have done it wrong.

16 Aug
11 months ago

Inquisitive started a new conversation Unable To Query Through Many To Many Relationship

Custom_list.php

    public function owners()
    {
        return $this->belongsToMany('App\Models\User','custom_pivot_users','custom_list_id','user_id');
    }
    public function custom_lists()
    {
        return $this->hasMany('App\Models\Custom_list','custom_pivot_users', 'custom_list_id', 'user_id');
    }

Pivot table: custom_pivot_users custom_list_id,user_id

Problem:

$user = User:find($id);
print_r($user->custom_lists);
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'custom_lists.custom_pivot_users' in 'where clause' (SQL: select * from `custom_lists` where `custom_lists`.`custom_pivot_users` is null and `custom_lists`.`custom_pivot_users` is not null and `custom_lists`.`deleted_at` is null)
29 Jul
11 months ago

Inquisitive left a reply on AJAX Post: MethodNotAllowedHttpException No Message Laravel 5.4

date_establishment:date_establishment, _token: csrf_token }

But before that you need to define csrf_token somewhere before that. With something like below

var csrf_token = "{{csrf_token()}}";

That above quotation works on php file

14 Jul
1 year ago

Inquisitive left a reply on Use WhereNotIn To Check If There Is Id Or Not In A Specific Column

I don't know, but it looks like quite opposite scenario. I feels like I require instead lie where $ids does not contain $id

Something like

->where delete_by_org doesnot contain $id

Is there anything in laravel to solve this

13 Jul
1 year ago

Inquisitive left a reply on Use WhereNotIn To Check If There Is Id Or Not In A Specific Column

Yeah, that is quite straight forward. But, with another table, i think there should be some relation.

base_record_id | deleted_by_org 12 | 1 12 | 2 13 | 3 13 | 1

Now, how can I check this, as actually I am retrieving data on base voter table

Inquisitive left a reply on Use WhereNotIn To Check If There Is Id Or Not In A Specific Column

Ok, how can I handle it with eloquent if i created another one to many table

Inquisitive left a reply on Use WhereNotIn To Check If There Is Id Or Not In A Specific Column

That is just an example, it might also have [1] or can be even null. Actually, I am trying to store organization id, such as if an organization delete a records, this should not be visible to any member of that organization but should be visible to member of other organization. So, if organization 1 deletes it, delete_by_org will be filled with [1]. Again, if is deleted by org by 2 the previous data will be updated as [1,2]

Inquisitive started a new conversation Use WhereNotIn To Check If There Is Id Or Not In A Specific Column

Currently, I am using serverside jquery data table. So, here is the snippet for it.

        if(empty($request->input('search.value'))){
            $posts = Base_voter::offset($start)
            ->limit($limit)
            ->orderBy($order,$dir)
            ->get();
            $totalFiltered = Base_voter::count();
        }else{
            $search = $request->input('search.value');
            $posts = Base_voter::where('name_voter', 'like', "%{$search}%")
            ->orWhere('name_first','like',"%{$search}%")
            ->orWhere('name_last','like',"%{$search}%")
            ->orWhere('home_street_address_1','like',"%{$search}%")
            ->orWhere('mailing_street_address_1','like',"%{$search}%")
            ->orWhere('home_address_city','like',"%{$search}%")
            ->orWhere('mailing_address_city','like',"%{$search}%")
            ->offset($start)
            ->limit($limit)
            ->orderBy($order, $dir)
            ->get();
            $totalFiltered = Base_voter::where('name_voter', 'like', "%{$search}%")
            ->orWhere('name_first','like',"%{$search}%")
            ->orWhere('name_last','like',"%{$search}%")
            ->orWhere('home_street_address_1','like',"%{$search}%")
            ->orWhere('mailing_street_address_1','like',"%{$search}%")
            ->orWhere('home_address_city','like',"%{$search}%")
            ->orWhere('mailing_address_city','like',"%{$search}%")
            ->count();
        }       

But, here i have one column 'deleted_by_org' which store data as in format [1,2,5]. Now, I want to get only those records which is equivalent to where !in_array($org_id,[1,2,5]).

That means, don't fetch this record, if $org_id = 1 or 2 or 5.

Inquisitive started a new conversation Store An Array Of JSON Data In Mysql Database

 $arr = [
            'organization_id' => $organization_id,
            'user_id' => $user_id
        ];
        $data = json_encode($arr);

With above code I am able to insert data as

{"organization_id":1,"user_id":1}

But, next time I run the same function (with different organization and user id value), I want to store this data as follow:

[{"organization_id":1,"user_id":1}, {"organization_id":2,"user_id":5}]

How can I achieve this.

28 Jun
1 year ago

Inquisitive left a reply on Treat NULL As Equal To Empty ''

@BishoyWagih I don't think orWhere is the solution. I think it will just skip the condition and also, return row even if single condition is met. Please, correct me if I am wrong on that thoughts.

Inquisitive started a new conversation Treat NULL As Equal To Empty ''

I want to returns true no matter either the data is NULL or empty. This might not explain well about my requirements. So, let me explain you, with code snippets.

 $existing = Voter::where('name_last', $base_voter_arr['name_last'])
                        ->where(function($query) use ($base_voter_arr) {
                            if (array_key_exists('phone', $base_voter_arr)) {
                                $query->where('phone', $base_voter_arr['phone']);
                            }
                            if (array_key_exists('email', $base_voter_arr)) {
                                $query->where('email', $base_voter_arr['email']);
                            }
                        })->first();

Here, for an example phone value on database is NULL but value on $base_voter_arr['phone] is (empty string) i.e (''). So, it is not returning the row. So, how can I deal with so that this conditions becomes true and returns the row successfully.

22 Jun
1 year ago

Inquisitive started a new conversation Laravel SoftDelete Is Not Working. (Deleting Permanently)

User Migration:

        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password',191);
            $table->rememberToken();
            $table->softDeletes();
            $table->timestamps();
        });

Column deleted_at has been successfully created.

User Model:

use Illuminate\Database\Eloquent\SoftDeletes;
.   . 
.   .
.   .
.   .
class User extends Authenticatable
{
    use Notifiable;

    protected $fillable = [
        'name', 'email', 'password',
    ];
    protected $dates = ['created_at','updated_at','deleted_at'];
.   .
.   .
.   .
}

Controller (Destroy)

$user = User::find($id);
$user->delete();

On other models it is working fine, but not in this user model. However, on other models, I have used use softdeletes inside class. But, for user models, it could not find softdeletes trait inside class so need to added above class.

08 Jun
1 year ago

Inquisitive left a reply on Laravel 5.6 App To Shared Hosting

Copy and paste the following after

$download_files= DownloadFile::where('contract_id',$contract->id)->get();

and show what it outputs

    

echo "Contract";   
echo 'pre>';
   print_r($contract);
echo '<pre>'

echo "Contract Status";

echo 'pre>';
   print_r($contractstatus);
echo '<pre>'

echo "client";
echo 'pre>';
   print_r($client);
echo '<pre>'

echo "defined_task";
echo 'pre>';
   print_r($defined_task);
echo '<pre>'

echo "employy";
echo 'pre>';
   print_r($employy);
echo '<pre>'

echo "subdefined_task";
echo 'pre>';
   print_r($subdefined_task);
echo '<pre>'

echo "download_files";
echo 'pre>';
   print_r($download_files);
echo '<pre>'
exit();

Also, make sure you have mentioned

use App/Client;

like these, Capital Client not client

Inquisitive left a reply on Teacher And Student Table Registered With Same Email. How Fix It

Use a single table for all users, and store all the information related to a person. Then, provide them different roles such as teacher,student and Admin. Based, on if one person can have multiple roles or not, you can design database structure.

Inquisitive left a reply on Laravel 5.6 App To Shared Hosting

So, what is the error? You are not being specific.

Ther might be a lot of cases, maybe there is no data to populate foreach loop, also on many cases when you work on windows on the local machine, it might not be case sensitive, which would not be the case on Linux machine on the server.

Inquisitive left a reply on Add A Column In A Table With A Form

  1. Create a form and send data such as name, type, and length etc
  2. On Controller, use those data to create field.

So here is an example for form

<form method=""POST action="{{url('/)}}">
@csrf

<label>Field Name</label>
<input type="text" name="name">

<label>Field Type</label>
<input type="text" name="type">

<label>Field Length</label>
<input type="text" name="length">

<button type="submit">Submit</button>

On Controller

$table_name = 'name_of_table_to_add_column';

        try { 
            Schema::table($table_name, function (Blueprint $table) use ($request->type, $request->length, $frequest->name) {
                $table->$request->type($request->name, $request->length)->nullable();
            });
        } catch(\Illuminate\Database\QueryException $ex){ 
            dd($ex->getMessage()); 
        }

Inquisitive left a reply on How To Pass DB Array Values To Blade View

paste following code above @foreach($meetings as $meeting) and show what it outputs

echo '<pre>';
print_r($meetings);
echo '</pre>';
exit();
06 Jun
1 year ago

Inquisitive left a reply on How To Save Multiple Array? I M Getting Undefined Offset: 0

Did you change just for the name case? You need to change for all gsl_title, gsl_email and so on.

Inquisitive left a reply on How To Save Multiple Array? I M Getting Undefined Offset: 0

It means to access those data you need to do something like:

$fg->name = $inputs['fg_name'][$i];

Inquisitive left a reply on Equivalent Of Return View('path',compact('data1', 'data2', 'data3' )) In Ajax Success.

I don't know if this is what you are looking, but I could show you how you can tackle this problem.

  1. Return just the filename from controller on completion of upload.
return response()->json(array('success' => true, 'filename'=>$filename));
  1. On success submit a form, but before that just place a form on html and make it hiddden. So, on success, on ajax request, submit that form with filename to another controller.
                success:function(data){
                    if(data.success === true){
                        $("#modal_id").modal('hide');
                        $('<input />').attr('type', 'hidden') .attr('name', "filename") .attr('value', data.filename).appendTo('#hidden_form_id');
                        $('#hidden_form_id').submit();
                    }
                }
  1. From that second controller, just return data as in other methods with return view and compact.

Inquisitive left a reply on How To Save Multiple Array? I M Getting Undefined Offset: 0

paste following code just before the for loop and make something like

echo '<pre>';
print_r($inputs);
echo '<pre>';
exit();
for($i = 0; $i< count($inputs['fg_name']); $i++){
....

And paste, what does it return. Are you sure $inputs has [0] offset? Let's check it at first.

Inquisitive left a reply on Controller Edit Method (Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message)

<form method="POST" action="{{action('[email protected]')}}">
    @csrf
    @method('PATCH')
</form>

Try with something like this and make sure route is defined as:

Route::patch('path', '[email protected]');

OR

Route::resource('path', 'MeetingsController');
30 May
1 year ago

Inquisitive left a reply on File Upload Progress In Modal Box.

It will be little difficult to give the exact answer without looking at your form, but I am trying to provide you some idea.

$(document).ready(function(){
        $('form').submit(function(event){

            event.preventDefault();
            var formData = new FormData($(this)[0]);
            $.ajax({
                headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') },
                url: "{{url('abc/xyz')}}",
                data: formData,
                type: 'post',
                cache: false,
                xhr: function() {
                    var xhr = new window.XMLHttpRequest();
                    $("#modal_id").modal('show');
                    xhr.upload.addEventListener("progress", function(evt) {
                        if (evt.lengthComputable) {
                            var percentComplete = evt.loaded / evt.total;
                            percentComplete = parseInt(percentComplete * 100);
                            $('.uploadProgressBar').attr('aria-valuenow',percentComplete).css('width',percentComplete + '%').text(percentComplete + '%');
                            if (percentComplete === 100) {
                                $("#modal_id").modal('hide');
                            }

                        }
                    }, false);

                    return xhr;
                },
                processData: false,
                contentType: false,
            });

        });
    });

And modal box:

<div class="modal fade" id="modal_id" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header bg-success">
        <h5 class="modal-title text-white" id="exampleModalLabel">Uploading</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
          <div class="progress" style="height: 2em;">
            <div class="progress-bar uploadProgressBar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary uploading_close_btn" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
22 May
1 year ago

Inquisitive started a new conversation Check Validation Based On Value Not Key Laravel

I am doing a mapping function at a stage so the data send through ajax request will be like :

[row] => Array
        (
            [0] => name_first
            [1] => name_last
            [2] => email
            [3] => phone
            [4] => address
    )

Now , I want to make that name_last as required. Is there any way to do this through laravel's built in method.

If there is not built in method(then only), let's suppose I do it manually, such as

            if(!in_array('name_last',$request->row)){
                // Handle error exactly same as it is handeled by default method
        // I mean generate error in exactly same (json)format exactly as
        // $this->validate($request,[
                //'name_last' => 'required',
                // ]);
            }

Reminding again this is ajax request.

So far, I tried with something like but with no success

                return response()->json([
                    'status' => '-1',
                    'message' => 'name_last is required'
                ]);

Also with

                    $arr = array(
                        'status' => '-1',
                        'message' => 'name_last required',
                    );
                    echo json_encode($arr);
                    exit();

My ajax code:

        $.ajax({
                    url: "{{url('admin/contribution_data')}}", // point to server-side PHP script
                    data: data_form,
                    type: 'POST',
                    cache: false, 
                    success: function(data) {
                        var obj = JSON.parse(data);
                        console.log(obj.status);
                        if(obj.status == '1')
                        {
                            waitingDialog.message('Rows Processed:'+obj.offset); 
                            csv_ajax(parseInt(obj.offset));
                        }
                        else
                        {
                            waitingDialog.hide();
                            $("#csvImportComplete").modal('show');

                            $('.modal_close_btn').click(function(){
                                location.href = "{{url('admin/contribution_data')}}"    
                            });
                            return;
                        }
                                
                    },
                    error: function(data) {
                        var obj = JSON.parse(data.responseText);
                        $( "#AjaxModalBoxTitle" ).append( obj.exception );
                        $( "#AjaxModalBoxContent" ).append( obj.message );
                        if(obj.errors){
                            $.each(obj.errors, function() {
                                $.each(this, function(k, v) {
                                    $( "#AjaxModalBoxContent" ).append( '<br>'+v );
                                });
                            });
                            
                        }
                        $("#AjaxModalBox").modal('show');
                        waitingDialog.hide();
                        $('#progress-bar-close').show();
                    }
                });

Currently, following code successfully could display the error

         $this->validate($request,[
                'name_last' => 'required',
                ]);

But I want to check either that value is present instead of key.

14 May
1 year ago

Inquisitive left a reply on Get Path Of File Stored In Storage/apps/files/data/filename.csv

Update

$csv_file_path = storage_path('files/data/').$request->filename;

to

$csv_file_path = storage_path(app/'files/data/').$request->filename;

You are missing app

Inquisitive left a reply on Invalid Argument Supplied For Foreach()

After lists = [];

paste following codes and reply what it returns:

echo '<pre>';
print_r($request->input('hobbies'));
echo '</pre>';
exit();

Inquisitive left a reply on Invalid Argument Supplied For Foreach()

After lists = [];

paste following codes and reply what it returns:

echo '

';
print_r($request->input('hobbies'));
echo '
'; exit();

Inquisitive started a new conversation Unable To Upload Large File Around 70MB On Server

Everything works fine on local, but when I tried to upload a file to the server, it takes some time and shows the following error:

This site can’t be reached The connection was reset. Try:

Checking the connection Checking the proxy and the firewall Running Windows Network Diagnostics ERR_CONNECTION_RESET

Currently, my code looks like:

    $extension = $request->file('import_file')->getClientOriginalExtension(); // getting excel extension
    $dir = 'assets/files/contribution_data/';
    $filename = uniqid().'_'.time().'_'.date('Ymd').'.'.$extension;
    $request->file('import_file')->move($dir, $filename);

What might I be doing wrong here? How can I get rid of this problem?

09 May
1 year ago

Inquisitive left a reply on Add Is-invalid Class In Laravel Form Model Dynamically.

{{ Form::password('old_password',array('required','autofocus','class'=>(($errors->has("old_password"))?"is-invalid":"").' form-control ')) }}

I have fixed these things. Thanks for the idea, rin4ik

Inquisitive left a reply on Add Is-invalid Class In Laravel Form Model Dynamically.

@ rin4ik not working. At first, it says syntax error as there is one extra ) . Even after removing that its showing errror "array to string conversion"

Inquisitive started a new conversation Add Is-invalid Class In Laravel Form Model Dynamically.

Currently I am trying with something like this:

{{ Form::password('old_password',array('required','autofocus','class'=>'form-control')) }}

Now I want to implement the following ternary operator in class. But I haven't achieved any success so far.

$errors->has("old_password") ? "is-invalid" : ""

How can I achieve this.

04 May
1 year ago

Inquisitive left a reply on Maximum Function Nesting Level Of '256' Reached, Aborting!

Hey guys, I have fixed this issues, it was just typos error.

I was using $this->store('store',Post::class); instead of $this->authorize('store',Post::class);

Inquisitive started a new conversation Custom Error Validation In Laravel 5.6

I am trying to create a custom error validation in laravel. What I did:

  1. php artisan make:rule CurrentPassword

  2. update passes in app\rules\currentpassword.php

public function passes($attribute, $value) { $current_pass = \Auth::user()->password; return \Hash::check($current_pass, $value); }

  1. tried to validate in controller

$this->validate($request,[ 'old_password' => 'required|new CurrentPassword', ]);

Got error:

Method Illuminate\Validation\Validator::validateNewCurrentPassword does not exist

03 May
1 year ago

Inquisitive started a new conversation Maximum Function Nesting Level Of '256' Reached, Aborting!

I am using laravel 5.6. I don't know the exact reason for it. But, I feel like it is because some buffer is fulfilled. I am using with('key','value') procedure to return error from the exception handler.

I just keep on checking the error and after a certain time, this starts to appear.

I also google for it and find the solution of increasing xdebug.max_nesting_level. But instead, I want to solve it another way. Should I clear any buffer after passing with() or is there any better procedure.

30 Apr
1 year ago

Inquisitive started a new conversation Add Created By And Updated By Dynamically In UpdateOrCreate

                $colorado_voter = new Colorado_voter();
                foreach ($map_data as $mk => $mv) {
                    if(!isset($skip[$mk])){
                        $colorado_voter->$mv = $cv[$mk];
                    }
                }

                 $colorado_voter_rec = Colorado_voter::updateOrCreate(
                    ['voter_id' => $colorado_voter_arr['voter_id']],
                    $colorado_voter_arr
                );

Now I want to insert created_by only when it is inserting and updated_by when updated.

How can I achieve this.