my_name_is_dimitris

Junior Web Developer at Unemployed

Member Since 1 Year Ago

Volos

Experience Points
14,030
Total
Experience

970 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
124
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 3
14,030 XP
Apr
01
1 week ago
Activity icon

Started a new Conversation Incorrect Values When Using Nexmo In Laravel ,correct Ones When Using Nexmo Web Interface

I'm trying to implement an sms functionality and using Nexmo. The thing is that i'm using Greek characters for the sms text but every time i'm using this method

foreach ($members as $member) {
            Nexmo::message()->send([
                'to'   => $member->phone_number,
                'from' => 'sender',
                'text' => 'ΔΟΚΙΜΗ'
            ]);

I get Δ????? as an sms. However everything works as it should if i try the same thing from Nexmo's web interface panel.

Anyone else tried this one?

Mar
31
1 week ago
Activity icon

Started a new Conversation Weird Aligment Issue With Tailwind And Laravel Collection

So i have this method:

  public function print()
    {

        $members = Member::where(['is_a_candidate' => true])
            ->orWhere(['is_a_scrutineer_candidate' => true])->get();

        return view('print', compact('members'));
    }

and this blade file:


<x-app-layout>
 


    <div class="flex flex-col mt-8">


        <div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg mt-4 table-auto">
            <table class="min-w-full divide-y divide-gray-200 ">
                <thead>
                    <tr>
                        <th class="py-3 px-6 text-center">
                            <span
                                class=" text-center text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">Select</span>
                        </th>
                        <th class="py-3 px-6 ">
                            <span
                                class=" text-center text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">Name</span>
                        </th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    @foreach ($members as $member)
                    @if ($member->is_a_candidate)
                    <tr>
                        <td class="py-3 px-6 text-center whitespace-nowrap">
                            <input type="checkbox"
                                class="form-checkbox h-6 w-6 text-indigo-600 transition duration-150 ease-in-out">

                        </td>
                        <td class="py-3 px-6 text-left whitespace-nowrap">


                            <div class="ml-4">
                                <div class="text-sm leading-5 text-center  font-medium text-black">

                                    {{ $member->name }}


                                </div>
                            </div>
                        </td>

                    </tr>
                    @endif
                    @endforeach
                </tbody>
            </table>



            <table class="min-w-full divide-y divide-gray-200 ">
                <thead>
                    <tr>
                        <th class="py-3 px-6 text-center">
                            <span
                                class=" text-center text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">Select</span>
                        </th>
                        <th class="py-3 px-6 ">

                            <span
                                class=" text-center text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">Name</span>


                        </th>

                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    @foreach ($members as $member)
                    @if ($member->is_a_scrutineer_candidate)
                    <tr>
                        <td class="py-3 px-6 text-center whitespace-nowrap">
                            <input type="checkbox"
                                class="form-checkbox h-6 w-6 text-indigo-600 transition duration-150 ease-in-out">

                        </td>
                        <td class="py-3 px-6 text-left whitespace-nowrap">


                            <div class="ml-4">
                                <div class="text-sm leading-5 text-center  font-medium text-black">


                                    {{ $member->name }}


                                </div>
                            </div>
                        </td>

                    </tr>
                    @endif
                    @endforeach
                </tbody>
            </table>
        </div>


    </div>


</x-app-layout>

if i use the same @foreach for both tables ,everything aligns perfectly.

if not this is the result : https://i.imgur.com/nWn3J3z.png

Any suggestions?

Mar
27
2 weeks ago
Activity icon

Commented on Datatables

Anyone tried to implement the "Edit" functionality?

Activity icon

Replied to Using Dynamic Table Head In Order To Sync With Data In Cell

Thank you for your time.

i Get " BadMethodCallException Call to undefined method Illuminate\Database\Eloquent\Builder::all() " error .

Activity icon

Started a new Conversation Using Dynamic Table Head In Order To Sync With Data In Cell

Im trying to build a small (offline,without the use of Stripe etc) membership app. What i want to achieve is having years as thead in a table and as table data/cell a true or false statement (if member has paid subscription). Im stuck for a few days now on how i can sync the data of table head to table cells.

in order to do that i have this method:

public function index()
    {

        $period = range(Carbon::now()->year, 2018);
        $users = User::all();

 $dates = Subscription::first()->user->subscriptions->pluck('SubscriptionYear')->toArray();

        return view('index')->with(compact('period', 'users', 'dates'));
    }

and this part of the view:



  <thead>
                        <tr>

                            <th> Name </th>
                            @foreach ($period as $date)

                            <th> {{ $date }} </th>
                            @endforeach


                        </tr>
                    </thead>
                    <tbody>
                        <tr>

                            @foreach ($users as $user)

                            <td>{{ $user-> name }}</td>
                            @endforeach



                            @foreach ($dates as $year)


                            @if ($year === $date)
                            <td> {{ 'true' }}</td>



                            @else

                            <td>{{ 'false' }} </td>

                            @endif


                            @endforeach


                        </tr>

                    </tbody>

The outcome of this is every cell shows false except the last one. I have stored fake years from 2021 back to 2018 into the database.

I think im taking the wrong route on this one. Anyone who done something similar or having a suggestion on how to achive that?

Feb
27
1 month ago
Activity icon

Replied to Add Modal Popup From Ajax Fetched Results

A hardcoded example of what i am trying to achieve is this

$(document).on('click', '#searchButton', function (event) {event.preventDefault();
            let href = $(this).attr('data-attr');
            $.ajax({
                url:"/books/12",

                beforeSend: function () {
                    $('#loader').show();
                },
                // return the result
                success: function (result) {
                    $('#mediumModal').modal("show");
                    $('#mediumBody').html(result).show();
                },
                complete: function () {
                    $('#loader').hide();
                },
                error: function (jqXHR, testStatus, error) {
                    console.log(error);
                    alert("Page " + href + " cannot open. Error:" + error);
                    $('#loader').hide();
                },
                timeout: 8000
            })
        });

while pressing the search button ,a modal with the details of a book with an id of 12 is shown. What i am trying to do is pass the value from the auto-complete search bar to the search button and show the details of a book in a modal. Any help is much appreciated,thanks.

Feb
26
1 month ago
Activity icon

Replied to Add Modal Popup From Ajax Fetched Results

Dropdown is working just fine. What i want is to press the search button and show a modal which shows the requested book details.

$(document).on('click', '#searchButton', function (event) {event.preventDefault();
            let href = $(this).attr('data-attr');
            $.ajax({
                url:href,

                beforeSend: function () {
                    $('#loader').show();
                },
                // return the result
                success: function (result) {
                    $('#mediumModal').modal("show");
                    $('#mediumBody').html(result).show();
                },
                complete: function () {
                    $('#loader').hide();
                }

I dont see any problems in the console. The problem is that i cant combine the fetched result of the dropdown and pass it to the modal

Activity icon

Started a new Conversation Add Modal Popup From Ajax Fetched Results

im struggling to achieve this because my javascript knowledge is not that good.

So what im trying to do is this: I'm building a borrowing book laravel app and i have a landing page that has a search box and a search button. When someone starts typing a query an auto-complete suggestion is triggered and a drop-down of book titles is available to choose from. The problem is that i cant use the search result to show any book details in a popup modal.

route:

Route::get('autocomplete', 'App\Http\Controllers\[email protected]');

method in my controller:


public function search(Request $request)
    {
          $search = $request->get('term');

          $result = Book::where('title', 'LIKE', '%'. $search. '%')->get();


          return response()->json($result);

    }

_searchbox.blade.php :

   <div class="col-md-10 col-lg-8 col-xl-7 mx-auto">
                    <form method="">
                        <div class="form-row">
                            <div class="col-12 col-md-9 mb-2 mb-md-0">
                                <input id="search"  "type="text" class="form-control form-control-lg" name="search"
                                    placeholder="Search for...">

                            </div>

                            <div class="col-12 col-md-3">
                                <button type="button" name="searchButton" id="searchButton" class="btn btn-block btn-lg btn-primary" ><i class="fa fa-search"></i></button>
                            </div>
                        </div>
                    </form>
                </div>

script for fetching the results :


$(document).ready(function() {
       $( "#search" ).autocomplete({

           source: function(request, response) {
               $.ajax({
               url: "{{url('autocomplete')}}",
               data: {
                       term : request.term
                },
               dataType: "json",
               success: function(data){
                  var resp = $.map(data,function(obj){
                      // console.log(obj.city_name);
                       return obj.title;
                  });

                  response(resp);
               }
           });
       },
       minLength: 1
    });

i followed this tutorial : https://w3path.com/jquery-ui-autocomplete-search-in-laravel-6-tutorial/

Can someone help me with that?

Jan
07
3 months ago
Activity icon

Replied to BelongsTo/HasMany Question

Thank you for your reply,

regarding your question yes and no. So one member can borrow/reserve many books ,but a unique book can only reserved by one member. So i need a belongsTo/hasMany relationship between the member and the books.Correct?

Activity icon

Replied to BelongsTo/HasMany Question

Thank you for your answer. So you suggest something like this:

migration

 Schema::create('reservations', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('member_id')->nullable();
            $table->unsignedBigInteger('book_id')->nullable();
            $table->timestamps();
            $table->date('due_date');
            $table->date('return_date');

            $table->foreign('member_id')
                ->references('id')
                ->on('members')
                ->onDelete('cascade');

            $table->foreign('book_id')
                ->references('id')
                ->on('books')
                ->onDelete('cascade');
        });


and Model

class Reservation extends Model
{
    use HasFactory;

    public function member()
    {
        return $this->belongsTo(Member::class);
    }

    public function books()
    {
        return $this->hasMany(Book::class);
    }
}

So lets say for example i have a reservation record with id of 1:


 $reservation = Reservation::find(1);

Shouldn't this return the collection of books? i'm getting an exception:

 $reservation -> books;
Illuminate\Database\QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.reservation_id' in 'where clause' (SQL: select * from `books` where `books`.`reservation_id` = 1 and `books`.`reservation_id` is not null)'

Again thank you for your help ,i just started learning Laravel and im still figuring things out while trying to build this app.

Jan
02
3 months ago
Activity icon

Started a new Conversation BelongsTo/HasMany Question

I'm trying to understand the use of pivot table. If i understood correctly a pivot table is only useful when the relationship is belongsToMany. This brings me to my issue. I'm in the process of building a library management app with members and books. So as I understand it, one member can borrow a number of books and a book can only be borrowed by one member. So we have a hasMany/belongsTo relationship. This is where things starting to become unclear to me. Should i make another table named reservations in order to save date of borrow for example? I'm stuck to the logic of it mostly. Any help is much appreciated,thank you in advance.

create_books_table.php :


 public function up()
    {
        Schema::create('books', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('category_id');
            $table->unsignedBigInteger('member_id');
            $table->timestamps();
            $table->string('title', 255);
            $table->string('author_name');
            $table->integer('page_count');
            $table->text('short_description');
            $table->boolean('borrowed');
            $table->string('image', 255)->nullable();


            $table->foreign('member_id')
                ->references('id')
                ->on('members')
                ->onDelete('cascade');


            $table->foreign('category_id')
                ->references('id')
                ->on('categories')
                ->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('books');
    }


create_members_table.php :


public function up()
    {
        Schema::create('members', function (Blueprint $table) {
            $table->id();
            $table->integer('number_of_books_borrowed')->nullable();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('members');
    }
}

Member model :


class Member extends Model
{
    use HasFactory;

   protected $fillable = ['name', 'email'];



   public function books()
   {
       return $this->hasMany(Book::class);
   }

}

Book Model :

class Book extends Model
{
    use HasFactory;


    protected $fillable = [
        'title',
        'author_name',
        'page_count',
        'short_description',
        'category_id',
        'borrowed'
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function member()
    {
        return $this->belongsTo(Member::class);
    }
}


Dec
20
3 months ago
Activity icon

Commented on Forms That Submit PUT Requests

So if we want a delete method ,we must create a form? Can someone please explain this to me?

Dec
07
4 months ago
Activity icon

Started a new Conversation Using Two Controller Methods In One View

Hello everyone,

i want to pass two datasets in a home.blade.view file. More specifically,i want to count the total number of books and members and view it .So in my HomeController

<?php

namespace App\Http\Controllers;

use App\Models\Member;
use App\Models\Book;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $members = new Member();
        $books = new Book();
        return view('home', compact(['members', 'books']));
    }
}

and finally on my home.blade.php :


 <p>Books</p>
          </div>
          <div class="icon">
            <i class="fas fa-book "></i>
                  </div>
          <a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
        </div>
      </div>
      <!-- ./col -->
      <div class="col-lg-3 col-6">
        <div class="small-box bg-info">
          <div class="inner">
            <h3>{{ $books -> count() }}</h3>

            <p>Members</p>
          </div>
          <div class="icon">
            <i class="fas fa-users"></i>
          </div>
          <a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
        </div>
      </div>
      <!-- ./col -->
      <div class="col-lg-3 col-6">
        <div class="small-box bg-info">
          <div class="inner">
            <h3> {{ $members -> count() }}</h3>

Is this approach ok? Am i missing something? Thank you very much in advance.