yudy

yudy

Member Since 1 Year Ago

Experience Points 120
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

10 Jan
1 year ago

yudy left a reply on -> OrWhereHas Failed Fetch Data From Multiple Tables

I didn't test ilike to my local version with Mysql, but as you mention I think i will be a good idea to have support Mysql and Postgres, so I will try ASAP.

By the way how to use whereRaw with Has, is it whereRawHas?

09 Jan
1 year ago

yudy left a reply on -> OrWhereHas Failed Fetch Data From Multiple Tables

Thanks alot for the explanation, by the way ilike works perfectly. bless you :)

yudy started a new conversation -> OrWhereHas Failed Fetch Data From Multiple Tables

I'm using Laravel 5.2 and PostgreSql and deploy on Heroku

I have a search form to get data from multiple table >> books, writters, publisher and categories.

Here is the controller for the search form

public function search(Request $request)
    {
        $keyword = $request->input('keyword');
        

        // multiple query from different tables
        $query = Book::where('judul','like','%'.$keyword.'%')
        ->orWhere('label','like','%'.$keyword.'%')
        ->orWhere('isbn','like','%'.$keyword.'%')
        ->orWhere('status', 'like', '%'.$keyword.'%')
        ->orWhereHas('writter', function ($query) use ($keyword) {
            $query->where('nama_penulis', 'like', '%'.$keyword.'%');
        })
        ->orWhereHas('category', function ($query) use ($keyword) {
            $query->where('nama_kategori', 'like', '%'.$keyword.'%');
        })
        ->orWhereHas('publisher', function ($query) use ($keyword) {
            $query->where('nama_penerbit', 'like', '%'.$keyword.'%');
        });


        $book_list = $query->paginate(5);
        $pagination = $book_list->appends($request->except('page'));
        $total_book = $book_list->total();
        return view('dashboards.index', compact('book_list', 'keyword', 'pagination', 'total_book', 'nama_penulis'));
    }

the code works like a charm on the local using Mysql.

the problem is after i deploy to the Heroku and using Postgress, the search form only get data from the books table.

I wonder why its ignoring ->whereHas. Is it any explanation, or should I get different approach if using postgres?

24 Dec
1 year ago

yudy started a new conversation How To Handle Update On Image Upload

Hi all i new to laravel

recently i try to practice with laravel 5.5 and create simple upload image task

here is my controller on store

        $input = $request->all();

 
        $this->validate($request, [ 
            'photo' => 'sometimes|image|mimes:jpeg,png,jpg,gif,svg|max:500',
        ]);
        


        if ($request->hasFile('photo')) {
            $photo = $request->file('photo');
            $ext = $photo->getClientOriginalExtension();

            if ($request->file('photo')->isValid()) {
                $photo_name = date('YmdHis'). ".$ext";
                $phptpName = time().'.'.$request->photo->getClientOriginalExtension();
                $request->photo->move(public_path('photo-upload'), $photoName);
                $upload_path = public_path('photo-upload');
                $input['photo'] = $photoName;
            }
        }

contoller on update


        if ($request->hasFile('photo')) {
            // delete the old/previous one
            $exist = Storage::disk('photo')->exists($student->photo);
            if (isset($student->photo) && $exist) {
                $delete = Storage::disk('photo')->delete($siswa->photo);
            }

            // upload new one
            $photo = $request->file('photo');
            $ext = $photo->getClientOriginalExtension();
            $photoName = time().'.'.$request->foto->getClientOriginalExtension();
            if ($request->file('photo')->isValid()) {
                $upload_path = 'photo-upload';
                $request->file('photo')->move($upload_path, $phptpName);
                $input['photo'] = $iphotoName;
            }
        }

the store method works perfectly, it uploaded image to the right folder then update the databse

the problem is on the update, it update the database but it didn't upload the image to the photo-upload folder

Any suggestion?

Thanks