Azik

Azik

Member Since 1 Year Ago

Ferghana

Backend Developer at Youcode

Experience Points 5,010
Experience Level 2

4,990 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 33
Lessons
Completed
Best Reply Awards 2
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.

15 Jun
1 month ago

Azik left a reply on Reduce The Number Of Queries

@SNAPEY - Okay thank you.

Azik started a new conversation Reduce The Number Of Queries

Hi, I need your advice to reduce the number of queries. In main view, all queries total count more than 50, because in the model that I check, each advert is added to favorites or not added .. Index.blade.php

@foreach($supers as $advert)
<div class="item">
    <a href="{{ route('single',['id'=>$advert->id]) }}">
        <button class="{{ $advert->isFavorited() ? 'favorited' : '' }} fa fa-heart" data-id="{{ $advert->id }}"
            type="button"></button>
        @if($advert->feature)
        <img src="/uploads/thumb/{{ $advert->feature}}" />
        @else
        <img src="/uploads/default.png" />
        @endif
    </a>
    <p class="realstate">{{ $advert['realstate']['name_'.App::getLocale()]}}</p>
    <p class="want">{{strtolower($advert['want']['name_'.App::getLocale()]) }}</p>
    <p class="city">{{$advert['massiv']['name_'.App::getLocale()]}}</p>
    <p class="currency">{{ $advert->cost }}$</p>
    <p class="rooms">{{ $advert->room }}</p>
    <p class="floor">{{ $advert->floor}}/{{ $advert->all_floor}}</p>
    <p class="area">{{$advert->area}}m<sup>2</sup></p>
    <p class="date">{{ $advert->created_at->format('d/m/Y') }}</p>
</div>
@endforeach

Advert.php

public function favorites()
{
    return $this->morphMany(Favorite::class, 'favorited');
}

public function isFavorited()
{
        return (bool) Favorite::where('user_id', Auth::id())
                    ->where('favorited_id', $this->id)
                    ->where('favorited_type', Advert::class)
                        ->first();
}

public static function solds($count){
    return self::where('status',self::SOLD)->orderBy('created_at','DESC')->with('realstate','massiv','want','favorites')->take($count);
 }
 public static function type($type,$count){
        return self::orderBy('created_at','DESC')->where('typeadvert_id',$type)->with('realstate','massiv','want','favorites')->where('status',1)->take($count);
}

public static function lastadverts($count){
        return self::where('status',self::ACTIVE)->orderBy('created_at','DESC')->with('realstate','massiv','want','favorites')->take($count);
}

in controller also Advert model called 5 times

public function index(){

      $supers=Advert::type(2,8)->get(); // super type 2, limit 8

      $vips=Advert::type(3,8)->get(); // vip super type 3, limit 8

      $countall=Advert::where('status',1)->count(); // count all adverts where type is equal to 1

      $soldouts=Advert::solds(8)->get(); // sold adverts

      $lastadverts=Advert::lastadverts(8)->get(); // last adverts list
      
      $realstates=Realstate::select('name_'.\App::getLocale(),'id')->get(); 
      
      $regions=Region::select('name_'.\App::getLocale(),'id')->get();
      
      $posts=Post::where('status',1)->latest()->take(3)->get(); // get last post
      
      $wants=Want::select('name_'.\App::getLocale(),'id')->get();

      $fundaments=Fundament::select('name_'.\App::getLocale(),'id')->get();
      
      
      return view('index',compact('supers','vips','posts','realstates','wants','regions','lastadverts','soldouts','countall','fundaments'));
    }

I need your advice thank you in advance..

15 May
2 months ago

Azik left a reply on The Page Has Expired Due To Inactivity.Please Refresh And Try Again This Error Comes When Login To Admin Panel

Thank you all for the answers. The reason is that server sessions are not working properly.

08 May
2 months ago

Azik started a new conversation The Page Has Expired Due To Inactivity.Please Refresh And Try Again This Error Comes When Login To Admin Panel

When running on local server it did not have the same problem after it was deployed to the ISPManager this problem The page has expired due to inactivity. Please refresh and try again occurs when the user logs into the panel.

29 Sep
9 months ago

Azik left a reply on I Need Help, Data Wont Show With Selectable Dropdown With Jquery

 $(document).ready(function(){
        $("#room").change(function(){
            $("#price").val($(this).attr('data-price'));;
        });
    });

Azik left a reply on Inserting A Datetime With Carbon::now() But Add A Null Attribute Laravel

'date_activated ' => new \DateTime, if this also couldn't help

try this $table->timestamp('date_activated');

Azik left a reply on Laravel Take Not Working

show me school and its relation models..

Azik left a reply on Laravel Take Not Working

in controller display your data with dd($schools)

{  
 $schools = School::with('activities.cluster', 'activities.group')->where('user_id', Auth::user()->id )->first();
dd($schools);
}

Azik left a reply on Laravel Take Not Working

try first() ..

{ $schools = School::latest()->with('activities.cluster', 'activities.group')->where('user_id', Auth::user()->id )->first(); return view('Admin.submit-information.all', compact('schools')); }

Azik left a reply on How To Access The Image Location From The View

<img src="{{ asset('storage/'.$data->file_name.'/'.$data->image_name) }}">

28 Sep
9 months ago

Azik left a reply on TWO FIELDS IN ONE COLUMN.

before showing in your view check the order of date it should be looks like 2018-09-29

Azik left a reply on TWO FIELDS IN ONE COLUMN.

Corporate Personal

Azik left a reply on TWO FIELDS IN ONE COLUMN.

Well, it's easy to check on the condition..

@if($customer->type == 1) Corporate @else [email protected]

or

{{ $customer->type ? 'Corporate' : 'Personal' }}

Azik left a reply on TWO FIELDS IN ONE COLUMN.

yes, so it's better to use string or boolean type..

Azik left a reply on TWO FIELDS IN ONE COLUMN.

this way is also not bad.,

$table->enum('customer_type',['cor','per']);

Azik left a reply on The Given Data Was Invalid

try this..

// namespace

use Illuminate\Validation\Rule;

// usage gender'=> [ Rule::in(['female', 'male','none']), ],

Azik left a reply on TWO FIELDS IN ONE COLUMN.

or

$table->boolean('type')->default(1);

it is up to you..

Azik left a reply on TWO FIELDS IN ONE COLUMN.

i think create type column is simple way..

27 Sep
9 months ago

Azik left a reply on Merge Images

http://image.intervention.io/ package also has like this insert — Paste over another image function

Azik left a reply on How To Store Row Id In Laravvel

change from input names ..

        <form action="{{ route('requisitions.store')}}" method="post">
            {{ csrf_field() }}
            <div class="radio">
                <label for="school">School</label>
                <input type="radio" value="1" id="school" name="school">
                <br>
                <label for="equipment">Equipment</label>
                <input type="radio" value="2" id="equipment" name="equipment">
                <br>
                <label for="level">Level</label>
                <input type="radio" value="3" id="level" name="level">
                <br>
                <label for="place">Place</label>
                <input type="radio" value="4" id="level" name="level">
                <br>
                <label for="tax">Tax</label>
                <input type="radio" value="5" id="tax" name="tax">
                <br>
                <label for="reactivation">Reactivation</label>
                <input type="radio" value="6" id="reactivation" name="reactivation">
                <br>
                <button type="submit" class="btn-warning btn">Send</button>
            </div>
        </form>

Azik left a reply on Image Upload To Pivot Table

any ideas?

Azik left a reply on Image Upload To Pivot Table

any ideas?

25 Sep
9 months ago

Azik left a reply on Insert Additional Pivot Table Attributes

it works thanks to a lot !!

Azik left a reply on Insert Additional Pivot Table Attributes

in pivot table i insert branch_id and working_mode_id without problem but, i can't add other two columns data!!

Azik left a reply on Insert Additional Pivot Table Attributes

Argument 1 passed to Illuminate\Database\Eloquent\Relations\BelongsToMany::save() must be an instance of Illuminate\Database\Eloquent\Model, array given, called in

this line gives an error.. $branchs->workingModes()->save($workingModes,['time_start' => $time_start, 'time_finish' => $time_finish]);

Azik left a reply on Insert Additional Pivot Table Attributes

I tried useing save but it gives me an error.

$workingModes = $request->input('workingModes'); $time_start = $request->input('time_start'); $time_finish = $request->input('time_finish'); $branchs->workingModes()->save($workingModes,['time_start' => $time_start, 'time_finish' => $time_finish]);

Azik started a new conversation Insert Additional Pivot Table Attributes

Hi I am working with Eloquent many-to-many relations. I've created pivot table with some additional attributes such as time_start, time_finish and time stamps. I am trying to insert pivot table row with some additional column values..

Branch model

public function workingModes()
  {
  return $this->belongsToMany('App\Models\WorkingMode')
  ->withPivot('time_start','time_finish')
  ->withTimestamps();
  }

WorkingMode Model

public function branches() { return $this->belongsToMany('App\Models\Branch') ->withPivot('time_start', 'time_finish') ->withTimestamps(); }

and the request coming from view

"workingModes" => array:4 [▼ 0 => "1" 1 => "2" 2 => "3" ] "time_start" => array:3 [▼ 0 => "8-00" 1 => "9-00" 2 => "10-00" ] "time_finish" => array:3 [▼ 0 => "21-00" 1 => "22-00" 2 => "23-00" ]e guide me how to do that?

Thanks

20 Sep
9 months ago

Azik started a new conversation Image Upload To Pivot Table

I have cars , images and car_image tables in addController.php I get an array of images name and save to storage floder. store function

  public function store(Request $request)
  {   
      $imageall = [];
      $array = [];
    $this->validate($request, [
      'profile_image.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
    ]);
    $car = Car::create([
          'user_id' => $request->user_id,
        ]);   
  if ($request->hasFile('profile_image')) {
    foreach ($this->uploadImage($request) as $image) {
      $array[] = Photo::create(['image' => $image])->id;
      }
      $car->images()->attach($array);
    }
      $car->options()->attach($request->options);
    return redirect()->back()->with('success', "image successfully uploaded!!");
  }

and uploadImage function

 protected function uploadImage($request){
    $imageall = [];
      foreach($request->file('profile_image') as $file){
        $filenamewithextension = $file->getClientOriginalName();
        $extension = $file->getClientOriginalExtension();
        $filenametostore = 'getauto_'.uniqid().'.'.$extension;
        $imageall[] = $filenametostore;
        Storage::put('public/cars/'. $filenametostore, fopen($file, 'r+'));
        Storage::put('public/cars/thumb/'. $filenametostore, fopen($file, 'r+'));
        $thumbnailpath = public_path('storage/cars/thumb/'.$filenametostore);
        $mainimagepath = public_path('storage/cars/'.$filenametostore);
        }
        return $imageall;
     }

the problem is updating function how can i update and delete which related user images ??

Azik left a reply on What Is The Problem On My Php Code!!

i cant see code??

20 Jul
11 months ago

Azik left a reply on How To Set A Cookie With Laravel 5?

namespace ** use Illuminate\Support\Facades\Input; ** ** use Illuminate\Http\Request; **

and function ** public function regionCookie(Request $request) { $region = Input::get('region'); return redirect()->back()->withCookie(cookie('region', $region,10));; } **