Andreas94

Andreas94

Member Since 2 Years Ago

Experience Points
3,470
Total
Experience

1,530 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
1
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.

Level 1
3,470 XP
May
11
2 weeks ago
Activity icon

Awarded Best Reply on Placeholder Function Error When Not Finding Record

maybe i solved used firstOrFail instead of first

May
09
3 weeks ago
Activity icon

Replied to Placeholder Function Error When Not Finding Record

maybe i solved used firstOrFail instead of first

Activity icon

Replied to Placeholder Function Error When Not Finding Record

does not work ... do you have any other advice?

May
08
3 weeks ago
Activity icon

Replied to Placeholder Function Error When Not Finding Record

It's just a field of the table “Games” but working in the “Games” template I thought it was correct so instead of using “belongsTo” and the like

Activity icon

Replied to Placeholder Function Error When Not Finding Record

I honestly didn't understand very well how it works, is that correct so?

return $this->copertina->withDefault([
        'copertina' => '/upload/games-pattern.png',
]);

will this avoid me creating error logs when the record no longer exists even by visiting the url?

Activity icon

Started a new Conversation Placeholder Function Error When Not Finding Record

I created a function in the modal that allows you to load a placeholder image when it is missing, the problem is that when it doesn't find the record because deleted (but still indexed by Google), in the log you create the error:

Call to a member function copertina() on null {"exception":"[object] (Error(code: 0): Call to a member function copertina() on null at /var/www/vhosts/**.it/httpdocs/app/Http/Controllers/FrontController.php:306)

how can I do to avoid this? i have the log full of this error...

	public function copertina() {
		if (!empty($this->copertina) && $this->copertina != null) {
			if (file_exists(public_path('/upload/copertina/'.$this->copertina))) {
				return 'upload/copertina/'.$this->copertina;
			} else {
				return '/upload/games-pattern.png';
			}
		} else {
			return '/upload/games-pattern.png';
		}
	}

do you have any suggestions on how to change this feature?

Apr
10
1 month ago
Activity icon

Replied to Combine Js File And Have A Single File, Does It Exist?

because in the past I have had problems combining js files.

also example, in /Games I have this js to combine:

'/inc/plugins/slider/jquery-plus-ui.min.js',
'/inc/plugins/slider/jquery-plus-ui.min.js',
'/inc/plugins/slider/jquery-ui-slider-pips.js',
'/inc/plugins/noty/noty.min.js',
'/inc/plugins/lazysizes/lazysizes.min.js',
'/inc/plugins/gallery/gallery.js',
'/inc/plugins/jquery.mousewheel.min.js'

and it would have been really useful if this could have been generated by the blade rather than having to manually rebuild the file to be put into production, and maybe create a "cache" js file that stays until it reaches its expiration date.

no alternative?

Activity icon

Started a new Conversation Combine Js File And Have A Single File, Does It Exist?

Hi everyone, I need to create a js file according to the files I have listed. I come from Smarty and we had them this:

https://github.com/dead23angel/smarty-combine

do you know anything that does this directly from the blade? I don't want to use webpack

Apr
08
1 month ago
Activity icon

Awarded Best Reply on Read Cookie Content

I tried to put:

   @dd(\Cookie::get('trophylist')

and it prints me on the blade exactly

(\Cookie::get('trophylist')

i am using Laravel 5.8

Edit:

was missing one ), I print null.

Another Edit:

I solved it by inserting the name of the cookie in Http\Middleware\EncryptCookies.php

Activity icon

Replied to Read Cookie Content

I tried to put:

   @dd(\Cookie::get('trophylist')

and it prints me on the blade exactly

(\Cookie::get('trophylist')

i am using Laravel 5.8

Edit:

was missing one ), I print null.

Another Edit:

I solved it by inserting the name of the cookie in Http\Middleware\EncryptCookies.php

Activity icon

Started a new Conversation Read Cookie Content

I have a cookie called: trophylist by default its value is 'list' when I press a button it becomes grid.

how do I check the value inside the cookie? I did this, but it doesn't work

          @if (\Cookie::get('trophylist') == 'list')
            @include('front.component.trofei.table')
          @else
            aaaaaaaaa
          @endif

now the cookie content is 'list' and it shows me 'aaaaaaaaaa', why?

Apr
05
1 month ago
Activity icon

Replied to Load Content In Modal From Ajax

I also tried with the get

js

$(document).ready(function(){
    $.ajaxSetup({
      headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      }
    });
   $('#votoGiochi').click(function(){
     $.ajax({
       url:"{{url('ajax/view_voto/'.$info_giochi->id)}}",
       method:"get",
       success:function(data){
         $('#votehere').html(data);
         console.log(data);
         $('#votoGiochi').modal("show");
       }
     });
   });
});

route

  Route::get('view_voto/{id}', '[email protected]_voto');

controller

	public function view_voto(Request $request, $id) {
	 if(!empty($request)){
		 $data = VotoGiochi::where('id_gioco', $id)->get();
	   //print_r($request->all());
	   return $data;
	 } else {
	    return 'asa';
	 }
	}

if I visit the url with the browser it's work:

[{"id":33,"id_gioco":4633,"id_utente":2,"voto":"10","updated_at":"2019-01-03 16:59:56","created_at":"2019-01-03 16:59:56"},{"id":34,"id_gioco":4633,"id_utente":1,"voto":"10","updated_at":"2019-01-05 13:57:24","created_at":"2019-01-05 13:57:24"},{"id":35,"id_gioco":4633,"id_utente":8,"voto":"10","updated_at":"2019-01-12 16:02:22","created_at":"2019-01-12 16:02:22"},{"id":36,"id_gioco":4633,"id_utente":4,"voto":"10","updated_at":"2019-03-18 23:47:55","created_at":"2019-03-18 23:47:55"},{"id":37,"id_gioco":4633,"id_utente":9,"voto":"9","updated_at":"2019-03-19 12:50:36","created_at":"2019-03-19 12:50:36"}]

and the debugbar returns me the correct query

select * from `voto_giochi` where `id_gioco` = '4633'

but why does nothing appear in the modal yet?

Activity icon

Started a new Conversation Load Content In Modal From Ajax

I'm trying to load votes in ajax from my controller, only it always returns me empty, and from the debugbar it seems to load the ajax page with the query, but it doesn't print the results in the modal

route

  Route::post('view_voto', '[email protected]_voto');

controller

	public function view_voto(Request $request) {
	 if(!empty($request)){
	   $data = VotoGiochi::where('id_gioco', $request->input('id_gioco'))->get();;
	   //print_r($request->all());
	   return $data;
	 } else {
	    return 'asa';
	 }
	}

html

<div class="modal modal-primary fade" id="votoGiochi" tabindex="-1" role="dialog" aria-labelledby="primaryModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
      <h6 class="modal-title" id="primaryModalLabel">Voti per {{$giochi->nome}}</h6>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span>
        </button>
      </div>
      <div class="modal-body" id="votehere">

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

js

$(document).ready(function(){
    $.ajaxSetup({
      headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      }
    });
   $('#votoGiochi').click(function(){
     var project_id = $(this).attr("id");
     $.ajax({
       url:"{{url('ajax/view_voto')}}",
       method:"POST",
       data: {
         "_token": "{{ csrf_token() }}",
         id_gioco : {{$info_giochi->id}}
       },
       success:function(data){
         $('#votehere').html(data);
         console.log(data);
         $('#votoGiochi').modal("show");
       }
     });
   });
});

Shouldn't print the string into array? Where is it that I am wrong?

Mar
18
2 months ago
Activity icon

Replied to Create A Condition In A Table Inserted With "WITH"

thanks for your answer @nakov ! I didn't know this way.. unfortunately I get the error:

Argument 1 passed to App\Http\Controllers\FrontController::App\Http\Controllers\{closure}() must be an instance of App\Http\Controllers\Builder, instance of Illuminate\Database\Eloquent\Builder given, called in /var/www/vhosts/**.it/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php on line 1008 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Argument 1 passed to App\Http\Controllers\FrontController::App\Http\Controllers\{closure}() must be an instance of App\Http\Controllers\Builder, instance of Illuminate\Database\Eloquent\Builder given, called in /var/www/vhosts/**.it/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php on line 1008 at /var/www/vhosts/**.it/httpdocs/app/Http/Controllers/FrontController.php:573)
Activity icon

Started a new Conversation Create A Condition In A Table Inserted With "WITH"

Hi I have a query, where I want to insert a condition to a table inserted with the "with":

$list_game= InfoGame::with('Games','Platform','Review')
->whereMonth('data', '=', date('m'))
->whereYear('data', date('Y'))
->groupBy('id_game')
->orderBy('data')
->get();

I would like to add the condition active == '1'to the table "Games", i tried with ->where('games.active', '1') but it didn't go...

Dec
31
4 months ago
Activity icon

Replied to Site Also Accessible From /public

@siangboon I did not understand your answer.

the problem is not the forum, but that laravel is accessible from two urls and on google everything is doubled

domain.it domain.it/public

other example:

domain.it/news/1-test domain.it/public/news/1-test

Activity icon

Replied to Site Also Accessible From /public

in the root folder I duplicated the file server.php rename it index.php.

and this I have my htaccess in the root:

<IfModule mod_rewrite.c>
   RewriteEngine On
  
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_URI} =/forum
RewriteRule ^.*[^/]$ /LARACASTS_SNIPPET_PLACEHOLDER/ [L,R=301]
 
   RewriteCond %{REQUEST_URI} !/public/
   RewriteRule ^(.*)$ public/ [L]
</IfModule>

I read on the internet that this is one of Laravel's biggest problems, correctly removing /public the url

Activity icon

Replied to Site Also Accessible From /public

Exactly @snapey , the site works perfectly.

.env etc files are all hidden and cannot be viewed.

I integrated an IP.Board forum platform in Laravel and to have it viewed in domain.it/forum I installed it in public /forum.

then /publish is the main directory of the project... I installed laravel in a DigitalOcean droplet with Plesk

Activity icon

Started a new Conversation Site Also Accessible From /public

I have a big headache, the site is accessible both from domain.it and from domain.it/public and google indexed both of them! and I don't understand why.

can you help me not to make the site accessible from /public? I don't understand how