coder72

Member Since 6 Months Ago

Experience Points
3,240
Total
Experience

1,760 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
3,240 XP
Apr
01
2 weeks ago
Activity icon

Started a new Conversation Needed Help For Query

This is my Seller Table.I need to find all sales from seller id 1

id | name  | phone   |
 1 |  Coder | 98653271039 |

This is my Sales table

 id | action_date | seller_id | quantity | product_id |
 1  |  2021-01-01 |     1     |     50   |       1    |
 2  |  2021-01-01 |     1     |    100   |       2   |
 3  |  2021-01-01 |     1     |    150   |       2   |
 4  |  2021-01-03 |     1     |    120   |       1   |
 5  |  2021-01-04 |     1     |    190   |       1   |
 

This is my product table

id | name  |
 1 | Mobile |
 2 | Laptop |

This is my Sale.php

public function product()
    {
        return $this->belongsTo('App\Product');
    }
 public function seller()
    {
        return $this->belongsTo('App\Seller', 'seller_id');
    }

I want my result like this.I want to query to be sum all quantity of each day of each product .

| Date    |    Mobile     | Laptop |
          | Sales | Stock | Sales | Stock |
2021-01-01|  50   | 0     | 250 | 0
2021-01-03| 120  |  0    |  0    | 0
2021-01-04| 190  |  0    |  0    | 0
Mar
03
1 month ago
Activity icon

Started a new Conversation How To Sum All Stock And Add In Total From Table ?

<table>
	<thead>
		<tr>
			<td>Product Name</td>
			<td>Stock</td>		
		</tr>	
	</thead>
	<tbody>
		@foreach($products as $product)
		<tr>
			<td>{{$product->name}}</td>
			<td>{{ $product->getProductStock() }}</td>	
		</tr>
		@endforeach	
	</tbody>	
</table>

I am getting this result from above code.

| Product Name | Stock  |
|     Mobile           |   32     |
|    Laptop            |  45      |

But am expecting this result.So how to add all stock from and and put in total ?

| Product Name | Stock  |
|     Mobile           |   32     |
|    Laptop            |  45      |
|     Total              |     77    |
Feb
25
1 month ago
Activity icon

Replied to How To Store Rate Field In Pivot Table In Laravel

Thanks a lot for your response.I will try your method also.But I have write silly logic for this ha ha.First I detach and again attach data.i know this logic is not good

$user=User::where('id',auth()->user()->id)->first();
  $user->items()->detach();
        foreach ($request->item as $key=>$item){
            $user->items()->attach($item,['rate'=>$request->rate[$key]]);
        }
        return redirect()->back()->withStatus(__('Rate Over Succesfully Updated.'));
 
Activity icon

Replied to How To Store Rate Field In Pivot Table In Laravel

I tried this also.but its not working

$user=User::where('id',auth()->user()->id)->first();
        foreach ($request->item as $key=>$item){
            $ite[$item]=$request->rate[$key];
        }

        $user->items()->sync([$request->item =>['rate'=>$ite]]);
Activity icon

Replied to How To Store Rate Field In Pivot Table In Laravel

i donot have any pivot model.I have defined my directly in user model and item model.So Where should make rate coulmn fillable.

public function items()
    {
        return $this->belongsToMany(Item::class, 'item_user')->withPivot('rate');
    }

I thought ->withPivot('rate'); is simlar like protected fillable

Feb
24
1 month ago
Activity icon

Started a new Conversation How To Store Rate Field In Pivot Table In Laravel

This is my pivot table look like

item_id|user_id|rate|

"item" => array:3 [▼
    0 => "1"
    1 => "2"
    2 => "3"
  ]
  "rate" => array:3 [▼
    0 => "10"
    1 => "30"
    2 => "20"

I want to store rate data in pivot table.But is not working.Only item_id and user_id has been store.

public function settings(Request $request){
dd($request->all());
 $user=User::where('id',auth()->user()->id)->first();
 foreach ($request->item as $key=>$item){
            $ite[$item]=$request->rate[$key];
        }

  $user->items()->sync($request->item, array('rate' => $ite));
 return redirect()->back()->withStatus(__('Rate Over Succesfully Updated.'));
}

This is my User model

public function items()
    {
        return $this->belongsToMany(Item::class, 'item_user')->withPivot('rate');
    }
Feb
21
1 month ago
Activity icon

Replied to How To Get All Consumer Data ?

Yes I tried this.but i donot know whtether this method is good or not

$sales=Sale::with('customer')->where('user_id', 2)->groupBy('consumer_id')->get();
  $consumers=[];
foreach($sales as $sale){
	   array_push($consumers,$sale->consumer);
}
Activity icon

Replied to How To Get All Consumer Data ?

I tried like this.It worked.

$sales=Sale::with('customer')->where('user_id', 2)->groupBy('consumer_id')->get();
  $consumers=[];
foreach($sales as $sale){
	   array_push($consumers,$sale->consumer);
}
Activity icon

Started a new Conversation How To Get All Consumer Data ?

This is my Sales Table.

id | sales | consumer_id | user_id
 1 | 23    |      1      |    2
 2 | 43    |      2      |  2
 3 | 38    |      2      |  2
 4 | 198    |      1      |  3

This is my Consumers Table

id | name | 
 1 | arju    |
 2 | kara    |
 3 | pemb    |
 4 | dran    |

This is my Sales model look like

 public function consumer()
    {
        return $this->belongsTo('App\Consumer', 'consumer_id');
    }

Suppose My User Id is 2.I want to get all consumer where my user_id is 2 in sales table.If my user_id is 1 the i need all consumer from sale table where user_id 1.So how should do it

Feb
11
2 months ago
Activity icon

Replied to How To Sum Two Different Array If Their Name Match

Thank you so much for your response. but i am working this on Jquery.

Feb
10
2 months ago
Activity icon

Started a new Conversation How To Sum Two Different Array If Their Name Match

This is my two object from two different URL.I want to sum or add item distribution array if name match.

0:
cancelTenders: 1
closeTenders: 7
itemDistribution: Array(4)
0: {name: "Mobile", quantity: 18472.8}
1: {name: "Laptop", quantity: 20117.535000000003}
2: {name: "Tablet", quantity: 2609.75}
3: {name: "Watch", quantity:6205}


1:
cancelTenders: 0
closeTenders: 0
itemDistribution: Array(3)
0: {name: "Mobile", quantity: 26290.65}
1: {name: "Laptop", quantity: 11844.774}
2: {name: "Tablet", quantity: 416.8}

I want to add two different array if their name match result like this

0: {name: "Mobile", quantity: 44,763.45}
1: {name: "Laptop", quantity: 31,962.309}
2: {name: "Tablet", quantity: 3,026.55}
3: {name: "Watch", quantity: 6205}
Feb
01
2 months ago
Jan
29
2 months ago
Activity icon

Started a new Conversation How To Sum Two Table (price And Dicount) If Date Match Though Item

This is my item database look like

| id | name | description | created_at |
| 1  | Test | ............| 2021/1/29

This is my sale table.My price and discount store in serialized array

id |item_id| title |          price          |       discount     |       created_at
1  |   1   |test1 | ["3200","2300","4500"]  |["500","200","500"] | 2021/1/29
2  |   1   |test2 | ["2300","6200","8500"]  |["200","300","400"] |2021/1/30

This is my trade table

id | item_id|title  | price | discount | created_at
1  |      1   |test1 | 5230  |6500 | 2021/1/29
2  |      1  |test2 | 9000  |7800 |2021/1/30

This is my Item Model.I need to add all price and discount both of sale and trade of related item

public function sale(){
 	return $this->hasMany(Sale::class, 'item_id', 'id');
}
public function trade(){
 	return $this->hasMany(Trade::class, 'item_id', 'id');
}
public function sum_total(){
	
}
array:3 [▼
  0 => {#1663 ▼
    +"created_at": "2021/1/29"
    +"price":15230
    +"discount": 7700
  }
  1 => {#1702 ▼
    +"created_at": "2021-01-30 "
    +"price": 26000
    +"discount": 8700
  }
]
Jan
14
3 months ago
Activity icon

Started a new Conversation Count(): Parameter Must Be An Array Or An Object That Implements Countable

This is my Project model

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

This is my User Model

public function project(){

 	return $this->belongsToMany(Project::class,'project_users');
}
This is my ProjectController

public function index(ProjectDataTable $dataTable){
	return $dataTable->render('projects.index');
}

THis is my Yajra Datatable

 public function dataTable($query)
    {
        $users=Project::find(1)->user()->get();

	// If i do dd($members); then data will come but i removed that this error will come
        return DataTables::of($users)
            ->addIndexColumn()
            ->addColumn('name', function($user){
                return $user->name;
            })
            ->addColumn('action', function($user){
                return view('');
            })
            ->rawColumns(['action']);
    }
Jan
04
3 months ago
Activity icon

Replied to How To Update Data That Is In Array ?

Yes i want to update those product attribute data.So how to update ? One product may have multiple product attribute .In my product edit form,i want to update sku and color and rest product data too.

Activity icon

Started a new Conversation How To Update Data That Is In Array ?

I want to update sku and color data .But My function only update of last array data When I do dd($request->all()) in update form

  "_token" => "6OmWbWhVTvyw4PXq1mhZbbcopMehx15pEjOJtWNz"
  "name" => "Jacket"
  "price" => "4000"
 
  "sku" => array:2 [▼
    0 => "057HJI"
    1 => "0KL780"
  ]
  "colour" => array:2 [▼
    0 => "Red"
    1 => "White"
  ]
  
]

In Product Controller update function.I want to update sku and colour data but when i clicked updated button,the whole data is comming of last array

   public function update(Request $request,Purchase $purchase)
    {

        $purchase->fill($request->all())->update();
	foreach($request->sku as $key => $attr)
        $purchase->productattribute()->update([
            'sku'=>$attr,
            'colour'=>$request->colour[$key];
            
        ]);

        return redirect()->back();
    }

This is my Product Model

 protected $fillable = ['name','price'];

 public function productattribute()
    {
        return $this->hasMany(ProductAttribute::class,'product_id');
    }
Jan
03
3 months ago
Activity icon

Started a new Conversation Gument 1 Passed To Illuminate\Database\Eloquent\Relations\HasOneOrMany::create() Must Be Of The Type Array

This is my products table loos like

| id | name | price | created_at

This is my product_attribute table look like

|id | product_id | sku | colour |

This is my Product model

 protected $fillable = ['name','price'];

 public function productattribute()
    {
        return $this->hasMany(ProductAttribute::class,'product_id');
    }

This is my product attribute model

 protected $fillable = ['product_id','sku','colour']

In Product Controller.I want to save data to both table (purchase,purchase_warehous)

   public function store(Request $request,Purchase $purchase)
    {

        $purchase->fill($request->all())->save();

        $purchase->productattribute()->createMany([
            'product_id' => $product->id,
            'sku'=>$request->sku,
            'colour'=>$request->colour
            
        ]);

        return redirect()->back();
    }

I am using dynamic add/delete input.So data come like this.When i do dd($request->all())

array:12 [▼
  "_token" => "6OmWbWhVTvyw4PXq1mhZbbcopMehx15pEjOJtWNz"
  "name" => "Jacket"
  "price" => "4000"
 
  "sku" => array:2 [▼
    0 => "057HJI"
    1 => "0KL780"
  ]
  "colour" => array:2 [▼
    0 => "Red"
    1 => "White"
  ]
  
]
Dec
30
3 months ago
Activity icon

Started a new Conversation How To Use Change Value In Another Select Box In AJAX ?

This is my commodity database look like

id | name     | type     |   created_at    
1  |  Apple   | Fruits   |                     
2  | Mango   | Fruits    |                    
3  | Tomato  | Vegetable |              
4  | Oranges |Fruits     |
5  | Potato  |  Vegetable|

In create form, I want to use AJAX for commodity_type select box.When I select fruits,then apple,mango,oranges should come in SELECT box. when i select Vegetable then tomato ,potato should come though AJAX

<select id="commodity" name="commodity">
	<option value="Fruits">Fruits</option>
        <option value="Vegetable">Vegetable</option>
</select>
<select id="commodity_type" name="commodity_type">

</select>

In My Commodity Controller

public function create(){
	$commodities=Commodity::groupBy('type')->pluck('type')->get();
}

In route

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

In Script file

 <script>
        $('#commodity').change(function(){
            let commodity= $(this).val();
             $.ajax({
                 type:'GET',
                 url:'getCommodityType',
                 data:commodity,
             	  success:function(data) {
                  
               }
            });
        })
    </script>
Dec
28
3 months ago
Activity icon

Started a new Conversation How To Validate Image In Edit Form If There Is No Image Is Selected

I want to validate image in edit form.If image already exists no need to validate but if empty it needed to validated.But In my case even there is already image ,Validation occur This is my product edit form

<form action="{{route('product.store')" method="post" enctype="multipart/form-data" autocomplete="on">
	<input type="text" name="name" value="{{ old('name', $product->name ?? null) }}">
	<input type="file" name="image" id="image">
	@if($product->image)
     	<img src="{{asset($patient->image())}}"
      @endif
</form>

This is my Product Controller.Here i am using Product Request for validation

public function update(ProductRequest $request,Product $product){
	 $product->fill($request->all());
     if($request->hasFile('image')){
              $image_tmp=$request->file('image');

              $image_path = $product->image();
 
              if(File::exists($image_path)){
                   File::delete($image_path);
              }

             if($image_tmp->isValid()){
                 $image_name=$image_tmp->getClientOriginalName();
 
                 $extension=$image_tmp->getClientOriginalExtension();
  
                 $imageName=$image_name.'-'.rand(111,99999).'.'.$extension;
  
                 $image_path='admin/images/products/'.$imageName;

                Image::make($image_tmp)->save($image_path);
                $product>image=$imageName;
            }
        }
        $product->update();
return redirect()->back();

}

This is my product model

public function image(){
  return 'admin/images/products/'.$this->image
}

This is my Product Request for validation

public function rules()
    {
        return [
            'name' => [ 'required' ],
            'image' => [ 'required' ],
        ];
    }

    public function messages()
    {
        return [
            'name.required' => 'Prodcut Name is Compulsary',
            'image.required' => 'Image is Compulsary',

        ];
    }
Dec
27
3 months ago
Activity icon

Started a new Conversation How To Filter Between Two Date Only If They Are Not Empty Or Null

Hello , I am trying to make filter.I am trying to filter between two date only if they are not null or empty.In my case if $from and $to variable are empty it is filtering with today date.So how to make filter only if $from and to and are not empty ?

$from = "2020-12-01" ?? ''; // date coming from filter
$to = "2020-12-27" ?? '';  // date coming filter

	$order=Order::where('status','delivered')
		 ->where('delivery_date','>=' ,Carbon::parse($from))
                ->where('delivery_date','<=' ,Carbon::parse($to))
		->get();

Dec
25
3 months ago
Dec
24
3 months ago
Activity icon

Started a new Conversation How To Export Single Data In Laravel ?

Hello, I am trying export single product data, So I am using this command

composer require maatwebsite/excel

This is my ProductExport.php.Do i need to make another function for single detail ?

  public function collection() 
    {
        return Product::all();
    }

This is my route

  Route::get('export/{product}', '[email protected]')->name('prodcutExport');

In ProductController.php

 public function export()
    {
        return Excel::download(new ProductExport(), 'patient.xlsx');
    }

In product (index.blade.php)

@foreach($products as $product)
	<tr>{{$product->name}}</tr>
        <tr>{{$product->price}}</tr> 
        <tr><a href="{{route('prodcutExport',$product->id)}}">Export Product Detail</></tr>
@endforeach
Dec
23
3 months ago
Activity icon

Started a new Conversation How To Validate In Laravel ?

In Product Model Product.php

 protected $fillable = [
        'name','price','image','type'
    ];

In ProductController.php

public function update(Request $request,Product $product){
	$validatedData = $request->validate([
            'name' => 'required|max:255',
        ]);
       $product::update($validatedData);//if i did this only name is working update.Other are not updating
        return redirect()->back();
}

So how to merge $validatedData in $request->all()

Dec
21
3 months ago
Activity icon

Started a new Conversation How To Append <img Src=""> In Datatable

Hello I am using Yajra Datatable

"yajra/laravel-datatables": "1.5",
 "yajra/laravel-datatables-buttons": "4.9" 

Everything is good.All data are coming except i want to append my image in that Datatable This is my productDataTable.php

 public function dataTable(Product $product)
    {
          $products=Product::latest();
          return DataTables::of($products)
              ->addIndexColumn()
              ->addColumn('name', function($product){
                return $product->name;
             })
              ->addColumn('image', function($product){

                return '<img src=" '.$product->image().' "/>';
            })
            ->addColumn('price', function($product){
                return $product->price;
            })
	}

In my Product.php Model

public function image(){
    return 'admin/images/products/'.$this->image;
}

My problem is all product name and price are coming except image.Only path are coming.So show to append in datatable

Activity icon

Replied to How To Validate Where Name=price[] Like This ?

I have already tried that but didnot work :(

Activity icon

Started a new Conversation How To Validate Where Name=price[] Like This ?

This is my product form.which name has name="price[]". I want to validate in Laravel Product Request

This is my product.blade.php

<input type="text" name="name" class="form-control">
<input type="text" name="price[]" class="form-control">

ProductRequest.php

public function rules()
    {
        return [
            'name' => [ 'required'],
	    'price' => [ 'required'], // I tried this
             'price[]' => [ 'required'],// also this
             'price' => [ 'required','array'], and this
           ];
    }

But none of them are working except name.How should i validated that product price ?

Dec
20
3 months ago
Activity icon

Started a new Conversation How To Retrive Image In Image Preview In Edit Form ?

I am trying to use image preview before upload.Its working fine while creating new.but how to retrieve that image that has already saved in edit form and can be change when i try to change another image ? This is my input type for file.

 <input type="file" class="form-control" name="image" id="image">
      	<img id="user_image" src="{asset('admin/images/user/'.auth()->user()->image)}}" />

This is my script file to preview image before uploading

<script>

      function readURL(input) {


          if (input.files && input.files[0]) {

              var reader = new FileReader();
              reader.onload = function(e) {
                  @php  $value=auth()->user()->image; @endphp
                  $('#user_image').show();
                    $('#user_image').attr('src', e.target.result).slideDown();;
              };

              reader.readAsDataURL(input.files[0]);
          }
      }

      $("#image").change(function() {
          readURL(this);
      });
  </script>
Dec
17
4 months ago
Activity icon

Awarded Best Reply on How To Customize Login Page In Laravel ?

Sorry I forget to give name in input type in both email and password
Activity icon

Replied to How To Customize Login Page In Laravel ?

Sorry I forget to give name in input type in both email and password
Dec
16
4 months ago
Activity icon

Started a new Conversation How To Customize Login Page In Laravel ?

This is my resources\views\auth\login.blade.php. i want to customized this design.When i try to login,nothing is happening and redirect back even it has right email and password.So how to customize login page in laravel ?

  <!DOCTYPE html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Majestic Admin</title>

    @include('layouts.backend.style')
</head>

<body>
<div class="container-scroller">
    <div class="container-fluid page-body-wrapper full-page-wrapper">
        <div class="content-wrapper d-flex align-items-center auth px-0">
            <div class="row w-100 mx-0">
                <div class="col-lg-4 mx-auto">
                    <div class="auth-form-light text-left py-5 px-4 px-sm-5">
                        <div class="brand-logo">
                            <img src="{{asset('admin/images/logo.svg')}}" alt="logo">
                        </div>
                        <h4>Hello! let's get started</h4>
                        <h6 class="font-weight-light">Sign in to continue.</h6>
                        <form role="form" method="POST" action="{{ route('login') }}">
                            @csrf
                            <div class="form-group">
                                <input type="email" class="form-control form-control-lg" id="exampleInputEmail1" placeholder="{{ __('E-Mail Address') }}">
                                @error('email')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                            <div class="form-group">
                                <input type="password" class="form-control form-control-lg" id="exampleInputPassword1" placeholder="{{ __('Password') }}">
                                @error('password')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                            <div class="mt-3">
                                <button class="btn btn-block btn-primary btn-lg font-weight-medium auth-form-btn" type="submit">SIGN IN</button>
                            </div>
                            <div class="my-2 d-flex justify-content-between align-items-center">
                                <div class="form-check">
                                    <label class="form-check-label text-muted">
                                        <input type="checkbox" class="form-check-input">
                                        Keep me signed in
                                    </label>
                                </div>
                                <a href="#" class="auth-link text-black">{{ __('Forgot Your Password?') }}</a>
                            </div>
                          
                        </form>
                    </div>
                </div>
            </div>
        </div>
        
    </div>
    
</div>

@include('layouts.backend.script')

</body>

</html>
Activity icon

Replied to Error Coming While Trying To Execute This Composer Require Laravel/ui

@sinnbeck Sorry I though i work when i tried to terminate this command

composer global self-update
and composer require laravel/ui
composer require laravel/ui
Using version ^3.1 for laravel/ui
./composer.json has been updated
Running composer update laravel/ui
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/ui[v3.1.0, ..., 3.x-dev] require illuminate/console ^8.0 -> found illuminate/console[v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with ano
ther require.
    - Root composer.json requires laravel/ui ^3.1 -> satisfiable by laravel/ui[v3.1.0, 3.x-dev].


Installation failed, reverting ./composer.json and ./composer.lock to their original content.
Activity icon

Started a new Conversation Error Coming While Trying To Execute This Composer Require Laravel/ui

When i try to execute this command in laravel 7

composer require laravel/ui

This error is coming

Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Using version ^3.1 for laravel/ui
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResol
ver/RuleWatchGraph.php on line 52

Dec
11
4 months ago
Activity icon

Started a new Conversation How To Give Value From Select Box Everytime I Increase Button Of Dynamically Input Jquery

I am using jQuery dynamic table inputs in my form.

 <table class="dynamic-fields-table">
	 <thead>
            <tr>
                <th >Country</th>
                <th >City</th>
                 <th></th>
            </tr>
	</thead>
	<tbody>
		<tr>
		<td>
			<select name="country[]" class="form-control">
				<option value="1">USA</option>	
				<option value="2">Russia</option>
				<option value="3">Japan</option>
			</select>
		</td>
		<td>
		<input type="text" name="city[]" class="form-control">
		</td>
		<td>
			+ -  // button for increasing or decreasing input
		</td>
		</tr>
	</tbody>

</table>

In script file.When I select country at first it will come value right in console.but when i increase input form then i select again another country then value of country will give same as first time selected.So how should i give value of country i selected everytime i increase dynamically input button


 $(document).on('change', " select[name='country[]']", function(){
    	updatecity();
  });

function updatecity(){
	$country = $(" select[name='country[]']").val();
	console.log($country)
}

Dec
10
4 months ago
Activity icon

Started a new Conversation How To Trigger By Taking Parent Class Instead Of Input

This is my form

 <div class="col-md-9 kg">
          <input type="number" name="kg[]" id="input-kg" class="form-control">
 </div>

So this is my script where data is change from input name.But i want to trigger or change from its parent div that has class kg ?

$(document).on('change paste keyup', "input[name='kg[]']", function(){
    	updatedynamicprice($(this));
   });
Activity icon

Replied to Uncaught TypeError: Cannot Read Property '1' Of Undefined ?

Okay i have like this

function conversion_kg_to_price($item) {
$rate = {
        '0': 100,
        '1': 100,
        '2': 120,
        '3': 120,
    };

return $rate[$item];
}

function updatedynamicprice(value) {
	let kg = $("input[name='kg[]']").val();
  	let total_price=conversion_kg_to_price(value) * kg;
console.log(total_price)
}

When i something try to write in kg like 2.then

The specified value "NaN" cannot be parsed, or is out of range.
Activity icon

Replied to Uncaught TypeError: Cannot Read Property '1' Of Undefined ?

i am just trying to return that price to multiply with kg . so what would be best option ?

Activity icon

Started a new Conversation Uncaught TypeError: Cannot Read Property '1' Of Undefined ?

<select class="form-control item" name="item[]">
  <option value="1">Potato</option>
  <option value="2">Tomato</option>
  <option value="3">Onion</option>
</select>
<input type="text" name="kg[]" class="form-control">
<input type="text" name="price[]" class="form-control">

This is my script file

$(document).on('change', ".item", function(){
    updatedynamicprice($(this).val());
});

function conversion_kg_to_price($item) {

    $rate = [
        ["0", 100], // [id,price]
        ['1', 100],
        ['2', 120],
        ['3', 120],
    ];
    return $rate[$item];

}
function updatedynamicprice(value) {
	let kg = $("input[name='kg[]']").val();
  	let total_price=conversion_kg_to_price(value)[1] * kg;
  	console.log(total_price);
}

When i do console.log(conversion_kg_to_price(value)[1]); it return its price but when i tried to multiply with kg error is comming

Activity icon

Started a new Conversation How To Change Other Input Field When Select Box Is Choosen ?

This is my form.When i select some item and write some kg then price should be automatically come. like potato - 1 kg - Rs 100 | Tomato - 1 kg - Rs 90 | Onion - 1 kg - 80

<select class="form-control item" name="item[]">
	<option value="1">Potato</option>
	<option value="2">Tomato</option>
	<option value="3">Onion</option>
</select>
<input type="text" name="kg[]" class="form-control">
<input type="text" name="price[]" class="form-control">

This is my index.js.

$(document).on('change', ".item", function(){
    updatedynamicprice($(this))
});

Here i want to check condition if item is selected as 1 then price should 100, if item is selected as 2 then price should be 90 and if item is selected 3 then price should be onion.So how to send select box value in below function ?

function updatedynamicprice(){
	$kg=$("input[name='kg[]']").val();
	$total_price=  $kg * $price ;
	$price = $("input[name='price[]']").val($total_price);
}
Dec
07
4 months ago
Activity icon

Replied to Argument 1 Passed To App\Http\Controllers\Controller::authorize() Must Be An Instance Of Illuminate\Http\Request, String Given, Called In

Yeah I tried this

 public function authorize(Request $request,$email){
 	
       $user=User::where('email',$request->email)->firstOrFail();
    if(isset($user))
       {
           auth()->user()->update([
               'last_login_at' => Carbon::now()->toDateTimeString(),
               'last_login_ip' => $request->getClientIp(),
           ]);
           return redirect('/');
       }
       }

Error comike this

Argument 1 passed to App\Http\Controllers\Controller::authorize() must be an instance of Illuminate\Http\Request, string given, called in
Activity icon

Started a new Conversation Argument 1 Passed To App\Http\Controllers\Controller::authorize() Must Be An Instance Of Illuminate\Http\Request, String Given, Called In

This is my web.php

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

This is Controller.php

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Carbon\Carbon;
use Illuminate\Http\Request;


class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

public function authorize(Request $request)
{
    $user=User::where('email',$request->email)->firstOrFail();
    if(isset($user))
       {
           auth()->user()->update([
               'last_login_at' => Carbon::now()->toDateTimeString(),
               'last_login_ip' => $request->getClientIp(),
           ]);
           return redirect('/');
       }
}

}


Dec
04
4 months ago
Activity icon

Started a new Conversation How To Validate Phone Number Jquery Number

I want to validate this input for phone.Up to 10 digit only and no text allowed only number digit

<input type="text" name="phone" onkeypress='validate(event)'>

Although no text allowed worked but how to validate upto maximun 10 digit

<script>
function validate(evt) {
    var theEvent = evt || window.event;
    var key = theEvent.keyCode || theEvent.which;
    key = String.fromCharCode( key );
    var regex = /[0-9]|\./;
    if( !regex.test(key) ) {
        if(!regex.test(key) >=10 && !regex.test(key)<=10){
            theEvent.returnValue = false;
            if(theEvent.preventDefault) theEvent.preventDefault();
        }

    }
}
</script>
Dec
01
4 months ago
Activity icon

Replied to How To Login After Checking Ip Address And City ?

If they match already,There would be another code Its just Example but i just need to put condition.If there is another IP address detected then user will get message weather it was you or not .If user clicked yes then new IP address will be stored.but for now i need to put those condition

Activity icon

Replied to How To Login After Checking Ip Address And City ?

@sinnbeck When user login ,the IP address and login time and city will get updated.If Ip address and city doesnot match i just want to send email to user

Activity icon

Replied to How To Login After Checking Ip Address And City ?

Sorry I want to check condition of current IP address and city and if it match with database then successfully login otherwise Error.How to check condition of IP address and city ?

Activity icon

Started a new Conversation How To Login After Checking Ip Address And City ?

This is my user database where i have to store /update last_login_at and last_login_IP and current city from given below API.

id | name | email | phone | password | last_login_at | last_login_ip |city |created_at |

I my trying to use this http://ip-api.com/php/24.48.0.1 API that detect the user location from IP. This is data i get from API

{
  "query": "24.48.0.1",
  "status": "success",
  "country": "Canada",
  "countryCode": "CA",
  "region": "QC",
  "regionName": "Quebec",
  "city": "Montreal",
  "zip": "H1S",
  "lat": 45.5808,
  "lon": -73.5825,
  "timezone": "America/Toronto",
  "isp": "Le Groupe Videotron Ltee",
  "org": "Videotron Ltee",
  "as": "AS5769 Videotron Telecom Ltee"
}

This is where i want to update last_login and ip address of user and city from where he login in.I want to check if last_login_ip and city didnot match.Then Message/Mail should be thrown to the user

function authenticated(Request $request, $user)
    {
        $client = new  \GuzzleHttp\Client();
        $url = "http://ip-api.com/php/24.48.0.1";
        $response = $client->request("GET", $url);
        $response=(array) json_decode($response->getBody()->getContents());
        
        $user->update([
             'last_login_at' => Carbon::now()->toDateTimeString(),
             'last_login_ip' => $request->getClientIp(),
             'city' => $response['city'],
         ]);
       
    }
Activity icon

Replied to How To Make Security Login In Laravel Like Facebook ?

Thank you so much for your advice.If i got any problem related this.i will ask

Nov
30
4 months ago
Activity icon

Replied to How To Make Security Login In Laravel Like Facebook ?

@lorvent Thanks i will try and inform you. anyway thanks a lot

Activity icon

Replied to How To Make Security Login In Laravel Like Facebook ?

@automica @deep88 Thanks. But every time user have to do 2 step authentication to login ? When user is in some random city like Mumbai and login his dashboard.But after 2 minutes some guy tries to login his dashboard from another city like New Delhi.So in this case i want to send mail to user with some message . https://ip-api.com/ may be this work i think.Do i have to compare city or IP address