What are virtual columns? While developing any web application sometimes we need virtual columns - columns don't actually exist in our DB table, but we drive them from other columns. Why we need them? For example, generally, we use first_name and last_name in the users table. But sometimes we also need user's complete name i.e. full_name . There is no benefit of saving full_name in user table if we have already first_name and last_name in the table OR even if we have full_name as a column in our table then there is no benefit of saving first_name and last_name in the table. So in a scenario like this, we prefer to use the virtual column. Using Virtual Columns in Laravel Considering the first case, in Laravel to get virtual column i.e. full_name from the users table will have Accessors. Accessors are methods defined automatically called by Eloquent when select is called on that particular column. Let take an example here: To get full_...
Cookie in Laravel You can use the cookie in Laravel using the Helper method ` cookie() ` or method available with Request/Response Object or `Cookie` facade. $request->cookie('name'); OR use Illuminate\Support\Facades\Cookie; Cookie::get('name'); To get more clarity on how to use the cookie in Laravel with an example to show cookie consent popup on your Laravel website and hide/remove it once you accept the policy. Cookie Policy Consent Popup in Laravel First, create and a Cookie Consent popup as notification to the footer section of your Laravel main blade template file. <div class="cookies-block"> <h5>This website uses cookies</h5> <p>We use cookies to improve your experience and deliver personalised content. By using this website, you agree to our <a href="javascript:void()">Cookie Policy</a>.</p> ...
You may have read differences between PostgreSQL datatypes JSON and JSONB. If not, let see the difference between both theoretically and practically. Although, both json and jsonb are types of PostgreSQL JSON datatypes and accepts almost same format as input values i.e. json. But still there are some difference which one must know to efficiently use or can choose from both json and jsonb. The main different is how they actually store data; the json data type stores input value as it is but jsonb stores value in a decomposed binary format which lead to difference in efficiency . Jsonb is slower as compare to json while saving the input values because of converting json values to binary format before saving. Jsonb fast in processing the data because no re-parsing needed as compare to json datatype which needs processing function to re-parsing on every execution. Few other differences between json and jsonb are: Jsonb supports indexing which is advantage over j...
Comments
Post a Comment