iki

Experience

560

0 Best Reply Awards

  • Member Since 3 Weeks Ago
  • 0 Lessons Completed
  • 0 Favorites

10th August, 2018

iki left a reply on Calender • 1 week 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 • 1 week 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 • 1 week 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 • 1 week 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks ago

@tykus thank you very much <3

iki left a reply on Display One To Many Relationship Data • 2 weeks 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 weeks 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 weeks ago

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

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

yes i have status_id on agents , and when i try to

{{$agent->status->name) }}

it says Trying to get property 'name' of non-object

iki started a new conversation Display One To Many Relationship Data • 2 weeks 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>{{$data->status()->first()->name) }}</td>

thats given me an error , how i do that

2nd August, 2018

iki started a new conversation Laravel 5.6 Realtime Notification • 2 weeks ago

how can i make real time notification on laravel 5.6 that every time someone sends a message on my forum i get notified on my notification blade or form

iki started a new conversation One To One Relation Problem • 2 weeks ago

i have a problem with laravel relations , still getting them sry , i have agents ,employees, statues tables , every agent have a statues and employee i mad a relation at the agent model

 public function emp(){
        return $this->hasOne('App\Employee');

    }

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

index controller

 public function index()
    {
        $employee=Employee::all();
        $status=Status::all();
        $agents = Agent::all();
        return view('admin.agents',compact('employee','status','agents'));
    }

store function

 public function store(Request $request)
    {
        dd($request->all());
        $this->validate($request,[

            'name'=>'required',
            'email'=>'required|unique:agents',
            'phone'=>'required|integer',
            'activity'=>'required',

        ],
            [

                'name.required'=>'برجاء إدخال الإسم',
                'email.required'=>'برجاء إدخال البريد الإلكترونى',
                'email.unique'=>'هذا البريد الإلكترونى مستخدم بالفعل',
                'phone.required'=>'برجاء إدخال رقم الهاتف',
                'phone.integer'=>'برجاء إدخال رقم الهاتف فى صيغه أرقام',
                'activity.required'=>'برجاء إدخال النشاط',
            ]);
       $agent= Agent::create($request->all());


        session()->flash('success','تم حفظ البيانات بنجاح');
        return redirect()->back();
    }

and my form

                                                <form action="{{route('agents.store')}}" method="POST">
                                                    {{csrf_field()}}

                                                    <div class="form-group">
                                                        <label class="control-label mb-10 text-left">الاسم </label>
                                                        <input type="text" name="name" class="form-control" value="">
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label mb-10 text-left">الايميل </label>
                                                        <input type="text" name="email" class="form-control" value="">
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label mb-10 text-left"> رقم الجوال </label>
                                                        <input type="text" name="phone" class="form-control" value="">
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label mb-10 text-left"> النشاط </label>
                                                        <input type="text" name="activity" class="form-control" value="">
                                                    </div>
                                                    <div class="form-group mt-30 mb-30">
                                                        <label class="control-label mb-10 text-left">الموظف المختص</label>
                                                        <select name="employees" class="form-control">
                                                            @foreach($employee as $emp)
                                                            <option value="{{$emp->id}}">{{$emp->name}}</option>
                                                                @endforeach

                                                        </select>
                                                    </div>
                                                    <div class="form-group mt-30 mb-30">
                                                        <label class="control-label mb-10 text-left">الحالة</label>
                                                        <select name="statuses" class="form-control">
                                                            @foreach($status as $stat)
                                                            <option value="{{$stat->id}}">{{$stat->name}}</option>
                                                                @endforeach
                                                        </select>
                                                    </div>

                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default" data-dismiss="modal">إغلاق</button>
                                                        <button type="submit" class="btn btn-primary"> حفظ</button>
                                                    </div>

                                                </form>

how i use the relation to save the data at the database so when i update the statues or the employee it being updated for the agent too , and please tell me what columns to add at the database cause i gets errors about the columns

thanks in advance

iki left a reply on Retrieve Data From Many To Many • 2 weeks ago

thanks guys <3

iki started a new conversation Retrieve Data From Many To Many • 2 weeks ago

hello guys , this is my first time to use many to many relationship , so here is my question , now i have users , roles , and role_user table . i have a many to many relation ship

public function roles(){
        return $this->belongsToMany('App\Role');

    }

and have roles like (super_admin_moderator,..etc) how i retrieve all the users except the one with role_id (1) (the super admins) to my index view

   public function index()
    {


        $admins =User::all();


        return view('admin.admin',compact('admins'));
    }

so it be like get all users except the one with role_id 1 , in my database i have the role_user contains user_id and role_id

28th July, 2018

iki left a reply on Adding Images Without Deleting The Current One • 3 weeks ago

cause i dont want the old images in my storage if he updated it , i want it not to delete first images if i just changed the second one

iki started a new conversation Adding Images Without Deleting The Current One • 3 weeks ago

when adding a new project the admin can add one img instead of three , and later he can add the other 2 if he likes , so my problem is , if he has one image like in the picture when trying to select the second or third img it deletes the current one , how can i fix it , here it my code

public function update(BoysRequest $request, $id)
    {
        $input = $request->all();
        Boy::findorfail($id)->update($input);
        if ($file = $request->file('photos')) {
            $del = Boy::findorfail($id);
            foreach ($del->photo as $img)
            {
                @unlink(base_path('images/boys/'.$img->path));
                $del->photo()->delete();
            }
            foreach ($file as $photo) {
                $name = rand(0000, 9999) . time() . '.' . $photo->getClientOriginalExtension();
                $photo->move(base_path('/images/boys'), $name);
                $photos = new Photo;
                $photos->path = $name;
                $photos->boy_id = $id;
                $photos->save();
            }


        }
        return redirect()->back();
    }
                                                                                    <div class="row">

                                                                                        <div class="wrap-custom-file">
                                                                                            <input type="file"
                                                                                                   name="photos[]"
                                                                                                   id="img1{{ $data->id }}"
                                                                                                   accept=".gif, .jpg, .png"/>
                                                                                            <label for="img1{{ $data->id }}"
                                                                                                   @if(isset($data->photo[0]))
                                                                                                   class="file-ok"
                                                                                                    style="background-image: url({{url('images/boys/'.$data->photo[0]->path)}});"
                                                                                                   @endif
                                                                                            >
                                                                                                <span>Select Image One</span>
                                                                                            </label>
                                                                                        </div>

                                                                                        <div class="wrap-custom-file">
                                                                                            <input type="file"
                                                                                                   name="photos[]"
                                                                                                   id="img2{{ $data->id }}"
                                                                                                   accept=".gif, .jpg, .png"/>
                                                                                            <label for="img2{{ $data->id }}"
                                                                                                   @if(isset($data->photo[1]))
                                                                                                    class="file-ok"
                                                                                                    style="background-image: url({{ url('images/boys/' .$data->photo[1]->path)}});"
                                                                                                   @endif
                                                                                            >
                                                                                                <span>Select Image Two</span>
                                                                                            </label>
                                                                                        </div>

                                                                                        <div class="wrap-custom-file">
                                                                                            <input type="file"
                                                                                                   name="photos[]"
                                                                                                   id="img3{{ $data->id }}"
                                                                                                   accept=".gif, .jpg, .png"/>
                                                                                            <label for="img3{{ $data->id }}"
                                                                                                   @if(isset($data->photo[2]))
                                                                                                    class="file-ok"
                                                                                                    style="background-image: url({{ url('images/boys/' .$data->photo[2]->path)}});"
                                                                                                   @endif
                                                                                            >
                                                                                                <span>Select Image Three</span>
                                                                                            </label>
                                                                                        </div>


                                                                                    </div>

https://i.gyazo.com/de5bd2350da58c6fb0994eda619c1036.png

Edit Your Profile
Update

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