iki

Experience

1,380

0 Best Reply Awards

  • Member Since 2 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

3rd October, 2018

iki left a reply on Many To Many Filter Problem • 1 week ago

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

2nd October, 2018

iki left a reply on Many To Many Filter Problem • 1 week ago

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 • 1 week ago

@Artak that really helped thanks

1st October, 2018

iki left a reply on Many To Many Filter Problem • 2 weeks ago

@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 • 2 weeks ago

@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 • 2 weeks ago

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 • 2 weeks ago

@wilk_randall what code u need to see ?

30th September, 2018

iki started a new conversation Real Time Notification Problem • 2 weeks ago

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

22nd September, 2018

iki left a reply on Google Maps • 3 weeks ago

thanks guys

iki started a new conversation Google Maps • 3 weeks ago

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

16th September, 2018

iki left a reply on One To Many Relation Not Working • 4 weeks ago

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 • 4 weeks ago

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

11th September, 2018

iki left a reply on One To Many Relationship Problem • 1 month ago

solved

10th September, 2018

iki started a new conversation Auth Login Not Working • 1 month ago

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 • 1 month ago

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 • 1 month ago

@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 • 1 month ago

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 • 1 month ago

@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 • 1 month ago

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

iki left a reply on Helper Function • 1 month ago

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 • 1 month ago

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

iki left a reply on Helper Function • 1 month ago

Undefined variable: contact (View: C:\xampp\htdocs\myspare\resources\views\layouts\Site-Layout.blade.php) (View: C:\xampp\htdocs\myspare\resources\views\layouts\Site-Layout.blade.php)

iki left a reply on Helper Function • 1 month ago

iki left a reply on Helper Function • 1 month ago

namespace App\Http;
class helpers
{
if (!function_exists('sections'))
{
    function sections()
    {
        return \App\Section::all();
    }
}

if (!function_exists('site_data')) {
    function site_data()
    {
        return \App\SiteData::first();
    }
}

if (!function_exists('social')) {
    function social()
    {
        return \App\Social::first();
    }
}

if (!function_exists('contact')) {
    function contact()
    {
        return \App\Contact::first();
    }
}
}

this gives me errors

iki left a reply on Helper Function • 1 month ago

and thats my helpers.php

 function sections()

    {
        $all_sections=Section::all();
        return $all_sections;
    }
      function site_data()

    {
        $data=SiteData::first();
        return $data;
    }
      function social()

    {
        $social=Social::first();
        return $social;
    }

if (!function_exists ('contact')) {
    function contact()

    {
        $contact=Contact::first();
        return $contact;
    }
}

iki left a reply on Helper Function • 1 month ago

if (!function_exists ('contact')) {
    function contact()

    {
        $contact=Contact::first();
        return $contact;
    }
"autoload": {
        "files":[
            "app/helpers.php"
        ],
Undefined variable: contact (View: C:\xampp\htdocs\myspare\resources\views\layouts\Site-Layout.blade.php) (View: C:\xampp\htdocs\myspare\resources\views\layouts\Site-Layout.blade.php)

iki left a reply on Helper Function • 1 month ago

@bestmomo i saw it but it have nothing to do with my functions xD , i just try to make helper function for the functions above

iki left a reply on Helper Function • 1 month ago

like this ?

namespace App\helpers;
class helper

{
    public static function sections()
    
    {
        $all_sections=Section::all();
        return $all_sections;
    }
    public static function site_data()

    {
        $data=SiteData::first();
        return $data;
    }
    public static function social()

    {
        $social=Social::first();
        return $social;
    }
    public static function contact()

    {
        $contact=Contact::first();
        return $contact;
    }
}

iki left a reply on Helper Function • 1 month ago

so if i want to make functions as i did at the code , how can i do it , cause i did what u said but when i copy pasted the code to it , it gave me errors

iki left a reply on Helper Function • 1 month ago

@bestmomo i was following a website instructions , can u tell me a better way ?

iki started a new conversation Helper Function • 1 month ago

hey guys ,

i have a problem with my helper functions ,

i created a controller called helper and i added it to the aliases and it works when i am in index page ,, but when i change to any other page it gives me error undefined variable , i am using it in my layout ,

helper controller

class helper extends Controller
{
    public static function sections()

    {
        $all_sections=Section::all();
        return $all_sections;
    }

    public static function site_data()

    {
        $data=SiteData::first();
        return $data;
    }
    public static function social()

    {
        $social=Social::first();
        return $social;
    }
    public static function contact()

    {
        $contact=Contact::first();
        return $contact;
    }

aliases

        'helper'=>App\Http\Controllers\helper::class,

calling it in layout

{{ helper::contact()->phone 

5th September, 2018

iki left a reply on Using Google Maps • 1 month ago

@Cronix cool thanks

iki started a new conversation Using Google Maps • 1 month ago

hey guys , i wanna know how can i add a map to my admin pannel and be able to update the location by moving the map pin , like this http://prntscr.com/kqxwil

here , u just move the map pin to the location and its been updated at the lat and long fields up there and when u click saved its saved to the database and shows the saved one , any ideas ?

30th August, 2018

iki left a reply on Mailable • 1 month ago

@fabricecw no i didnt use it , i am sending a mail from the site to our mail

iki left a reply on Mailable • 1 month ago

@Cronix no , i even tried to send while i am openning it , nothing is added

iki started a new conversation Mailable • 1 month ago

hey guys i am trying to send an email. i got no error but its not sending the mail either !

$name=$request->name;
        $email=$request->email;
        $subject=$request->subject;
        $content=$request['content'];
        if ( Mail::to('[email protected]')->send(new ContactUs($name,$email,$subject,$content))) {
            if (app()->getLocale() == 'ar')
                session()->flash('success', 'تم إرسال الرساله بنجاح وسيتم التواصل معك فى اقرب وقت');
            if (app()->getLocale() == 'en')
                session()->flash('success', 'Message Sent Successfully And We Will Contact You As Soon As Possible ');
            return redirect()->back();
        }
MAIL_DRIVER=SMTP
MAIL_HOST=*****
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=******
MAIL_ENCRYPTION=null

29th August, 2018

iki started a new conversation Set Lang • 1 month ago

hey guys i have a site with two langs , and i am trying to change the local but i doesnt work for me thats my code

 <ul class="top-menu">
                                <li>
                                    <div class="dropdown">
                                        <a href="#" data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-globe"></i>{{\Illuminate\Support\Facades\App::islocale('ar') ?'العربيه' :'English'}} <b class="caret"></b></a>
                                        <ul class="dropdown-menu dropdown-menu-right">
                                            <li class="active" value="en"><a href="{{\Illuminate\Support\Facades\Lang::setLocale('en')}}">English</a></li>
                                            <li value="ar"><a href="{{\Illuminate\Support\Facades\App::setLocale('ar')}}">Arabic</a></li>
                                        </ul>
                                    </div>
                                </li>
                            </ul>

when i check with islocale it only says that is en , i tried both lang and app setlocale

10th August, 2018

iki left a reply on Calender • 2 months ago

i tried but i couldnt make it to work, as i want it to display the days since the current day and then when someone clicks it it opens a model to make a request .

iki started a new conversation Calender • 2 months ago

hey guys , i have a calender in my website , but its static , how to make days and months display dynamicly

https://gyazo.com/a575d53a6c65f6ed891ebcbc8533e7ca

7th August, 2018

iki left a reply on Checkbox Value When Checked • 2 months ago

@lostdreamer_nl all names and ids unique and even of its inside the other script still the same

iki started a new conversation Checkbox Value When Checked • 2 months ago

hey guys , my problem is i have a check box in my foreach and i want it whenever i click on it it updates the is_active column in my database , i managed to do that with ajax but the problem is the value , i tried to make a script so when its checked the value = 1 and if not checked the value = 0 but it only worked for the last checkebox in my foreach thats my code

<div class="checkbox checkbox-custom">
                                                                            <input class="checker"
                                                                                   id="checkbox{{$branch->id}}"
                                                                                   @if($branch->is_active) checked
                                                                                   @endif lid="{{$branch->id}}"
                                                                                   value="1" type="checkbox">
                                                                            <label for="checkbox{{$branch->id}}"> </label>
                                                                        </div>

 <script>

        $('#checkbox{{$branch->id}}').on('change', function () {
            this.value = this.checked ? 1 : 0;
            // alert(this.value);
        }).change();

    </script>


    <script>


        $(document).on("change", ".checker", function () {
            var is_active = $(this).val();
            var id = $(this).attr("lid");
            var token = "{{ csrf_token() }}";
            $.ajax({
                url: "{{ url('admin/active-location') }}",
                type: "post",
                dataType: "json",
                data: {is_active: is_active, id: id, _token: token},
                success: function (data) {
                    if (data.is_active !== "ok") {
                        alert("ERROR");
                    }
                },
                error: function () {
                    alert("ERROR");
                }
            })
        })
    </script>
 public function activelocation(Request $request){



        $checker = Contact::find($request->id);
        $checker->is_active = $request->is_active;
        $checker->save();



        return response()->json(["is_active" => "ok"]);

    }

3rd August, 2018

iki left a reply on One To Many Relationship Problem • 2 months ago

@Dalma it gets a null, when i dd, can u check if i wrote my foreign key wrong?

iki started a new conversation One To Many Relationship Problem • 2 months ago

i have one to many relation ship between , agents and status table , so that every agent have one status but the status can go to more than agent , so thats what i did so far on agent mode

 public function status(){
        return $this->belongsTo('App\Status');
    }

one status model

public  function agent(){

        return $this->hasMany('App\Agent');

    }

one database i have status_id on my agents table , my question is i wanna display the status name in my view


                                            <tr>
                                                <td>{{$agent->id}}</td>
                                                <td>{{$agent->name}}</td>
                                                <td>{{$agent->email}}</td>
                                                <td>{{$agent->phone}}</td>
                                                <td>{{$agent->activity}}</td>
                                                <td>{{$agent->employees}}</td>

                                               

                                                <td>{{$agent->status()->first()->name) }}</td>

thats given me an error , how i do that

iki left a reply on Display One To Many Relationship Data • 2 months ago

@tykus hello again bro , i have this tables

https://gyazo.com/9b498e266cf49e238d3b6b353af9a347

https://gyazo.com/7962b5074ecd97048207849642dddf8d

https://gyazo.com/faacdcf7b82f2cafcbf621dbd21d9f00

https://gyazo.com/d5933c54a64be52d4614052710071b5b

and thats my code

model AgentMeeting

public function meeting(){


        return $this->belongsto('App\MeetingType','meeting_type_id');
    }

Model MeetingType

public function agentmeeting(){

        return $this->hasMany('App\AgentMeeting');

    }
                                              
  <td>{{$data->meeting()->name }}</td>

and thats whai i get

https://gyazo.com/0aafcef9dab7ea5e18c85075dee72375

it shows wrong data and only shows three then it gives error trying to get property name of non object and tried optional() but it then gives me the last input as empty data , whats the wrong here , i feel thats its the foreign key

iki started a new conversation Not Displaying The Passed Days • 2 months ago

hello guys , i was wondering how can i make my date input not displaying the passed days . like it only show dates from today

iki left a reply on Display One To Many Relationship Data • 2 months ago

@tykus thank you very much <3

iki left a reply on Display One To Many Relationship Data • 2 months ago

btw if i can ask another question , if i have a select option that retrieve the data from the database how i make the current selected value as selected when editing

iki left a reply on Display One To Many Relationship Data • 2 months ago

u are right , i was passing the value with invalid name . totally mybad , thanks for the help , i wish i can solve the rest of the errors now xD

iki left a reply on Display One To Many Relationship Data • 2 months ago

but when i dd($agent->status->name)) its given me the name of the first column only

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.