preloader
學習 Laravel 5.5 Eloquent relation whereHas and whereRaw usage

Version: Laravel 5.5 Model: Post, Comment Post’s columns: id, title, content, created_at, updated_at Comment’s columns: id, post_id, content, c_date, c_time, u_date, u_time Relation: A post has many comments and a comment belongs to a post. The following shows how to get posts, which had been comments in recent 24 hours. use CarbonCarbon; // use package Post::whereHas('comments', function ($query) { $query->whereRaw('(u_date = ? AND u_time >= ?) OR (u_date =? AND

read more
軟體工程 Laravel 5.5 Get session value or Loginned user data at AppServiceProvider

We can get session value or data of a loginned user at AppServiceProvider. The following we will show how to get, share values of session and loginned user to all views. ========= Code: namespace App\Yourapp\Younamespace; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Session; use Illuminate\Support\View; use App; class AppServiceProvider extends ServiceProvider{ public function boot() { $auth = $this->app['auth']; // get Laravel's Auth facades view()->composer('*', function($view) use (&$auth) { // this function coding style is

read more

About

Howard Lee, Frontend-engineer with Angular 7+, Typescript, ReactJS, VueJS. Flutter, Dart, PHP, Ruby, JavaScript, HTML, SASS, CSS, Postgres, MySQL, Web Developer. Have a certificate of AWS Solution Architect Associate with verify number: 8FYNL55LCEEQ10W5. You can verify at AWS Certificate site or Credly site Tech lead role Lead 4 colleagues to build products and infrastructure Coordinate schedule of delivering products Senior web frontend developer role Products Form-filling, form-sharing, file-management, repair-managemnt and project-management for construction industry at Suiqui IoT management and EC platform for Liquid Petroleum Gas(LPG) at Wave-In Comm.

Know More

Tag

Social