bgass

Member Since 5 Months Ago

Experience Points
15,260
Total
Experience

4,740 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
143
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 4
15,260 XP
Mar
19
4 weeks ago
Activity icon

Replied to Stop Input Event While Running Long Process

Hi! Sorry for the late reply :)

I don't think the loading states is the solution. With this, I could easily disable the textarea for example so, while the latex file is compiling, you can't continue writing.

But when writing with latex, I usually write text... then, while it's compiling, I continue adding some informations (equations, plots, ...).

What I would need it tell livewire to not fire the "compile" event while it's already compiling. This tells me I should check a little bit more with events :)

Anyway, thanks for your help, I wasn't aware of the loading states :) Really need to go through the whole documentation of livewire !

Mar
04
1 month ago
Activity icon

Started a new Conversation Stop Input Event While Running Long Process

Hi! I'm encountering a problem with livewire... Basically, when I write a text, it sends it to the server and compile the file (it's a latex file). This compilation takes a "long" time. While the compilation is running, I would like livewire to stop receiving events, so there isn't multiple compilation running...

Basically, I have this blade component. It's a simple textarea receving the input. When the data is send to the server, it compiles it and convert it to a svg file. It is then displayed. I'm using the ?v={{$count}} to update the svg image (if you have a better way to do this...)

pdflatex.blade.php

	<div>
		<label>
			Contenu LaTeX
			<textarea wire:model.defer="tex"
					  wire:input.debounce.2s="compile"
					  rows="10"
					  class="w-full bordered"></textarea>
		</label>
	</div>
	
	<img src="/latex/svg/{{$svg}}?v={{$count}}" alt="No image..."/>
	
	@if($updating)
		IMAGE IS COMPILING... {{$count}}
	@else
		NOTHING IS HAPPENING... {{$count}}
		@endif
	
</div>

And now the livewire component/controller:


namespace App\Http\Livewire;

use App\Models\LatexCompiler;
use Livewire\Component;


class Pdflatex extends Component {
	public $tex = 'Something should be written here !';
	public $svg = '';
	public $count = 0;
	public $updating = false;

	public function render() {
		return view( 'livewire.pdflatex' );
	}

	public function compile(){
		$this->updating = true;
		$pdflatex = new LatexCompiler();
		$pdflatex->generateTexFile( $this->tex );
		$pdflatex->compile();
		$pdflatex->convert();
		$pdflatex->clean();
		$this->svg = $pdflatex->compileFile.'.svg';
		$this->count++;
		$this->updating = false;
	}
}

The $pdflatex->compile(); is the process taking a lot of time. It uses new Process([cmd])->run()from Symphony to send a command (it's a pdflatex command, with arguments).

So, basically, what I would like:

  1. When the text is send to the server with the livewire input, livewire should stop listening this event.
  2. I would like to see a visual effect. I tried changing the $updatingvalue, but it's not rendered until the end of the while process... (so it's back the false).
  3. When the process is finished, livewire should send the new svg file and allow listening the input events.

Thanks for your help !

Feb
17
2 months ago
Activity icon

Started a new Conversation Link Custom Articles Blade File In The Database

Hi!

I'm working (slowly) on a website for my students. The website will be divided in multiple parts:

  1. One will be some (math) exercises and I will build them like a "blog", so using a form and a database. For this part, my concern would be to minimize my work between writing in latex and display the result in a website. But this is another question and not really part of laravel.

  2. One other parts, and that's where I have my main question, is to create some pages with dynamic content, where the students can handle geometric figures, plot functions, ... The idea is to do a lot of little "articles" with these dynamic contents (one article per chapter / problem / theme / ...). So I cannot just create a form and paste some text and, once submitted, add it to the database, as it contains alpine.js function and much more...

I already started to make some articles / tools: they are blade files in a paticular folder (and subfolders). Actually, I have two categories:

Tools: I made a controller where I manually add the different possibilities. Not really funny :( Articles: I added at the top of the file a markup (json) data. Once I browse to a particular part of the webiste, laravel scans the folder and add to/update the database with the file header...

So... my question (finally!). Is there a better way to handle this: tell laravel to scan a folder (and subfolder) for blade files and automatically add them to a table in my database ? Or maybe I'm doing everything wrong and I shouldn't do make my files like this ?

Thanks for your help, Basil

PS: By the way, if you have any idea on how to install LaTeX on a website and the command to compile a file...

Jan
21
2 months ago
Activity icon

Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values

The counter is refreshing each time I'm typing. It's important to say that the livewire component is working as it should. What I want is stop making working like this !!!!

For example, when I'm writing: fx 3x+2,-10,10

When I'm writing the first letters, the livewire component should work as usual, until it "founds" a particular value (fx in this case). The component know there is a new page to be loaded and it loads. Perfect until now.

The problem is when I continue typing to give the paramters: the component should know that it already has loaded the fx page and that it should NOT refresh the component, but instead only refresh some "javascript/alpine" values (or an input). My problem is that I can't stop the livewire component to completely refresh when I'm typing.

Activity icon

Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values

I'm aware of the lazy loading. The fact is I want the values to be updated while I'm typing. It's necessary for adjusting various parameters and display the result. So unfortunatly, it isn't the path I'm using :)

Activity icon

Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values

I tried - but it doesn't work. In fact, just to be clear, I have only one livewire element.

Maybe I'm misunderstanding how livewire works: when a value is updated, does this mean the whole livewire component is updated ? Or can we force updating only a part of the component ? The latter is what I'm trying to achieve...

Jan
20
2 months ago
Activity icon

Started a new Conversation Prevent Livewire To Constantly Refresh Page, But Still Update Data Values

Hi!

I'm trying to create a particular livewire component. Basically, it is an input and a "page". The idea is to write a "command" in the input. The first part is a key to load the page, the second part of the command are parameters.

So, for instance, if you write fx 3x-5,-5,5, it should open the page fx and pass the parameters to the page (I'm math teacher :) ).

Basically, it is working... but I have a problem. Once I wrote the beginning of the command fx, the page is loaded as it should, without any parameters. But after that, when I add the parameters, the page is constantly refreshing.

My code for the view:

<div>
	<input autofocus type="search"
		   wire:model.debounce.500ms="input_value"
		   placeholder="Entrer un code..."
		   class="border rounded p-3 focus:outline-none focus:shadow-outline-blue w-full" >
	
	<p>Counts: {{ $renderCount }}</p>
	<div>
		@includeIf($current_page)
	</div>
	
</div>

And my code for the component:

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class Toolbox extends Component {
	public string|null $current_page = null;
	public string $input_value = '';
	public string $key = '';
	public string $previousKey ='';
	public string $params = '';
	public int $renderCount = 0;

	protected $rules = [
		'inputValue' => 'required|string|min:4'
	];

	private function get_tool() {
		$this->key    = explode( ' ', $this->input_value )[0];
		$this->params = trim( mb_substr( $this->input_value, mb_strlen( $this->key ) + 1 ) );

		if ( view()->exists( 'themes.tools.' . $this->key ) ) {
			$this->current_page = 'themes.tools.' . $this->key;
			return;
		}

		// Reset the page to nothing
		$this->current_page = null;
	}

	public function render() {
		$this->get_tool();

		$this->renderCount++;
		return view( 'livewire.toolbox' );
	}

	public function increment() {
		dd('here');
		$this->renderCount++;
	}
}

The main problem is, in particular with the function, is that the loaded page plots a function and add it dynamically. When the page is refreshed, this added div>svg is automatically deleted. I would need to reinitialize it each times.

Is there a better way to do this ? Notice that I also tried to replace the @includeIf($current_page) by a livewire component accepting a parameter like this <livewire:toolpage-page :page="$key"/>, but unfortunately, the component is never updated :(

Hope you can help :) (and also understand what I wrote)

Dec
05
4 months ago
Activity icon

Replied to Passing An Alpine.js Value To A Blade Component Attribute

I solved the problem slightly differently. You mentioned that it was already rendered - this gave me an idea. I passed to the component blade attribute the variable name as a string. In the component file, I used the blade "mustaches" to write the variable name in the rendered component.

Maybe not the best solution, but at least, it allows me to have a reusable signs table :)

Dec
04
4 months ago
Activity icon

Replied to Passing An Alpine.js Value To A Blade Component Attribute

So what's the best way to achieve something similar ? Using livewire ?

Maybe I should explain what I'm doing to be more clear :) I'm writing a webpage that generates an analysis of a math function (not sure of the English name, as I'm usually speaking french).

Basically, it creates 'sign' tables for a simple math function and for a delta function using javascript. The data for each table is stored in an array.

I'm displaying the data in a html table, formatted using tailwindcss: one table for the main function, one table for the delta function. But both html table layout shares the same code, except the data array.

So I thought it was a good idea to create a blade component that would create the table with all the tailwindcss styling and then using alpine.js to fill it. Actually, without the blade component, it's working: I copy/paste the table code and juste changed the data array name in the second table code.

But, to learn and to make the table reusable, I wanted to make it as a component.

If you want to check actual website: https://beta.scolcours.ch/maths/etude-de-fonctions (and yes, it's in french - just click on "Afficher les d├ętails" to see the two tables completeley rendered)

Activity icon

Started a new Conversation Passing An Alpine.js Value To A Blade Component Attribute

Hi! I'm new to Laravel and I wanted to make a blade component. The blade component receives a custom attribute. Basically, the component is working. But it won't work anymore if I fill the custom attribute with an alpine.js value.

<!-- resources/views/example.blade.php -->
<div x-data="{
    myvalue1: 'hello',
    myvalue2: {
        mysubvalue1: 'foo',
        mysubvalue2: 'bar'
    }
}">

    <div x-text="myvalue1"></div>
    <div x-text="myvalue2.mysubvalue1"></div>
    <div x-text="myvalue2.mysubvalue2"></div>


    <x-example-comp valuethrough="a new value is given">My slot goes here !</x-example-comp>

    <x-example-comp valuethrough="somethn else"></x-example-comp>

    <!--- The problem is with the next line -->
    <x-example-comp :valuethrough="myvalue1"></x-example-comp>
</div>

And here is the component:

<!-- resources/views/components/example-comp.blade.php -->
@props([
'valuethrough'=>'nothing'
])

<div>
    Something new here.

    <div>{{$slot}}</div>

    <div>{{$valuethrough}}</div>
</div>

I know there are "conflict" with the blade component (using x- as prefix) and alpine.js. So, my main question is how is the best way to handle this, just passing an alpine.js javascript value (string or even better, an object) to a blade component attribute.

Thanks for your help, Basil