12. Laravel - kód
<?php
namespace AppHttpControllers;
use AppUser;
use AppHttpControllersController;
class UserController extends Controller
{
public function show($id)
{
return view("user.profile", ["user" => User::findOrFail($id)]);
}
}
#wpweekendcz | @hlavacm
16. 2. Corcel
This package allows you to use
WordPress as backend (admin panel) and
retrieve its data using Eloquent, with any
PHP project or even framework.
https://github.com/corcel/corcel
#wpweekendcz | @hlavacm
23. Corcel - custom post type
// using type() method
$videos = Post::type("video")->status("publish")->get();
// using your own class
class Video extends CorcelPost
{
protected $postType = "video";
}
$videos = Video::status("publish")->get();
#wpweekendcz | @hlavacm
24. Corcel - uživatelé
// only all categories and posts connected with it
$cat = Taxonomy::where("taxonomy", "category")
->with("posts")->get();
$cat->each(function($category) {
echo $category->name;
});
// clean and simple all posts from a category
$cat = Category::slug("uncategorized")->posts()->first();
$cat->posts->each(function($post) {
echo $post->post_title;
});
#wpweekendcz | @hlavacm
25. Corcel - uživatelé
// All users
$users = User::get();
// A specific user
$user = User::find(1);
echo $user->user_login;
#wpweekendcz | @hlavacm
26. Corcel - co umí?
■ Posts
■ Advanced Custom Fields (ACF)
■ Custom Post Type
■ Shortcodes
■ Taxonomies
■ Post Format
■ Pages
■ Categories & Taxonomies
■ Attachment and Revision
■ Menu
■ Users
■ Authentication
#wpweekendcz | @hlavacm