Bosstone

Bosstone

Member Since 10 Months Ago

Experience Points 650
Experience Level 1

4,350 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

05 Nov
5 months ago

Bosstone left a reply on Get Data From Two Tables

Dear Snapey, dear Arthvrian,

thanks a lot for your help. I do not get it :-(

in my Project.php I have

public function user()
{
    return $this->belongsTo(\App\User::class, 'user_id');
}

in my User.php I have

public function projects()
  {
      return $this->hasMany(\App\Project::class, 'user_id');
  }

When I use

$results = User::with('projects')->get();

in my controller, then I get all data from User, but no data from projects.

@foreach($results as $project)
     <br>
        <tr>
            <td>{{ $project->name }}</td>
            <td>{{ $project->user_id }}</td>
            <td>{{ $project->cat_name }}</td>
         </tr>
 @endforeach

The first Data is from User, the other two from Project and those Variables will not be shown.

Thank you for your Time and support.

Stefan

Bosstone started a new conversation Get Data From Two Tables

Hi, how can I get all the data from two tables:

users, projects

My tables are connected with user.id & projects.user_id

This is my Controller:

public function adminProjectShowAll() {
    
    $user = Auth::user();
    $stat = 1;
    $projects = Project::where('stat' <> $stat );

    
  return view('admin-project-show-all', compact('projects', 'user'));
    
}

my sql code would be: select * from users, projects where user.id = projects.user_id

This is my View:

@foreach($projects as $project)
                  <br>
                  <tr>
                    <td>{{ $project->name }}</td>
                    <td>{{ $project->user_id }}</td>
                    <td>{{ $project->cat_name }}</td>
                  </tr>
                  @endforeach 

Error: No Error, but nothing will be displayed...

Thank you for your help and support!

Best Regards,

Stefan

07 Oct
6 months ago

Bosstone left a reply on E-Mail Sending

Thank you very much for your answer. Works like a charm :-)

Stefan

Bosstone started a new conversation E-Mail Sending

Hi Folks,

I have a problem sending E-Mail. I get an error message when I use the "lost password function":

my .env File (with Placeholders):

MAIL_DRIVER=smtp
MAIL_HOST="server1.weddingcompany.eu"
MAIL_PORT=587
MAIL_USERNAME="[email protected]"
MAIL_PASSWORD="*******"
MAIL_ENCRYPTION=tls

the mail.php File looks like this:

02 Jul
9 months ago

Bosstone started a new conversation Infinite Scroll - JScroll

Hi Folks,

I am trying to lazy load data from Mysql - To test, I have put 8000 entries into the database.

I have added <div class = "infinite scroll" to my HTML Source:

<div class="infinite-scroll">
                      @foreach($projects as $project)
                          <p style=""><b>Kategorie: {{ $project->cat_name }}
                          <p style=""><b>Projektname:  {{ $project->projektname }} ID: {{ $project->id }}</b></p>
                          @if ( $project->stat === 0 )
                            <p style=""><b>Projektstatus: eingereicht</b></p>
                          @elseif ( $project->stat === 2 )
                            <p style=""><b>Projektstatus: freigegeben</b></p>
                          @elseif ($project->stat === 3 )
                            <p style=""><b>Projektstatus: zur├╝ckgewiesen</b></p>
                          @endif

                          <div class="form-group">
                              <label for="comment">Projektinfos:</label>
                              <textarea class="form-control" rows="5" id="comment">Projektname: {{$project->name}} \n Projectbeschreibung: {{$project->beschreibung }}</textarea>
                          </div>
                          <br>
                          <div class="row">
                            <?php $imageCount = 0;?>
                          @foreach($project->images as $image)

                            <?php $imageCount ++; ?>

                              <div class="column" id = "thumb-<?php echo md5($image->filename)?>">
                                <img src="{{ $image->thumb_url }}" alt="{{$image->filename}}" style="width:100%;height:100%" onclick="openModal('{{$project->name}}');currentSlide(<?php echo $imageCount ?> , '<?php echo $project->name?>')" class="hover-shadow cursor">
                              </div>

                          @endforeach

                          </div>
                          <br>


                          <form method="POST" action="{{ route('project-rated') }}">
                              @csrf
                                {{ Form::hidden('project_id', $project->id) }}
                                <label for="Cat"></label>
                                    <select class="form-control" name="counts" id="counts" data-parsley-required="true" onchange='this.form.submit()'>
                                      <option value="10">10</option>
                                      <option value="20">20</option>
                                      <option value="30">30</option>
                                      <option value="40">40</option>
                                      <option value="50">50</option>
                                      <option value="60">60</option>
                                      <option value="70">70</option>
                                      <option value="80">80</option>
                                      <option value="90">90</option>
                                      <option value="100">100</option>
                                    </select>
                              </form>

                      <div id="myModal-{{$project->name}}" class="modal">
                        <span class="close cursor" onclick="closeModal('{{$project->name}}')">&times;</span>
                        <div class="modal-content">
                          <div class = "wide_wrapper" >
                            @foreach($project->images as $image)
                            <div class="mySlides-<?php echo $project->name ?>" data-responsive="true" style = "width : 100%;height : 100%;" id = "wide-<?php echo md5($image->filename)?>">
                              <img src="{{ $image->url }}" alt="Nature and sunrise" style="width: 100%; ">
                            </div>
                            @endforeach

                          </div>
                          <a class="prev" onclick="plusSlides(-1 , '<?php echo $project->name?>')">&#10094;</a>
                          <a class="next" onclick="plusSlides(1 , '<?php echo $project->name?>')">&#10095;</a>

                          <div style = "height : 30px;background : black">
                          </div>

                          <div class = "clearfix">
                            <?php $imageCount = 0;?>
                            @foreach($project->images as $image)
                            <?php $imageCount ++; ?>
                            @if ($user->rolle === 0)
                            <div class="column clearfix" id = "slide-<?php echo md5($image->filename)?>">
                              <div class = "clearfix text-center" style = "background : grey">
                                <span class="glyphicon glyphicon-trash" onclick="del('{{$image->filename}}' , '<?php echo md5($image->filename)?>')"></span>
                              </div>
                              <div class = "image-wrapper">
                                  <img id = "slideimg-<?php echo md5($image->filename)?>" class="demo-<?php echo $project->name ?> cursor" src="{{ $image->thumb_url }}" style="width:100%" onclick="currentSlide(<?php echo $imageCount ?> , '<?php echo $project->name?>')" alt="Nature and sunrise">
                              </div>
                            </div>
                            @endif
                            @endforeach

                        </div>

                        </div>
                        <div style = "height : 80px"></div>
                      </div>
                      <div style="height: 50px;"></div>
                      @endforeach
                    </div>

Here is the Javascript:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="/js/jquery.jscroll.min.js"></script>

<script type="text/javascript">
        $(function() {
            $('.infinite-scroll').jscroll({
                autoTrigger: true,
                loadingHtml: '<img class="center-block" src="{{ asset('images/loading.gif') }}" alt="Loading..." />',
                padding: 0,
                nextSelector: '.pagination li.active + li a',
                contentSelector: 'div.infinite-scroll',
                callback: function() {
                    $('ul.pagination').remove();
                }
            });
        });
</script>

The Script is from that site: https://laraget.com/blog/implementing-infinite-scroll-pagination-using-laravel-and-jscroll

The Data will be loaded, but not lazy (and therefore super slow), and the gif will never be shown...

Can anyone help me out? What am I missing? Thanks for any hints and suggestions.

Bosstone left a reply on Form Validation: Textarea - Maxlength

If someone needs the solution:

The Javascript - Code - I take the variable {{ $cats->words }} from the database.

<script src="http://code.jquery.com/jquery-1.5.js"></script>
    <script>
        var max = {{ $cats->words }};
        $(document).ready(function() {
          $("#beschreibung").on('keyup', function() {
      var words = this.value.match(/\S+/g).length;

      if (words > max) {
        // Split the string on first 200 words and rejoin on spaces
        var trimmed = $(this).val().split(/\s+/, max).join(" ");
        // Add a space at the end to make sure more typing creates new words
        $(this).val(trimmed + " ");
      }
      else {
        $('#display_count').text(words);
        $('#word_left').text(max-words);
      }
    });
  });

The HTML Code:

<div class="form-group row">
        <label for="beschreibung" class="col-md-4 col-form-label text-md-right">{{ __('Beschreibung*') }}</label>

        <div class="col-md-6">

            <textarea id="beschreibung" rows="10" class="form-control{{ $errors->has('beschreibung') ? ' is-invalid' : '' }}" name="beschreibung" value="{{ old('beschreibung') }}" required></textarea>
            Allowed Words: {{ $cats->words }} - Total Words : <span id="display_count">0</span> Words!
            @if ($errors->has('beschreibung'))
                <span class="invalid-feedback">
                    <strong>{{ $errors->first('beschreibung') }}</strong>
                </span>
            @endif
        </div>
    </div>

Bosstone left a reply on Form Validation: Textarea - Maxlength

Dear BishoyWaghi - thanks for your suggestion :-)

Bosstone started a new conversation Form Validation: Textarea - Maxlength

Hi Folks,

how can I count the number of words inside a textarea? I have a variable ($cats->count) where the number of allowed words are defined.

<div class="col-md-6">
          <div id="charNum">
            <textarea id="desc" class="form-control{{ $errors->has('desc') ? ' is-invalid' : '' }}" name="desc" value="{{ old('desc') }}" required></textarea>

            @if ($errors->has('desc'))
                <span class="invalid-feedback">
                    <strong>{{ $errors->first('desc') }}</strong>
                </span>
            @endif
          </div>
        </div>

Thank you for any suggestions

Kind Regards,

Stefan

22 Jun
10 months ago

Bosstone left a reply on Show Everything From 3 Tables Where Not In 1 Table

@burlresearch Thank you very much! Exactly what I have achieved! Kind Regards, Stefan!

21 Jun
10 months ago

Bosstone started a new conversation Show Everything From 3 Tables Where Not In 1 Table

Hi Folks,

sorry for that silly title. I try to explain what I want to achieve:

I am reprogramming a Voting Website. The user is uploading Projects, the judge is voting on them. As there are several judges, I have a "help table" where - after a judge has voted on a project - his user_id and the project_id will be saved.

I have 4 tables

Table: User (with id) Table: Project (with id and user_id) Table: Images (with id, project_id) Table: Counts (with id, project_id, user_id)

Class Count

class Count extends Model
{
  public function project()
    {
        return $this->belongsTo(\App\Project::class, 'project_id');
    }

    public function user()
      {
          return $this->belongsTo(\App\User::class, 'user_id');
      }
}

Class Project:

public function images()
    {
        return $this->hasMany(\App\Image::class, 'project_id');
    }

    public function user()
    {
        return $this->belongsTo(\App\User::class, 'user_id');
    }

    public function cat()
      {
          return $this->belongsTo(\App\Cat::class, 'cat_id');
      }

Class Image:

public function project()
    {
        return $this->belongsTo(\App\Project::class, 'project_id');
    }

Class User:

public function projects()
      {
          return $this->hasMany(\App\Project::class, 'user_id');
      }

I know, I can show all the projects (with the connected images) like this (in this case, all projects with stat = 2 will be shown):

$projects = Project::with(['images' => function($query){
        $query->where('state' , 0 );
      }])
      ->where('stat', '=', '2')
      ->whereHas('user', function ($query) use ($user) {
                        $query->where('id', '=', $user->id);

                    })->get();

What I want to achieve in the end is as follows:

I want to show all the projects (and connected images) from Table: Project where the combination of user_id and project_id is not in table Count

Can anyone advice me how to solve this issue?

Kind Regards,

Stefan

Bosstone left a reply on Fetch Data From Two Tables

Solved id:

$projects = Project::with(['images' => function($query){
        $query->where('state' , 0 );
      }])
      ->where('stat', '!=', '1')
      ->whereHas('user', function ($query) use ($user) {
                        $query->where('id', '=', $user->id);

                    })->get();

:-)

Bosstone started a new conversation Fetch Data From Two Tables

Hi Folks,

I have 2 Tables (projects and images) which I can fetch like this:

$projects = Project::with(['images' => function($query){
        $query->where('state' , 0 );
      }])->whereHas('user', function ($query) use ($user) {
                        $query->where('id', '=', $user->id);

                    })->get();

The Project Table has a field "stat" where the stat of the project is defined:

0 = uploaded by user 1 = deleted by user 2 = verified by admin 3 = rejected.

The Image Table has a field "state" where 0 = ok, 1 = deleted

Currently I am fetching all the projects with images with state 0 from the logged in user. What can I do to fetch only the projects with stat = 0 || stat = 2 || stat = 3?

Thank you for your advice!

Stefan

19 Jun
10 months ago

Bosstone left a reply on Textarea: Show Different Variables

Dear Snapey thanks for the hint with the Backticks ;-) I want to display more variables into one textarea and I need a linebreak after each variable.

I tried with

\n
</br>

The option

{!! nl2br(e($text))!!}

will not work, as I try to display several variables - or am I wrong?

Kind Regards,

Stefan

Bosstone started a new conversation Bootstrap Dropdown With Value

Hi Folks,

in my App I have a function where the judges can rate projects. Using this code

10 20 30 40 50 60 70 80 90 100 {{ __('Rate') }} @endif

I have a dropdown and a button. As this solution works, but looks ugly, I learned, that there is a CSS in Bootstrap for a dropdown, but I cannot send values with that:

Dropdown Example

Is there a solution for sending values in the second dropdown?

Thanks for any advice!

Stefan

Bosstone started a new conversation Textarea: Show Different Variables

Hi Folks,

I want to display several Variables inside a Textarea:

Projectname: {{$project->name}}ProjectDescription: {{$project->desc }}

When I use the code above, then will be printed, and ProjectDescription ist in the same line...

Thank you for your advice!

Kind Regards,

Stefan

Bosstone started a new conversation Bootstrap Container Width - Make Container "wider"

Hi Folks,

how can I make a Bootstrap container "wider"? I have seen in app.css that there is

{.container{max-width:540px}}

But when I change it to 900 the container is still the same wide, but oriented left instead of center...

Thank you for any help!

Kind Regards,

Stefan

11 Jun
10 months ago

Bosstone left a reply on Intervention: Image Manipulation On The Fly?

Dear Snapy, thank you very much for your support. Works like a charm :-)

Kind Regards,

Stefan

10 Jun
10 months ago

Bosstone left a reply on Intervention: Image Manipulation On The Fly?

Dear Snapy thank you for your feedback. I have made it as you suggested, but I am not able to use aspect ratio:

I am saving the thumbnails like

$img = Image::make($thumbnailpath)->resize(250, 150)->save($thumbnailpath);

Intervention Image tells that I have to use:

$img->resize(null, 200, function ($constraint) { $constraint->aspectRatio(); });

but when I adapt my code, then I get a "unexpected } error"

$img = Image::make($thumbnailpath)->resize(null, 200, function ($constraint) { $constraint->aspectRatio()})->save($thumbnailpath);

How can I solve this issue? I want all the images with a width of 200 and an aspected Ratio...

Kind Regards,

Stefan

31 May
10 months ago

Bosstone started a new conversation Intervention: Image Manipulation On The Fly?

Hi Folks,

I have 2 Tables (Images: Name, URL, Project_ID - Projects: Name, User_ID). I use eloquent to fetch the Data:

Controller:

public function ProjectShow () {

  $user = Auth::user();


  $projects = Project::with('images')
                ->whereHas('user', function ($query) use ($user) {
                    $query->where('id', '=', $user->id);
                })->get();

return view('project-show', compact('projects', 'user'));

}

Blade:

@foreach($projects as $project)

This is Project Name: {{ $project->name }}

@foreach($project->images as $image)
    <p>This is Project FotoURL:  <img src ="{{ $image->url }}" alt=""></p>
@endforeach

@endforeach

To show thumbnails, I have installed Intervention Package with:

php composer.phar require intervention/image

and entered the required data in config/app (providers, aliases)

I have watched the Thumbnail Video, but I am stuck as in the Video I have to add a ->thumbnail_ extension to the variable, but as I am using $projects->url I am not able to add this "extra" ->thumbnail_ stuff.

How can I solve this to show thumbnails (5 in a row, max 3 lines? Can I do this on the fly in the blade, or do I have to manipulate the image in the controller?

Sorry if already asked, but I was not able to find a solution for this request...

Kind Regards

Stefan

Bosstone left a reply on Fetch Data In Blade From Eloquent?

Dear Tykus & himanshu-dhiman

thank you very much for your feedback. I am very impressed how fast you were and what I am missing...

Kind Regards,

Stefan

Bosstone started a new conversation Fetch Data In Blade From Eloquent?

Hi Folks,

I am new to laravel and I am stuck at this problem:

I have 3 tables:

User: id, name Projects: id, name, user_id Images: id, name, project_id

Using Eloquent I can fetch any projects connected to a user and the images connecting to the project:

public function ProjectShow () {

  $user = Auth::user();

  $projects = Project::with('images')
                ->whereHas('user', function ($query) use ($user) {
                    $query->where('id', '=', $user->id);
                })->get();

 return view('project-show', get_defined_vars())->with(['user' => $user]);

}

When I "return $projects;" then I will get this result:

{"id":73,"user_id":1,"name":"dfds","projektname":"1527685835","cat_id":1,"beschreibung":null,"youtube":null,"copyright":null,"testimonial":null,"check":0,"ort":null,"stat":0,"created_at":null,"updated_at":null,"deleted_at":null,"images":[{"id":4,"project_id":73,"filename":"15276858427.png","url":"/Users/sl/Developer/awa/public/images/1/1/15276858427.png","filesize":null,"created_at":"2018-05-30 13:10:42","updated_at":"2018-05-30 13:10:42","deleted_at":null},{"id":5,"project_id":73,"filename":"15276858428.png","url":"/Users/sl/Developer/awa/public/images/1/1/15276858428.png","filesize":null,"created_at":"2018-05-30 13:10:42","updated_at":"2018-05-30 13:10:42","deleted_at":null},{"id":6,"project_id":73,"filename":"152768584224Alle.png","url":"/Users/sl/Developer/awa/public/images/1/1/152768584224Alle.png","filesize":null,"created_at":"2018-05-30 13:10:42","updated_at":"2018-05-30 13:10:42","deleted_at":null},

Where id:73 is the ID from projects and id:4 is the connected Images ID

When I remove the "return $projects;" then I am not able to fetch the $projects Variable in Blade:

The Blade:

@extends('layouts.app')

@section('content')

@foreach ($projects as $project)

<p>This is Project Name:  {{ $project->Name }}</p>
<p>This is Project FotoURL:  {{ $project->url }}</p>
<p>--------</p>

@endforeach

@endsection

Error: No Error, but the variables are empty...

Thank you for any feedback!

Kind Regards,

Stefan