iki

iki

Member Since 1 Year Ago

ismailia

Experience Points 5,040
Experience Level 2

4,960 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 28
Lessons
Completed
Best Reply Awards 0
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.

30 Jul
3 weeks ago

iki left a reply on Laravel Scout With Nova !

@aurawindsurfing lol , in the serious he just added the searchable trait to the model so i supposed its supported

https://laracasts.com/series/laravel-nova-mastery/episodes/8,

is there a way to use the fuzzy search without using scout ?

iki started a new conversation Laravel Scout With Nova !

in laravel nova i wanna use the scout and fuzzy search i added the searchable trait to the model but it says scout searchable not found , so i installed the scout but now it asks me for algolia ids and also indexes ! isnt it supposed to be supported by nova out of the box ?

15 Jul
1 month ago

iki started a new conversation Nova With Mongodb

anyone got nova to work with mongodb ?

when trying to add it says call to function prepare of null , cause they are using transactions , anyone could get it to work ?

13 May
3 months ago

iki left a reply on Laravel Pagination On Json Response

can u provide some screenshots please?

iki started a new conversation Laravel Pagination Meta Data Not Showing

hey guys ,

am using laravel api resources with my collection and pagination it all works fine when i return the apiresource directly but when am trying to pass the response to my custom api response function the pagination data disappear , i searched it and found that because it gets double wrapped , but i dont know how to fix it cause i need to pass it to that function , below code to explain more

resource collection

public function toArray($request)
    {
        $this->collection->transform(function (Laundry $laundry) {
            return [
                'id' => $laundry->id,
                'name' => $laundry->name,
                'description' => $laundry->description,
                'lat' => $laundry->lat,
                'lng' => $laundry->lng,
                'address' => $laundry->address,
                'has_offers' => $laundry->has_offers,
                'phone' => $laundry->phone,
                'email' => $laundry->email,
                'docs' => new LaundriesDocsResourceCollection($laundry->docs),
                'services' => new LaundriesServicesResourceCollection($laundry->services),
            ];
        });
        return $this->collection->toArray();

    }

my controller

  $laundries = Laundry::where('verified', 1)->where('expire_date','>=',Carbon::today())
            ->when($request->has_offer,function ($laundry){
                return $laundry->where('has_offers',1) ;
            })->when($request->lat && $request->lng,function ($laundry){
                // TODO:: implement filtering by lat and long logic
                return 'under implementation';
            })
            ->paginate($request->per_page ? $request->per_page : 5);
        return apiResponse(200, 'المغاسل', new LaundriesResourceCollection($laundries), true); 

my helper function

if (!function_exists('apiResponse')) {
    function apiResponse($status, $msg, $data = null, $force_data = false)
    {
        if (!$data && !$force_data) {
            return [
                'status' => $status,
                'msg' => $msg,
            ];
        } else {
            return [
                'status' => $status,
                'msg' => $msg,
                'data' => $data
            ];
        }
    }
};
09 May
3 months ago

iki left a reply on Laravel Belongs To Many Data Missing Error

@SNAPEY - to see all the data , cause i dont know why it gives me that error , i searched on it and i found that it is an carbon error , anyway i solved it , thanks anyway

iki started a new conversation Laravel Belongs To Many Data Missing Error

I'm trying to get data from a Many to Many Relationship using Eloquent in Laravel. Every time I do this I get a Data Missing error.

I've tried the following to get the data:

return  $workers = Worker::first()->workers_sub_categories;
return $workers = Worker::with('workers_sub_categories')->get();

Both of these result in the DataMissing error.

Database migration :

$table->bigIncrements('workers_services_id');
       $table->bigInteger('FK_workers_id')->unsigned();
       $table->bigInteger('FK_sub_categories_id')->unsigned();

       $table->foreign('FK_workers_id')->references('workers_id')->on('workers')
           ->onDelete('cascade');
       $table->foreign('FK_sub_categories_id')->references('sub_categories_id')->on('sub_categories')
           ->onDelete('cascade');

The Worker model:

protected $table="workers";

protected $primaryKey='workers_id';

const CREATED_AT = 'workers_created_at';
const UPDATED_AT = 'workers_updated_at';

protected $fillable = [
   'workers_username', 'email', 'password', 'FK_cities_id',
   'FK_packages_id', 'workers_points', 'jwt', 'workers_img',
   'workers_lat', 'workers_lang', 'workers_phone_number',
   'workers_businessregister', 'workers_desc', 'remember_token',
   'workers_status', 'workers_verified', 'step', 'expiry_date','workers_created_at','workers_updated_at'    ];

public function related_orders(){
   return $this->hasMany('App\Models\Order', 'FK_workers_id', 'workers_id');
}

public function related_offers(){
   return $this->hasMany('App\Models\Offer', 'FK_workers_id', 'workers_id');

}


public function related_comments(){
   return $this->hasMany('App\Models\Comment', 'FK_workers_id', 'workers_id');

}

public function worker_orders()
{
   return $this->belongsToMany('App\Models\Order', 'orders_workers_status','FK_workers_id', 'FK_orders_id')->withPivot('FK_categories_id','FK_sub_categories_id');
}

public function related_rates(){
   return $this->hasMany('App\Models\Rate', 'FK_workers_id', 'workers_id');

}

public function related_city(){
   return $this->belongsTo('App\Models\City', 'FK_cities_id', 'cities_id');

}

public function workers_sub_categories()
{
 //  dd($this);

return $this->belongsToMany('App\Models\SubCategory', 'workers_services','FK_workers_id', 'FK_sub_categories_id');
 //  return $this->belongsToMany('App\Models\Order', 'orders_workers_status','FK_workers_id', 'FK_orders_id')->withPivot('FK_categories_id','FK_sub_categories_id');

}

public function setWorkersImgAttribute($file)
{
   if ($file) {
       $fileName = $this->createFileName($file);
       $this->originalImage($file, $fileName,'worker/profile/original');
       $this->mediumImage($file, $fileName,150,150,'worker/profile/meduim');
       $this->thumbImage($file, $fileName, 70,70,'worker/profile/thumbnail');

       $this->attributes['workers_img'] = $fileName;
   }
}

public function setWorkersBusinessRegisterAttribute($file)
{
   if ($file) {
       $fileName = $this->createFileName($file);
       $this->originalImage($file, $fileName,'worker/business/original');
       $this->mediumImage($file, $fileName,150,150,'worker/business/meduim');
       $this->thumbImage($file, $fileName, 70,70,'worker/business/thumbnail');

       $this->attributes['workers_businessregister'] = $fileName;

The SubCategories model:

protected $table="sub_categories";

protected $primaryKey='sub_categories_id';

const CREATED_AT = 'sub_categories_created_at';
const UPDATED_AT = 'sub_categories_updated_at';
protected $fillable = [
   'sub_categories_img', 'sub_categories_status', 'FK_categories_id',
];

public function workers_categories()
{
   return $this->belongsToMany('App\Models\Worker', 'workers_services','FK_sub_categories_id', 'FK_workers_id');
}

protected function getArrayableAttributes()
{
   foreach ($this->attributes as $key => $value) {
       if ( is_null($value) ) {
           $this->attributes[$key] = "";
       }
   }
   return $this->getArrayableItems($this->attributes);
}

public function related_category(){

   return $this->belongsTo('App\Models\Category', 'FK_categories_id', 'categories_id');

}

public function getSubCategoriesImgAttribute()
{
   return SiteImages_path('subcategory') . '/thumbnail/' . $this->attributes['sub_categories_img'];

}
The database migration:

       $table->bigIncrements('workers_services_id');
       $table->bigInteger('FK_workers_id')->unsigned();
       $table->bigInteger('FK_sub_categories_id')->unsigned();

       $table->foreign('FK_workers_id')->references('workers_id')->on('workers')
           ->onDelete('cascade');
       $table->foreign('FK_sub_categories_id')->references('sub_categories_id')->on('sub_categories')
           ->onDelete('cascade');

It's supposed to return all workers with pivot.

01 Apr
4 months ago

iki left a reply on Solid Principles

@KEL_ - thank you for explaining it

iki started a new conversation Solid Principles

hey guys ,

i have a question in the solid principles , its about the single class responsibility , in laravel integrated auth they created 5 controllers or classes to handle the auth system , one for login , one for register , etc , and that follow the single class responsibility but should i follow that in other controller like posts for example ? should i make controller for add and one for edit and one for delete ? or i created only one for all posts functions and that its responsibility if i should create only one , why dont we create only one for Auth and contains its responsibility ?

25 Mar
4 months ago

iki started a new conversation Google Maps Not Working

hey guys i am trying to show google maps and it works but when i try to use it withing foreach its not working thats the code and help

<div class="row">
                                            <input  type="text" id="loc_{{$drug->id}}" class="form-control edit_map"
                                                   placeholder="المكان علي الخريطه" value="{{ $drug->address_ar }}"
                                                   aria-describedby="sizing-addon3" id="location_{{$drug->id}}">
                                            <div class="col-12">
                                                <div  id="map-canvas_{{$drug->id}}" d_id="{{$drug->id}}"></div>
                                                <input type="hidden" value="{{$drug->lat}}" name="lat" id="lat_{{$drug->id}}"/>
                                                <input type="hidden" value="{{$drug->long}}" name="long" id="lng_{{$drug->id}}"/>
                                                <input type="hidden" value="{{$drug->address_en}}" id="loc_{{$drug->id}}"/>
                                            </div>
                                        </div>
    <script>
        $.each($('.edit_map'),function (index,value) {

            let id = $(this).attr('d_id') ;

            var map, marker, infoWindow, latInp, lngInp, locInp;

            function init() {
                latInp = $('#lat_'+id);
                lngInp = $('#lng_'+id);
                locInp = $('#loc_'+id);

                var mapOptions = {
                    zoom: 9,
                    mapTypeControl: true,
                    mapTypeControlOptions: {
                        style: google.maps.MapTypeControlStyle.VERTICAL_BAR,
                        position: google.maps.ControlPosition.RIGHT_BOTTOM
                    },
                    zoomControl: true,
                    zoomControlOptions: {
                        position: google.maps.ControlPosition.LEFT_CENTER
                    },
                    scaleControl: true,
                    streetViewControl: true,
                    streetViewControlOptions: {
                        position: google.maps.ControlPosition.LEFT_TOP
                    },
                    fullscreenControl: true,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    scrollwheel: false
                };

                map = new google.maps.Map(document.getElementById('map-canvas_'+id), mapOptions);

                // Create the DIV to hold the control and call the constructor passing in this DIV
                var geolocationDiv = document.createElement('div');
                var geolocationControl = new GeolocationControl(geolocationDiv, map);

                map.set('styles', [{
                    "featureType": "administrative",
                    "elementType": "labels.text.fill",
                    "stylers": [
                        {
                            "color": "#444444"
                        }
                    ]
                },
                    {
                        "featureType": "landscape",
                        "elementType": "all",
                        "stylers": [
                            {
                                "color": "#f2f2f2"
                            }
                        ]
                    },
                    {
                        "featureType": "poi",
                        "elementType": "all",
                        "stylers": [
                            {
                                "visibility": "off"
                            }
                        ]
                    },
                    {
                        "featureType": "road",
                        "elementType": "all",
                        "stylers": [
                            {
                                "saturation": -100
                            },
                            {
                                "lightness": 45
                            }
                        ]
                    },
                    {
                        "featureType": "road.highway",
                        "elementType": "all",
                        "stylers": [
                            {
                                "visibility": "simplified"
                            }
                        ]
                    },
                    {
                        "featureType": "road.arterial",
                        "elementType": "labels.icon",
                        "stylers": [
                            {
                                "visibility": "off"
                            }
                        ]
                    },
                    {
                        "featureType": "transit",
                        "elementType": "all",
                        "stylers": [
                            {
                                "visibility": "off"
                            }
                        ]
                    },
                    {
                        "featureType": "water",
                        "elementType": "all",
                        "stylers": [
                            {
                                "color": "#46bcec"
                            },
                            {
                                "visibility": "on"
                            }
                        ]
                    }, {
                        "featureType": "administrative.country",
                        "elementType": "geometry",
                        "stylers": [
                            {
                                "visibility": "simplified"
                            },
                            {
                                "hue": "#ff0000"
                            }
                        ]
                    }]);
                map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(geolocationDiv);
                map.controls[google.maps.ControlPosition.TOP_CENTER].push(locInp[0]);
                if (navigator.geolocation && latInp && lngInp) {
                    addSearchBox();

                    map.addListener('click', function (p) {
                        resolvePlace(p.latLng);
                    });

                    lat = latInp.val();
                    lng = lngInp.val();
//        address = locInp.val();
                    if (lat.length && lng.length) {
                        success({formatted_address: locInp.val()}, new google.maps.LatLng(lat, lng));
                    } else {
                        map.setCenter(new google.maps.LatLng(30, 30));
                    }
                }


            }
            function GeolocationControl(controlDiv, map) {
                // Set CSS for the control button
                var controlUI = document.createElement('div');
                controlUI.style.backgroundColor = '#444';
                controlUI.style.borderStyle = 'solid';
                controlUI.style.borderWidth = '1px';
                controlUI.style.borderColor = 'white';
                controlUI.style.height = '28px';
                controlUI.style.marginTop = '5px';
                controlUI.style.cursor = 'pointer';
                controlUI.style.textAlign = 'center';
                controlUI.title = ' ';
                controlDiv.appendChild(controlUI);

                // Set CSS for the control text
                var controlText = document.createElement('div');
                controlText.style.fontFamily = 'Arial,sans-serif';
                controlText.style.fontSize = '10px';
                controlText.style.color = 'white';
                controlText.style.paddingLeft = '10px';
                controlText.style.paddingRight = '10px';
                controlText.style.marginTop = '8px';
                controlText.innerHTML = ' ';
                controlUI.appendChild(controlText);

                // Setup the click event listeners to geolocate user
                google.maps.event.addDomListener(controlUI, 'click', geolocate);

            }

            function geolocate() {

                if (navigator.geolocation) {

                    navigator.geolocation.getCurrentPosition(function (position) {

                        var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

                        resolvePlace(pos);
                    }, function () {
                        handleLocationError(true, infoWindow, map.getCenter());
                    });

                } else {
                    // Browser doesn't support Geolocation
                    handleLocationError(false, infoWindow, map.getCenter());
                }
            }

            function resolvePlace(pos) {

                var geocoder = new google.maps.Geocoder;
                geocoder.geocode({'location': pos}, function (results, status) {
                    if (status === google.maps.GeocoderStatus.OK) {
                        if (results[0]) {
                            success(results[0], pos);
                        } else {
                            error('No results found');
                        }
                    } else {
                        error(status);
                    }
                });

            }

            function error(status) {
                // window.alert('Geocoder failed due to: ' + status);
            }

            function success(place, pos) {

                if (marker) {
                    marker.setMap(null);
                    infoWindow.close();
                }

                marker = new google.maps.Marker({
                    title: place.formatted_address,
                    draggable: true,
                    animation: google.maps.Animation.DROP,
                    map: map,
                    position: pos
                });

                marker.addListener('mousedown', function () {
                    infoWindow.close();
                });
                marker.addListener('mouseup', function () {
                    var latlng = marker.getPosition();
                    latInp.val(latlng.lat);
                    lngInp.val(latlng.lng);

                    var geocoder = new google.maps.Geocoder;
                    geocoder.geocode({'location': latlng}, function (results, status) {
                        if (status === google.maps.GeocoderStatus.OK) {
                            if (results[0]) {
                                infoWindow.setPosition(latlng);
                                infoWindow.setContent(results[0].formatted_address);
                                locInp.val(results[0].formatted_address);
                                $('#location_'+id).val(results[0].formatted_address);
                                infoWindow.open(map, marker);
                            } else {
                                alert('No results found');
                            }
                        }
                    });
                });

                infoWindow = new google.maps.InfoWindow({map: map});
                infoWindow.setPosition(pos);
                infoWindow.setContent(place.formatted_address);
                map.setCenter(pos);
                infoWindow.open(map, marker);

                //update lat and lng
                latInp.val(pos.lat);
                lngInp.val(pos.lng);
                locInp.val(place.formatted_address);

            }

            function handleLocationError(browserHasGeolocation, infoWindow, pos) {
                infoWindow.setPosition(pos);
                infoWindow.setContent(browserHasGeolocation ? 'Error: The Geolocation service failed.' : 'Error: Your browser doesn\'t support geolocation.');
            }

            function addSearchBox() {

                // Create the search box and link it to the UI element.
                var searchBox = new google.maps.places.SearchBox(locInp[0]);

                // Bias the SearchBox results towards current map's viewport.
                map.addListener('bounds_changed', function () {
                    searchBox.setBounds(map.getBounds());
                });

                // Listen for the event fired when the user selects a prediction and retrieve
                // more details for that place.
                searchBox.addListener('places_changed', function () {
                    var places = searchBox.getPlaces();

                    if (places.length == 0) {
                        return;
                    }

                    // For each place, get the icon, name and location.
                    var bounds = new google.maps.LatLngBounds();
                    places.forEach(function (place) {
                        if (!place.geometry) {
                            console.log("Returned place contains no geometry");
                            return;
                        }

                        success({formatted_address: locInp.val()}, place.geometry.location);

                        if (place.geometry.viewport) {
                            // Only geocodes have viewport.
                            bounds.union(place.geometry.viewport);
                        } else {
                            bounds.extend(place.geometry.location);
                        }
                    });
                    map.fitBounds(bounds);
                });
            }
        });

    </script>
20 Mar
5 months ago

iki left a reply on Helper Function Not Working Within My Package

still not working

  "files": [
            "src/Helpers/helper.php"
        ]

iki left a reply on Helper Function Not Working Within My Package

the path is packages/iki/fixedAdmin/src/Helpers/helper.php

iki left a reply on Helper Function Not Working Within My Package

@RICHARD - its not within my app directory its withing my package directory in the src and thats in the package composer

iki left a reply on Helper Function Not Working Within My Package

@RICHARD - i did and still not working

iki started a new conversation Helper Function Not Working Within My Package

hey guys i added this code within my package composer.json and it still not reading the file or loading it


"autoload": {
        "psr-4": {
            "iki\fixedAdmin\": "src/"
        },
        "files": [
            "Helpers/helper.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "iki\fixedAdmin\Tests\": "tests"
        }
    },

iki started a new conversation Using Multi Auth While Creating A Package

hey guys i am trying to create a laravel package and within this package am using multi auth and i want to overwrite the auth.php in the config with my auth.php i tried this but didnt work

$this->app['config']['auth'] =  \Config::get('iki::auth');
02 Feb
6 months ago

iki left a reply on Json Error

@D9705996 - yes it was outside my <php . thank you so much <3

iki left a reply on Json Error

the problem is , i didnt touch this file today , it was a simple update on the app so i made it live on the server , i created a migration file and a model and a view and made routes for them , dk what happened

iki left a reply on Json Error

@D9705996 -

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;


class AppServiceProvider extends ServiceProvider
{
   /**
    * Bootstrap any application services.
    *
    * @return void
    */
   public function boot()
   {
       Schema::defaultStringLength(191);

   }

   /**
    * Register any application services.
    *
    * @return void
    */
   public function register()
   {
       //
   }
}

iki left a reply on Json Error

@D9705996 - it appears in both web and api routes , what could be in both of them ?

iki started a new conversation Json Error

s{"status":{"type":"Error","title":"No Token"}} hey guys , am having this "s" at the first of any json response in my app , it returns in different controllers , pages , site and api , i dont know what is this s ! any thoughts ?

also in my application like this

sMigrating: 2019_02_02_143415_create_service_requests_table
Migrated:  2019_02_02_143415_create_service_requests_table
php artisan migrate 
sMigrating: 2019_02_02_143415_create_service_requests_table
Migrated:  2019_02_02_143415_create_service_requests_table
php artisan config:cach
sConfiguration cache cleared!
sConfiguration cached successfully!
26 Jan
6 months ago

iki started a new conversation Pignose Calendar Problem

hey guys , i am currently trying to customize the pignose calendar https://www.pigno.se/barn/PIGNOSE-Calendar/

and am having troubles setting the disabledDates or disabledRanges dynamically , i am retrieving the dates or the range that should be disabled via ajax but when i try to insert the data to them it doesnt work and only works when i type it statically , any advices ?

19 Dec
8 months ago

iki started a new conversation Laravel Mix

trying to run npm run dev and i get this error

http://prntscr.com/lwxo45

and thats my code

mix.styles([
    'public/admin/assets/vendors/base/vendors.bundle.rtl.css',
    'public/admin/assets/demo/default/base/style.bundle.rtl.css',
    'public/admin/css/style-m.css',
], 'public/css/all.css');

mix.js([
    'public/admin/assets/vendors/base/vendors.bundle.js',
    'public/admin/assets/demo/default/base/scripts.bundle.js',
    'public/admin/assets/app/js/dashboard.js',
],'public/js/all.js');
09 Dec
8 months ago

iki left a reply on Pagination On SortBy()

found the answer to perform pagination on collection

 public function paginate($items, $perPage = 15, $page = null)
    {
        $pageName = 'page';
        $page = $page ?: (Paginator::resolveCurrentPage($pageName) ?: 1);
        $items = $items instanceof Collection ? $items : Collection::make($items);
        return new LengthAwarePaginator(
            $items->forPage($page, $perPage)->values(),
            $items->count(),
            $perPage,
            $page,
            [
                'path' => Paginator::resolveCurrentPath(),
                'pageName' => $pageName,
            ]
        );
    }

iki started a new conversation Pagination On SortBy()

hey guys

  $member = auth()->guard('members')->user();
        $doctors = Member::where('type', 0)->where('approve', 1)->where('city_id', '!=', null)->where('id', '!=', auth()->guard('members')->id())->orderByRaw("FIELD(city_id , $member->city_id) DESC")->paginate(10);
        foreach ($doctors as $doctor){
            $doctor['rate'] = $doctor->getRate();
        }

        $doctors = $doctors->sortByDesc('rate');

when i try this , it gives me that error ,

Method Illuminate\Database\Eloquent\Collection::links does not exist. (View: C:\xampp\htdocs\taheel\resources\views\site\pages\order\index.blade.php)


iki left a reply on Laravel Show Nearest Products First ?

thanks guys , your comments really helped

iki started a new conversation Laravel Show Nearest Products First ?

hey guys ,

i have a store website with every products has its lat and long , and i have the lat and long of the logged in user , my question is, how to show the products that is near to the logged in user first ?

03 Oct
10 months ago

iki left a reply on Many To Many Filter Problem

thats create ,thanks i really learned a lot out of this

02 Oct
10 months ago

iki left a reply on Many To Many Filter Problem

there is just one thing that i dont understand , when we use whereHas('color') it brings all the products that have colors , so in the query why did we write ('id',$colors) , i mean colors is the colors id , so does that check the color id in the colors table then gets the relative products from the relation or what ? @Artak @MikeMacDowell

iki left a reply on Many To Many Filter Problem

@Artak that really helped thanks

01 Oct
10 months ago

iki left a reply on Many To Many Filter Problem

@MikeMacDowell it actually worked , after i removed the id column but to be honest idk what i wrote , so can u explain the code u provided to me so i understand it and dont ask the same question again please ?

iki left a reply on Many To Many Filter Problem

@MikeMacDowell


        if ($colors)
        {
//            $data = array();
//            foreach ($colors as $color) {
//                $color = Color::where('id', $color)->first();
//                $checker = $color->product;
//                foreach ($checker as $checked)
//                    if ($checked->is_active == 1)
//                array_push($data, $checked);
//            }
//            dd($products);
//            $products = collect($data);
            
            $products->whereHas('color', function($query) use ($colors) {
                $query->whereIn('id', $colors);
            });



        }
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (SQL: select count(*) as aggregate from `products` where `is_active` = 1 and `section_id` = 2 and exists (select * from `colors` inner join `color_product` on `colors`.`id` = `color_product`.`color_id` where `products`.`id` = `color_product`.`product_id` and `id` in (4, 2)))

i can check multiple checkboxes , like multi colors , and even when i check one box i get the same error

iki started a new conversation Many To Many Filter Problem

i have 3 tables , colors , products and color_product with many to many relation , my problem is that i have a filter where the user can choose more than one color with the rest of the filter options how i filter the data with the selected colors, code will explain more

http://prntscr.com/l0vzim

http://prntscr.com/l0vzy8

http://prntscr.com/l0w02x

http://prntscr.com/l0w093


 public function filter(Request $request)

    {
        $sections = Section::all();
        $section = $request->section_id;
        $min = $request->min;
        $max = $request->max;
        $colors = $request->color_id;

        $products = Product::where('is_active', 1);
        if ($section)
            $products->where('section_id', $section);
        if ($min)
            $products->where('price_after', '>=', $min);
        if ($max)
            $products->where('price_after', '<=', $max);
//        if ($colors)
//            foreach ($colors as $color) {
//
//
//
////                $color = Color::where('id', $color)->first();
////                $checker = $color->product;
////                foreach($checker as $products)
//////                $products = $product->where('is_active', 1)->get();
////                if ($products->is_active == 1)
////                if ($section)
////                    $products->where('section_id', $section);
////                if ($min)
////                    $products->where('price_after', '>=', $min);
////                if ($max)
////                    $products->where('price_after', '<=', $max);
//            }

        $filter = $products->paginate(9);
 
        return view('site.filter', compact('filter', 'sections'));
    }


<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
     protected  $fillable=[

             'name',
             'code',
             'price_before',
             'price_after',
             'quantity',
             'section_id',
             'category',
             'description',
             'img',
         ];

     public function color()
     {

         return $this->belongsToMany('App\Color');

     }
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Color extends Model
{
     protected  $fillable=[

             'name',

         ];

    public function product()
    {

        return $this->belongsToMany('App\Product');

    }
}

iki left a reply on Real Time Notification Problem

@wilk_randall what code u need to see ?

30 Sep
10 months ago

iki started a new conversation Real Time Notification Problem

hey guys ,

i have a problem after creating my real time notification using vue and pusher all things working perfect , and the notification is pushed and all is good except that when my app.js is not commented out , the whole projects dont work , like when i press on buttons it doesnt work and when i comment it out all works but the notifications is not working , and there is no errors in log , like it overwrites on them

22 Sep
10 months ago

iki left a reply on Google Maps

thanks guys

iki started a new conversation Google Maps

hey guys , i have a map table in my data base with the lat and long saved , my question is , how i show it in my website with the lat and long coulmns

16 Sep
11 months ago

iki left a reply on One To Many Relation Not Working

it gives back a relation now after i added the same relation at the other other but it returns it empty

iki started a new conversation One To Many Relation Not Working

hey guys i have 3 tables

site_users

site_notifications

site__users__notifactions

in site__users__notifactions

i have user_id and notification_id

and i have a relation in the SiteUser Model as follow

public function get_notifications()

    {
        return $this->hasMany('App\Site_Users_Notifaction','user_id');
    }

when i try to call the relation in my blade like

@foreach($notifications as $notification)

{{dd($notification->get_notifications())}}

     @endforeach 

it gives me that error

Method Illuminate\Database\Query\Builder::get_notifications does not exist. (View: C:\xampp\htdocs\myspare\resources\views\site\notifications.blade.php)

and when i remove the () from the relation it gives null

11 Sep
11 months ago
10 Sep
11 months ago

iki started a new conversation Auth Login Not Working

hey guys i have created two tables users table and SiteUsers table ,

now i have added the site users to auth like this

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Authentication Defaults
    |--------------------------------------------------------------------------
    |
    | This option controls the default authentication "guard" and password
    | reset options for your application. You may change these defaults
    | as required, but they're a perfect start for most applications.
    |
    */

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    /*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    |
    | Next, you may define every authentication guard for your application.
    | Of course, a great default configuration has been defined for you
    | here which uses session storage and the Eloquent user provider.
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | Supported: "session", "token"
    |
    */

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'site_users' => [
            'driver' => 'session',
            'provider' => 'site_users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | User Providers
    |--------------------------------------------------------------------------
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | If you have multiple user tables or models you may configure multiple
    | sources which represent each model / table. These sources may then
    | be assigned to any extra authentication guards you have defined.
    |
    | Supported: "database", "eloquent"
    |
    */

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,

        ],
        'site_users' => [
            'driver' => 'eloquent',
            'model' => App\SiteUser::class,

        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Resetting Passwords
    |--------------------------------------------------------------------------
    |
    | You may specify multiple password reset configurations if you have more
    | than one user table or model in the application and you want to have
    | separate password reset settings based on the specific user types.
    |
    | The expire time is the number of minutes that the reset token should be
    | considered valid. This security feature keeps tokens short-lived so
    | they have less time to be guessed. You may change this as needed.
    |
    */

    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
        'site_users' => [
            'provider' => 'site_users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
    ],

];

and thats my code for registering ,

 public function register(Request $request)

    {

        session()->flash('register');
        if (app()->getLocale() == 'ar') {
            $this->validate($request, [

                'name' => 'required|unique:site_users,name',
                'email' => 'required|unique:site_users,email',
                'password' => 'required|min:6|max:10',
                'password_confirmation' => 'required_with:password|same:password',
                'phone' => 'required|max:20',
            ],
                [
                    'name.required' => 'برجاء إدخال إسم المستخدم',
                    'name.unique' => 'إسم المستخدم مسجل بالفعل',
                    'email.required' => 'برجاء إدخال البريد الإلكترونى',
                    'email.unique' => 'البريد الإلكترونى مسجل بالفعل',
                    'phone.required' => 'برجاء إدخال رقم الهاتف',
                    'phone.max' => 'رقم الهاتف لا يتجاوز ٢٠ رقم',
                    'password.max' => 'كلمه المرور لا تزيد عن 10 حروف',
                    'password.min' => 'كلمه المرور لا تقل عن 6 حروف',
                    'password.required' => 'برجاء إدخال كلمه السر',
                    'password_confirmation.required' => 'برجاء إدخال تاكيد كلمه السر',
                    'password_confirmation.same' => 'تاكيد كلمه السر لا تتطابق',
                ]);
        }
        if (app()->getLocale() == 'en') {

            $this->validate($request, [

                'name' => 'required|unique:site_users,name',
                'email' => 'required|unique:site_users,email',
                'password' => 'required|min:6|max:10',
                'password_confirmation' => 'required_with:password|same:password',
                'phone' => 'required|max:20',
            ],
                [
                    'name.required' => 'Please Enter The Name',
                    'password.required' => 'Please Enter The Password',
                    'password_confirmation.required' => 'Please Enter The Password Confirmation',
                    'email.required' => 'Please Enter The Email',
                    'phone.required' => 'Please Enter The Phone Number',
                    'phone.max' => 'Max Phone Number Is 20 Digits',
                    'password.max' => 'Max Password Is 10 Characters',
                    'password.min' => 'Min Password Is 6 Characters',
                    'password_confirmation.same' => 'Password Confirmation Does`\t Match',
                ]);


        }
        $input = $request->all();
        $input['password'] = bcrypt($request->password);

        $email=$input['email'];


        if ( SiteUser::create($input)) {
            $user=SiteUser::where('email','=',$email)->first();

        $credentials=array(
            'email' => $user->email,
            'password' => $user->password
        );

            if (Auth::attempt($credentials) )
            {
                return redirect('/');
            }
            else
            {

                return redirect()->back();}
            }

        if (app()->getLocale() == 'ar')
            session()->flash('error','حدث خطأ, برجاء المحاوله لاحقاً');
        if (app()->getLocale() == 'en')
            session()->flash('error','Error Occurred , Please Try Again Later ');



    }

the problem is . my Auth:attemp always return false , idk whats wrong with my code

iki left a reply on Login After Registeration

can u please explain this part "Also, make sure you set this model in the providers array in the config/auth.php file.

"

this is my first time to make two different table for admin and users and it confuses me , also why my users model is difference from SiteUsers users

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password','img',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

SiteUser

<?php

namespace App;

use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

class SiteUser extends Model implements Authenticatable
{
    use \Illuminate\Auth\Authenticatable;
    protected $fillable = [
        'name', 'email', 'password','img','phone','img'
    ];

}

iki left a reply on Login After Registeration

@wilk_randall i did this ,,

class SiteUser extends Model implements Authenticatable
{
    use \Illuminate\Auth\Authenticatable;
    protected $fillable = [
        'name', 'email', 'password','img','phone','img'
    ];

}

the error disappeared but it dont login

iki started a new conversation Login After Registeration

hey guys , i have a problem that after the user register , i want him to be logged in , the user is created successfully but after that it gives that error

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\SiteUser given, called in C:\xampp\htdocs\myspare\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 292

thats my code

$input = $request->all();
        $input['password'] = bcrypt($request->password);


        if ( $user =SiteUser::create($input)) {

            Auth::login($user);
            return redirect('/');
        }

        if (app()->getLocale() == 'ar')
            session()->flash('error','حدث خطأ, برجاء المحاوله لاحقاً');
        if (app()->getLocale() == 'en')
            session()->flash('error','Error Occurred , Please Try Again Later ');
        return redirect()->back();

iki left a reply on Helper Function

@bestmomo ok i fixed it , looks like as u said ( i used a contact variable) thanks for you time and i really appreciate it

iki left a reply on Helper Function

no i use it in my layout witch extended in all pages

iki left a reply on Helper Function

but i do xD , should i do an aliases or something , to be clear i dont get any error on my index , but when i change to another page i gets it

iki left a reply on Helper Function

maybe i am calling it with the wrong way ,

thats what in my composer.json

"files":[
            "app/Http/helpers.php"
        ],

and thats how i call it

contact()->phone