a4ashraf

a4ashraf

Member Since 7 Months Ago

Experience Points
120,900
Total
Experience

4,100 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
1020
Lessons
Completed
Best Reply Awards
19
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 25
120,900 XP
Jul
06
1 month ago
Activity icon

Replied to POST Request In Postman - 419 Expired

Hello @srenert

can you share your Controller and view here

I think you are using {{ csrf_field() }} instead of this @csrf in your view file

see the documentation

https://laravel.com/docs/7.x/csrf#csrf-introduction

Jul
03
1 month ago
Activity icon

Replied to Check If Item Is Inside A Collection

Hello @msslgomez

Try this one and see the Collections Method documentation

https://laravel.com/docs/7.x/collections#method-filter

$collection = collect([1, 2, 3, 4]);

$filtered = $collection->filter(function ($value, $key) {
    return $value > 2;
});

Jul
01
1 month ago
Activity icon

Replied to Verification Email In Laravel

@euchimed

no issue, if you are using mailtrap or gmail.com yahoo or Hotmail

please see the email verification document

https://laravel.com/docs/7.x/verification

Activity icon

Replied to Verification Email In Laravel

Hello @euchimed

its very simple please read the documentation here https://laravel.com/docs/7.x/verification

Jun
29
1 month ago
Activity icon

Awarded Best Reply on Track User Links

@johnw65

try this package https://github.com/spatie/activitylog

may this could help you

Jun
23
1 month ago
Activity icon

Replied to Dynamic Form And Save To Database

@trifek

Please share your model and migration

Activity icon

Replied to Return More Than Attribute While Grouping By From 3 Tables

hello @ahmedelgohary

Please share your model and migration

Activity icon

Replied to How To Convert This Query Into Laravel Eloquent Or Query Builder Way?

@lia97

try this



$data = DB::table("STOCK_MATERIAL AS x")
        
        ->select('x.MATERIAL_ID', 'STOCK_MATERIAL_EPI.HOUSE_NO', 'x.TXN_DATE', 'STOCK_MATERIAL_EPI.PROGRAM_NAME', 'PUR_EPISODE_HDR.EPI_NO', 'x.REMARKS', 'x.LOCATION_ID as shelf_no', 'stock_material_slag.remarks as short_list', 

		DB::raw("(SELECT TAPET_NAME FROM MA_TAPE_TYPE WHERE TAPET_CODE = x.MATERIAL_TYPE) as media_type"),

		DB::raw("(SELECT TAPEF_NAME FROM MA_TAPE_FORMAT WHERE TAPEF_CODE = x.MATERIAL_FORMAT) as media_format"),

		DB::raw("(SELECT MAX (last_date) FROM run_master WHERE run_master.row_id_epi = PUR_EPISODE_HDR.row_id AND run_master.run_aired = 'Y') as last_tx,"),
	            
	    DB::raw('CASE 	WHEN x.iden_flag = 'P' THEN STOCK_MATERIAL_EPI.epi_title 	WHEN x.iden_flag = 'C' THEN STOCK_MATERIAL_EPI.prod_version_name 	WHEN x.iden_flag = 'M' THEN STOCK_MATERIAL_EPI.promo_name  END as episode_title'))


->leftJoin('STOCK_MATERIAL_EPI', 'x.MATERIAL_ID', '=', 'STOCK_MATERIAL_EPI.MATERIAL_ID')
->leftJoin('stock_material_slag', 'x.MATERIAL_ID', '=', 'stock_material_slag.MATERIAL_ID')
->leftJoin('PUR_EPISODE_HDR', 'STOCK_MATERIAL_EPI.ROW_ID_EPI', '=', 'PUR_EPISODE_HDR.ROW_ID')
->get();


Activity icon

Replied to How This Query Works For Eloquent

Hello @lia97

try this



$data = DB::table("STOCK_MATERIAL AS x")
        
        ->select('x.MATERIAL_ID', 'STOCK_MATERIAL_EPI.HOUSE_NO', 'x.TXN_DATE', 'STOCK_MATERIAL_EPI.PROGRAM_NAME', 'PUR_EPISODE_HDR.EPI_NO', 'x.REMARKS', 'x.LOCATION_ID as shelf_no', 'stock_material_slag.remarks as short_list', 

		DB::raw("(SELECT TAPET_NAME FROM MA_TAPE_TYPE WHERE TAPET_CODE = x.MATERIAL_TYPE) as media_type"),

		DB::raw("(SELECT TAPEF_NAME FROM MA_TAPE_FORMAT WHERE TAPEF_CODE = x.MATERIAL_FORMAT) as media_format"),

		DB::raw("(SELECT MAX (last_date) FROM run_master WHERE run_master.row_id_epi = PUR_EPISODE_HDR.row_id AND run_master.run_aired = 'Y') as last_tx,"),
	            
	    DB::raw('CASE 	WHEN x.iden_flag = 'P' THEN STOCK_MATERIAL_EPI.epi_title 	WHEN x.iden_flag = 'C' THEN STOCK_MATERIAL_EPI.prod_version_name 	WHEN x.iden_flag = 'M' THEN STOCK_MATERIAL_EPI.promo_name  END as episode_title'))


->leftJoin('STOCK_MATERIAL_EPI', 'x.MATERIAL_ID', '=', 'STOCK_MATERIAL_EPI.MATERIAL_ID')
->leftJoin('stock_material_slag', 'x.MATERIAL_ID', '=', 'stock_material_slag.MATERIAL_ID')
->leftJoin('PUR_EPISODE_HDR', 'STOCK_MATERIAL_EPI.ROW_ID_EPI', '=', 'PUR_EPISODE_HDR.ROW_ID')
->get();

Activity icon

Replied to Track User Links

@johnw65

try this package https://github.com/spatie/activitylog

may this could help you

Activity icon

Replied to How To Rollback Laratrust Migration

Hello @flex

try this and see the DB migration documentation https://laravel.com/docs/7.x/migrations#rolling-back-migrations

php artisan migrate:rollback

php artisan migrate:rollback --step=5

Roll Back & Migrate Using A Single Command

php artisan migrate:refresh --step=5
Jun
18
1 month ago
Activity icon

Replied to Nested Subqueries

@arnosimon try it with this


Category::with(['subCategories' => function ($query) {
                    $query::withLatestPost()->get();
                }])->get();
Jun
17
1 month ago
Activity icon

Replied to 413 (Payload Too Large)

@luis100079 try this

8388608 bytes is 8M, the default limit in PHP. Update your post_max_size in php.ini to a larger value.

upload_max_filesize sets the max file size that a user can upload while post_max_size sets the maximum amount of data that can be sent via a POST in a form.

So you can set upload_max_filesize to 1 meg, which will mean that the biggest single file a user can upload is 1 megabyte, but they could upload 5 of them at once if the post_max_size was set to 5.

May
17
2 months ago
Activity icon

Replied to Listen For Broadcast Leave In Backend

@ziroy

see the documentation

https://laravel.com/docs/6.x/broadcasting

if you share your code here

Activity icon

Replied to Created At Timestamp Is Null When Retrieve

@muazzamazaz

try this

try{
		
		$input = $request["date"].' '.$request["time"]; 
		
		$newDate= DateTime::createFromFormat('d/m/Y H:i:s',$input);     
		$created_date = $newDate->format('Y-m-d H:i:s'); // for example

		$SensorData = SensorData::create([
			'sensor_id' => $request['sensor']['id'],            
			'created_at' => $created_date,
		]);
	}
May
05
3 months ago
May
03
3 months ago
Activity icon

Awarded Best Reply on How To Post A Question?

@rushand

it very easy

you type your question in as you are typing but when you add your code just start with three backticks and end with three backticks

this key is located above on tab and left site of 1 in your keyboard

enjoy !!!! & welcome to the community 

May
02
3 months ago
Activity icon

Replied to How To Post A Question?

@rushand

it very easy

you type your question in as you are typing but when you add your code just start with three backticks and end with three backticks

this key is located above on tab and left site of 1 in your keyboard

enjoy !!!! & welcome to the community 

May
01
3 months ago
Activity icon

Replied to Laravel HTTP::post() Not Working With `body`

@radicalactivity

this $response = Http::post('https://domain.com', ['body' => '{ test: 1 }']);

seems good, I think you need to check your API endpoint on postman maybe your API not response and maybe it gets data some other ways like header

$response = Http::withHeaders([
    'X-First' => 'foo',
    'X-Second' => 'bar'
])->post('http://test.com/users', [
    'name' => 'Taylor',
]);

Apr
29
3 months ago
Activity icon

Replied to How Can I Do A Laravel Filter That Accepts Two Inputs Or Just One

@yamato

try this

	if ($request->filled('name')) {
           // 
        }

        if ($request->filled('group')) {
         //
        }

or if you want to search both you can try this 

        $students = $students->where('group', $request->group)->orWhere('name', $request->name);
Apr
28
3 months ago
Apr
26
3 months ago
Activity icon

Replied to Pivot Table Extra Column

@shuvobhai

create a migration for where you will add new fields

and do following this


$purchase->SupplierProducts()->sync($request->product_id, json_encode(['cartoon'=> $request->cartoon,
                                                                'qty'=> $request->qty,
                                                                'rate'=> $request->rate,
                                                                'total'=> $request->total]));
Activity icon

Replied to Get Rid Of Time In A Date In Blade

@swimmer

use Carbon class, this will work for you


{{ Carbon::createFromFormat('Y-m-d', $val['created_at']); }}
Activity icon

Replied to Pivot Table Extra Column

@shuvobhai

oh you have change the original msg let me find out from your controller

Activity icon

Replied to Pivot Table Extra Column

@shuvobhai

try this


$user = App\User::find(1);

foreach ($user->roles as $role) {
    echo $role->pivot->created_at;
}

return $this->belongsToMany('App\Role')->withPivot('column1', 'column2');


return $this->belongsToMany('App\Role')->withTimestamps();
Apr
24
3 months ago
Activity icon

Replied to Laravel 7 Components - Merge Css On Conditions

@ftina

call your helper function like this in your blade file


<a href="#" class="nav-item flex flex-align-center {{ (new \App\yourpath\activeLink('/','active'))  }}">


Apr
23
3 months ago
Activity icon

Replied to Update Or Create

@bluebeard

try updateOrCreate like this

// If there's a flight from Oakland to San Diego, set the price to .
// If no matching model exists, create one.
$flight = App\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99, 'discounted' => 1]
);

Apr
22
3 months ago
Activity icon

Replied to Need Help Sending Email

@hjortur17

there is a new feature for email notification or even other notification ion Laravel

see their documentation

https://laravel.com/docs/7.x/notifications

Activity icon

Replied to Creating A Blog With Images

@gouseferoz

if you are using paid version of TinyMce editor then there is an option to upload the image

otherwise, you should paste an image tag like this


<img src="your path" title="" />

```
Apr
17
3 months ago
Activity icon

Replied to Patch

@davy_yg

The main difference between the PUT and PATCH method is that the PUT method uses the request URI to supply a modified version of the requested resource which replaces the original version of the resource whereas the PATCH method supplies a set of instructions to modify the resource.

Activity icon

Awarded Best Reply on (Laracast) Render Dynamic Data 2 - Stuck!

Hello @pt-83

here is an issue in your code

    $blogs = App\Blog::take(3)->latest()->get();
        
    replace with following 
    
    $blogs = DB::table('blogs')->take(3)->latest()->get();

furthermore please create one more blade.php file for showing all or blogs

Apr
16
3 months ago
Activity icon

Awarded Best Reply on Resorce File Returning Array As Object

@arkhokhar

Try this

return [
                            'item_id' => $this->item_id,   
                            'item_name' => $this->item_name,
                            'item_price' => '$'.$this->item_price,
                            'image_url' => $this->item_image_url,
                            'item_quantity' => $this->item_quantity,
                            'item_instruction' => $this->item_instruction,
                            'sub_menu' => [$sub_menu],
                          ];

Activity icon

Replied to Resorce File Returning Array As Object

@arkhokhar

Try this

return [
                            'item_id' => $this->item_id,   
                            'item_name' => $this->item_name,
                            'item_price' => '$'.$this->item_price,
                            'image_url' => $this->item_image_url,
                            'item_quantity' => $this->item_quantity,
                            'item_instruction' => $this->item_instruction,
                            'sub_menu' => [$sub_menu],
                          ];

Apr
11
3 months ago
Activity icon

Replied to Where Condition On One To Many In Laravel Eloquent

@engrlaravel

try this

$teams = App\Team::where('created_by', Auth::id())
               ->orderBy('id', 'desc')
               ->take(10)
               ->get();
$teams = App\Team::with(['TeamMember' => function ($query) {
    $query->where('user_id', Auth::id());
}])->where('created_by', Auth::id())
               ->orderBy('id', 'desc')
               ->take(10)
               ->get();
Apr
07
4 months ago
Activity icon

Replied to Resource API Data

@brunitosessa

here how you will add the calculate distance function in your controller

class BarController extends Controller
{
    public function index(Request $request) {
        $lat = $request->input('lat',0);
        $lng = $request->input('lng',0);

        $distance = $this->calculateDistance($lat, $lng);

        $request->request->add(['distance' => $distance]);

        return [
        	'estado' => 1,
        	'bares' => BarResource::collection(Bar::All()),
        ];   
    }

    protected function calculateDistance($lat, $lng) 
	{ 
		//your calculation code 
			
		return $distance; 
	} 
Activity icon

Replied to It Returns 404 For The Public Directory.

Hi @analien

where are your style file located

try this one

<link rel="stylesheet" href="{{ asset('css/my-style.css') }}">
Apr
05
4 months ago
Activity icon

Replied to Resource API Data

@brunitosessa

you should create it in you controller or if you are using any pattern you should it in that particular pattern file

if you share you controller or pattern file I can help you

Apr
04
4 months ago
Activity icon

Awarded Best Reply on ERROR: Call To A Member Function FullName() On Null

Hello @noblemfd

you need to create you accessor correct format in your model class

like this

public function getFullNameAttribute()
{
    return $this->first_name . ' ' . $this->other_name . ' ' . $this->last_name;
}

and call it in your view class

{{ $employee->linemanager->fullName() ?? 'None' }}
Activity icon

Replied to How To Upload Json File And Extract In Laravel 7

@nafeeur10

check your form HTML in the Blade file. it should be this

enctype="multipart/form-data"

and 2nd point may be an issue in this path public_path('uploads'),

run this command following

php artisan storage:link

Activity icon

Replied to Resource API Data

@brunitosessa

here is the solution to calculate the distance between two points

<?php 
		
	function twopoints_on_earth($latitudeFrom, $longitudeFrom, 
									$latitudeTo, $longitudeTo) 
	{ 
		$long1 = deg2rad($longitudeFrom); 
		$long2 = deg2rad($longitudeTo); 
		$lat1 = deg2rad($latitudeFrom); 
		$lat2 = deg2rad($latitudeTo); 
			
		//Haversine Formula 
		$dlong = $long2 - $long1; 
		$dlati = $lat2 - $lat1; 
			
		$val = pow(sin($dlati/2),2)+cos($lat1)*cos($lat2)*pow(sin($dlong/2),2); 
			
		$res = 2 * asin(sqrt($val)); 
			
		$radius = 3958.756; 
			
		return ($res*$radius); 
	} 

	// latitude and longitude of Two Points 
	$latitudeFrom = 19.017656 ; 
	$longitudeFrom = 72.856178; 
	$latitudeTo = 40.7127; 
	$longitudeTo = -74.0059; 
		
	// Distance between Mumbai and New York 
	print_r(twopoints_on_earth( $latitudeFrom, $longitudeFrom, 
					$latitudeTo, $longitudeTo).' '.'miles'); 

// This code is contributed by akash1295 
// https://auth.geeksforgeeks.org/user/akash1295/articles 
?> 

https://www.geeksforgeeks.org/program-distance-two-points-earth/

Activity icon

Replied to ERROR: Call To A Member Function FullName() On Null

Hello @noblemfd

you need to create you accessor correct format in your model class

like this

public function getFullNameAttribute()
{
    return $this->first_name . ' ' . $this->other_name . ' ' . $this->last_name;
}

and call it in your view class

{{ $employee->linemanager->fullName() ?? 'None' }}
Mar
24
4 months ago
Activity icon

Started a new Conversation I Got DNS_PROBE_FINISHED_NXDOMAIN Error When I Access Domain Through Laravel Valet

Hello

I'm facing DNS_PROBE_FINISHED_NXDOMAIN error when I access the domain blog.test

I do the following steps

sudo brew services stop nginx

sudo brew services stop [email protected]

sudo brew services stop dnsmasq

valet install

and its start my PHP, dnsmasq , and nginx but still facing the error DNS_PROBE_FINISHED_NXDOMAIN

Mar
20
4 months ago
Activity icon

Replied to How To Refactor This Code?

@armani

Please share output of $request->all()

Mar
19
4 months ago
Activity icon

Awarded Best Reply on Error On DB Where!

@randy_johnson

try this, you miss actually get method in your statement

$data = DB::table($this->tablex)->where('user_id', Auth::user()->id)->get();