Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
controller returns plain text & HTML & view
Returns plain text
public function contact() {
        return 'Under Construction';
}
Returns HTML
public function about() {
        return '<h1>About the site</h1>details...';
}
Returns view located at
resources/views/pages/services.blade.php
public function services() {
        return view('pages/services');
}
by Valeri Tandilashvili
4 years ago
0
Laravel
controllers
Laravel From Scratch
1
ctrl + p
-> search
ext install laravel blade
-> install
laravel blade snippets
extension
by Valeri Tandilashvili
4 years ago
0
Laravel
extensions
Laravel From Scratch
1
Pass parameter to view using
with
method
public function about() {
        $param1 = 'this is a parameter of about us page';
        return view('pages/about')->with('title', $param1);
}
Content of the blade template
@extends('layouts.app')

@section('cntnt')
    <h3>abt us {{$title}}</h3>
@endsection
by Valeri Tandilashvili
4 years ago
0
Laravel
blade template
Laravel From Scratch
1
Makes controller for
Posts
php artisan make:controller PostsController
With the following basic content
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class Postscontroller extends Controller
{
    //
}
Creates controller and empty methods in it (with appropriate comments)
php artisan make:controller PostsController --resource
The methods are:
index()
- Displays a list of the resource.
create()
- Shows the form for creating a new resource
store(Request $request)
- Stores a newly created resource in storage
show($id)
- Displays the specified resource
edit($id)
- Shows the form for editing the specified resource
update(Request $request, $id)
- Updates the specified resource in storage
destroy($id)
- Removes the specified resource from storage
by Valeri Tandilashvili
4 years ago
0
Laravel
artisan commands
Laravel From Scratch
1
Makes model called
Post
php artisan make:model Post
With the following basic content
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //
}
Creates
Post
model and also migrations to create table for the model
php artisan make:model Post -m
The migration file location is
database/migrations/2020_09_02_041219_create_posts_table.php
by Valeri Tandilashvili
4 years ago
0
Laravel
artisan commands
Laravel From Scratch
1
.env
file contains database config information that needs to be changed to use the database
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lara4db
DB_USERNAME=root
DB_PASSWORD=
by Valeri Tandilashvili
4 years ago
0
Laravel
Laravel From Scratch
1
create table
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->mediumText('content');
    $table->timestamps();
});
$table->id()
- creates
bigint(20)
unsigned auto-increment field
$table->string('title')
- creates
varchar(255)
utf8mb4_unicode_ci field
$table->mediumText('content')
- creates
mediumtext
utf8mb4_unicode_ci field
$table->timestamps()
- creates
created_at
and
updated_at
timestamps
by Valeri Tandilashvili
4 years ago
0
Laravel
migrations
1
Shows all the routes that we have in our application
 php artisan route:list
by Valeri Tandilashvili
4 years ago
0
Laravel
routes
Laravel From Scratch
1
Creates all 7 routes for the resource to cover CRUD functionality
Route::resource('posts', 'PostsController');
These routes are:
GET
at
posts
to list all the posts
POST
at
posts
to store new post
GET
at
posts/create
to show form for creating new post
GET
at
posts/{post}
to show the post
PUT
at
posts/{post}
to update the post
DELETE
at
posts/{post}
to delete the post
GET
at
posts/{post}/edit
to show edit form
by Valeri Tandilashvili
4 years ago
0
Laravel
routes
Laravel From Scratch
1
We can order posts by
created_at
with
descending
order, to see the newly created posts at the top
by Valeri Tandilashvili
4 years ago
0
Laravel
Laravel From Scratch
1
Results: 1580