Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

moses's avatar
Level 2

How to write code in laracast?

I want to write code that cleanly. So nice views. How can I do that?

0 likes
168 replies
Jaytee's avatar

I'm getting mixed signals, do you want to format your code properly here on the laracasts forum or in your project(s)?

You can click the link below the reply form here to view the "Github Flavoured" markdown code to see how to format your code.

1 like
sherwinmdev's avatar

use 3 backticks to start and 3 backticks when done. anything in between will be formatted. you should be able to use the tab key inside this textarea. if you don't know what the backticks are, it's the same key as the tilde. https://i.stack.imgur.com/TOn1U.png

6 likes
getvma's avatar
This is wrapped using 3 backticks  ` 

​```


Code goes in here..



​```        
18 likes
Prido's avatar

​`​`` Test

​`​``

1 like
codekko's avatar
public store function {
			dd('test');
}

DarkRoast's avatar

You can use the tilde (~~~) character for code blocks too - useful if you've bound your backtick character to the terminal :P

3 likes
bixelyte's avatar

test :D


class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function __construct()
    {
        //this is a comment
    }
}

Snapey's avatar

you can also indent code by 4 spaces

Snapey's avatar

You can use the tilde (~~~) character for code blocks too - useful if you've bound your backtick character to the terminal :P

or if using a mobile device where the backtick is some painful hold-for-obscure-character type of thing

5 likes
webrobert's avatar

@Snapey I love this thread. For mobile I created a autocorrect for the painful-to-get-to. I didn’t know about the alternates. So when I type codee it autocorrects to the backticks.

laravel_ninja's avatar

@Snapey testing~~~ {

    if ($request->query('model')) {
        $ads = Ad::where('car_make', 'like', '%' . $request->query('model') . '%')->paginate(5);
        return view('tailwind.search', [
            'ads' => $ads
        ]);
    }
stevenh's avatar

Testing....

$result = $result->newQuery();

stevenh's avatar

testing...

public function show($id)
    {
        $work = Work::find($id);
        return view ('works.show')->with('work', $work);
    }
islamnouman's avatar

@stevenh


public function show($id)
    {
        $work = Work::find($id);
        return view ('works.show')->with('work', $work);
    }



blitzkin's avatar

test

class Another extends Model { //

public function user(){
    return $this->belongsTo('App\User');
}
Next

Please or to participate in this conversation.