tigerjun

tigerjun

Member Since 2 Years Ago

Experience Points
1,000
Total
Experience

4,000 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.

Level 1
1,000 XP
Apr
24
3 months ago
Activity icon

Replied to How Can I Convert Array To Request Format

I need to run a lot of test to see the result correctly or not in my application without key in the data repeating. I tried laravel test but it look like more complicated. Therefore i choose the faster way just directly pass the data to controller.

Activity icon

Started a new Conversation How Can I Convert Array To Request Format

I have an array and required to convert to array format before passing to store function.

It's work when my controller put request infront.

 $product = [];
     $product['2024535545']  = '2';

app(OrderController::class)->store(new Request($data));


public function store(Request $request){}	

But when i put

public function store(UserOrderFormRequest $request){}

It's come out an errors

Argument 1 passed to App\Http\Controllers\Frontend\OrderController::store() must be an instance of App\Http\Requests\UserOrderFormRequest,

My UserOrderFromRequest

	class UserOrderFormRequest extends FormRequest
	{
		public function authorize(){return true;}

		public function rules()
		{
			$rules = [];

			switch($this->method())
			{

				case 'GET':
				case 'DELETE':
				{
					return [];
				}
				case 'POST' || 'PUT':
				{
					$rules['order_remark']              = 'max:1000';
	  
					return $rules;

				}
				case 'PATCH':
				default:break;
			}
		}
	}
Apr
19
3 months ago
Activity icon

Awarded Best Reply on Query With Special Condition Like 2%2 =0

Promotion::where('product_id',$product) ->whereRaw('('.$quantity.'%promotion_quantity) = 0') ->get();

Activity icon

Replied to Query With Special Condition Like 2%2 =0

Promotion::where('product_id',$product) ->whereRaw('('.$quantity.'%promotion_quantity) = 0') ->get();

Activity icon

Started a new Conversation Query With Special Condition Like 2%2 =0

When user buy two of the item will get a discount. Now the problem is when the user buy four qty of the product i cant match it out. Therefore i need to do some math in query. Like quantity%database.quantity == 0.

How can i do that in my query

        $promotionID = Promotion::where('product_id',$product)
			->whereRaw('promotion_quantity%'.$quantity.'=0')
                            ->get();
Mar
29
4 months ago
Activity icon

Replied to Dropzone.js Rename After Upload Success

@snapey No. I only need to rename the file have been uploaded in the dropzone.

Activity icon

Replied to Dropzone.js Rename After Upload Success

@bobbybouwmann I tried this but its didnt work. Not sure where the file have been saved. Can i know what the different between this two??

$image->storeAs(public_path('img/product/'), $imageName);
Mar
28
4 months ago
Activity icon

Replied to Dropzone.js Rename After Upload Success

@bobbybouwmann I change it on server and i return the new file name. Now i want to rename the uploaded file name to the name i return.

	public function updateImg(Request $request){

			$image = $request->file('file');
			$imageName = time().'.'.$image->extension();
			$image->move(public_path('img/product/'),$imageName);

		   return response()->json($imageName);
		}
Activity icon

Started a new Conversation Dropzone.js Rename After Upload Success

I want my file name become unqiue therefore i can pass the file name to controller and delete the file by name. But i tried it a lot of way its doesnt work. Any idea how can i change the file name??

when it upload success

	myDropzone.on("success", function(response) {
		let newName = response.xhr.response;
		myDropzone.on("renameFile", function(response) {
			return newName;
		});
	});
Activity icon

Replied to Ajax Sorting Randomly

@amaury You r genius. Thanks.

I found that $data.map is not working in my controller. Than i change it to this and it works.

$output = $data->map(function ($item, $key) {
        $value = [
            'value' => $item->id,
            'text' => ($item->level['level_name_en'] ?? null) ." --> ". $item->full_name,
        ];
        return [$key => $value];
    });

My js

$.each( result, function(k, v) {
         	$('#agent_id').append($('<option>', {value:v[k]['value'], text:v[k]['text']}));
     });
Activity icon

Replied to Ajax Sorting Randomly

@amaury I tried. But the select option become empty. Nothing come out. I found that all the data sorting randomly after i return it. Mean before return the data are sort. Than some how the return randomly sort my data

Activity icon

Replied to Eloquent How To Group Data By An Row

@testy U r genius. It solved all my problem

Mar
27
4 months ago
Activity icon

Started a new Conversation Ajax Sorting Randomly

I have a select option which using ajax to get the data. I try sort the query in the controller and is good. But it appear randomly when i append is js. How to return a correct sort which already sort in controller?

$data = $query
        ->join('level','level.level_id','users.level_id')
        ->orderBy('level_grade','asc')
        ->get();

    $output = [];
  
	foreach( $data as $d ) {
		$output[$d->id] = ($d->level['level_name_en'] ?? null) ." --> ". $d->full_name;
	}

	return $output;

My js

$('#levelOption').change(function(){

	var url = '{{ route( 'agent.option',':levelID' ) }}';
	url = url.replace(':levelID', levelID);
  
	$.ajax({
		url,
		type: 'GET',
		dataType: 'json',
		success: function( result ) {
			$("#agent_id option").remove();
			$.each( result, function(k, v) {
				$('#agent_id').append($('<option>', {value:k, text:v}));
			});
		}
	});
});
Mar
25
4 months ago
Activity icon

Replied to How Laravel @extends Work?

First i got a app.blade.php file

Inside this file i put this. I import all the file needed here.

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
</head>
<body>
	<div id="app">
		<main>
			<div class="container-fluid">
				@yield('content')
			</div>
		</main>
	</div>
</body>
</html>

You can see got a thing call @yield('content'). This is the location where i put content inside.

Than i got another file name index.blade.php

@extends('app')

@section('content')
	<h1>Content Here</h1>
@endsection

As you can see the @extend('app') is the my first file name. This will get all my html inside @section('content') and put inside the @yield('content') which located in my first file.

This is how i use it. The same header will compile to each file you open.

Mean you can open many index file with the same header. You no need to copy and paste the header again and again to each html file.

Activity icon

Started a new Conversation How Convert My Query To JS TREE Json Format

I need a diagram which will show all the relationship of each agent and i found it using JS TREE can done it.

Such as AGENT A have two child name AGENT B & AGENT C. AGENT B have two child again name AGENT D and ... I have many agent and each agent have many child. Now the problem is i have no idea how to get all the child and convert it into json format.

I have a user table with column id, name and agent_id. The agent_id is from the same table using id as referral Each agent have a agent id or maybe not. if not the agent parent is company

How can i get all the agent child?

Feb
27
5 months ago
Activity icon

Started a new Conversation How Remove Specifc Array Key From Request

This is the array from request

array:13 [
    "order_quantity" => array:2 [
        1643248297 => "1233"
        3434504227 => "202"  ]
    "order_price" => array:2 [
    1643248297 => "180"
    3434504227 => "120"  ] ]

If i wan to remove the order_quantity with key 1643248297 and also the order_price with same key. How can i do that?