Fresh install of repo?
- npm start
- composer install
- php artisan key:generate
- php artisan serve
- make sure database is connected
- ensure .env file exists and loads (it's the default rootpassword)
- Create a few blog posts -- http://127.0.0.1:8000/articles/create
Kick it off? php artisan serve
LINUX: http://localhost/phpmyadmin/ need to restart apache? sudo service apache2 restart
php artisan make:xxx -xx
public - you can put pure js/html/css in there resources are things that need to be compiled down.
Get npm up and running --> npm install
Then in your webpack, modify things.
in webpack.mix.js
(entrypoint, and output)
FROM:
mix.js('resources/js/app.js', 'public/js')
.sass("resources/sass/app.scss", "public/css");
TO:
mix.sass("resources/sass/app.scss", "public/css");
Next npm run dev
to make it watch -- npm run watch
Finally, import it into your file.
OR use the mix functionphp artisan tinker
$prop = new App\PROP
$prop->value = "new value here"
$prop->data = "new data here"
$prop //to review
$prop->save();
index = show all list
show = show single resource
create = to create new resource
store = save your new creation
edit = to modify resource
update = save your edit
destroy = to destroy it
php artisan make:controller THINGController -r
//this will create the model and tie it to the controller as well.
php artisan make:controller THINGController -r -m THING
http web verbs : GET, POST, PUT, DELETE
GET /articles
GET /articles/:id
GET /articles/:id/edit
GET /articles/create
POST /articles
PUT /articles/:id
DELETE /articles/:id
REST
Route::get('/articles', 'ArticlesController@index');
Route::get('/articles/{article}', 'ArticlesController@show');
Question: How to use Restful Routing and static pages like about us together? Should I create a route like this Route::get("about-us", 'AboutUsController@index') ?
ANSWER: Don't bother. I typically create a PagesController for all static pages. So you'd have actions like PagesController@about, PagesController@contact, etc.
public function store()
{
// die('hello'); // get something to show
// dump(request()->all()); //show all the data
$article = new Article();
// pass article data over
$article->title = request('title');
$article->excerpt = request('excerpt');
$article->body = request('body');
$article->save();
// redirect
return redirect('/articles');
}
If you want to test it.
php artisan tinker
$user = App\User::find(1);
$user->articles;
if (request('tag')) { }
- php artisan tinker
- factory(App\User::class, 7)->create(); //this creates 7 users
If you want to override factory(App\Article::class, 5)->create(['title'=> 'Override the title']);
so to override it to assign the new articles for a specific user factory(App\Article::class, 5)->create(['user_id'=> '1']);
In php artisan tinker
>>> $article->tags;
=> Illuminate\Database\Eloquent\Collection {#3029
all: [
App\Tag {#3019
id: 1,
name: "laravel",
created_at: "2020-01-30 00:00:00",
updated_at: "2020-01-30 00:00:00",
pivot: Illuminate\Database\Eloquent\Relations\Pivot {#3035
article_id: 1,
tag_id: 1,
},
},
App\Tag {#3022
id: 2,
name: "php",
created_at: "2020-01-30 00:00:00",
updated_at: "2020-01-30 00:00:00",
pivot: Illuminate\Database\Eloquent\Relations\Pivot {#3023
article_id: 1,
tag_id: 2,
},
},
App\Tag {#3036
id: 3,
name: "education",
created_at: "2020-01-30 00:00:00",
updated_at: "2020-01-30 00:00:00",
pivot: Illuminate\Database\Eloquent\Relations\Pivot {#3033
article_id: 1,
tag_id: 3,
},
},
],
}
>>> $article->tags->pluck('name');
=> Illuminate\Support\Collection {#3032
all: [
"laravel",
"php",
"education",
],
}
Attaching a tag
$article->tags()->attach(1)
//This takes the variable you created, visits the tag method, and uses the attach (1).
$article->tags()->attach([2,3])
//same, but with an array.
detach is the opposite.
$article->tags()->detach([2,3])
$tag = App\Tag::find(1); => App\Tag {#3033 id: 1, name: "laravel", created_at: "2020-01-30 00:00:00", updated_at: "2020-01-30 00:00:00", }
$article->tags()->attach($tag); $tag = App\Tag::find(2);
You can provide a single ID. You can provide an array. You can provide a model. You canprovide an array of models.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, Laracasts can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Patreon page.
- Vehikl
- Tighten Co.
- Kirschbaum Development Group
- 64 Robots
- Cubet Techno Labs
- Cyber-Duck
- British Software Development
- Webdock, Fast VPS Hosting
- DevSquad
- UserInsights
- Fragrantica
- SOFTonSOFA
- User10
- Soumettre.fr
- CodeBrisk
- 1Forge
- TECPRESSO
- Runtime Converter
- WebL'Agence
- Invoice Ninja
- iMi digital
- Earthlink
- Steadfast Collective
- We Are The Robots Inc.
- Understand.io
- Abdel Elrafa
- Hyper Host
- Appoly
- OP.GG
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.
The Laravel framework is open-sourced software licensed under the MIT license.