News Articles laravel

How to use Observers in Laravel?

So what are observers in Laravel and why you should use them? 1. Definition Observers in Laravel help you to fire multiple events or do a CRUD operation in database! When you create an observer, it will listen to a specific condition for a model, e.g: if user create a post and he/she achieved a […]

How to Secure Your Laravel Application

Nowadays, the tools we use to browse the internet require us to follow security standards. Otherwise, they tend to flag our web applications/sites as insecure. Read the full story Source: Hacker Noon – Programming

Vuex+Laravel: Can’t send multiple files with FormData and axios to server side. Always getting null on server side. What’s going on?

The information which I got by my previous question Vuex + Laravel. Why axios sends any values but only not that one, which come's with method's parameter? works only for situation when I pass only one argument in axios. I also found how to successfully pass multiple files with one argument, but in my situation, […]

Vue Js in production not displaying file correctly

I just finished developing an Vue/Vuetify JS +Laravel api(back end). Now I am trying to move it to production mode (to a new server). I ran "npm run build" to generate the filef for production. It worked fine the commnad and I have commited the file. however I am I having a behavior that I […]

How can I properly position an image using laravel-mpdf?

I need to generate a pdf, the HTML itself is ok, but the logo is not where I want it to be. I know that mpdf has some incompatibilities with CSS but I really need this to work. Can someone help me? Thanks in advance! Source: CSS – Stack Overflow

Laravel Eloquent Query containing pivots and relations

I want to make graphs based on values i get from my questionnaire. This is how my database looks like (Only showing the ones I need): questionnaires id client_id questionnaire_answers id questionnaire_id questionnaire_question_id answer questionnaire_questions id question What I want is basically get all the answers of question 1 (of all their questionnaires) from a […]

Relationship between two tables – Laravel, Inertia, Vuejs

I’m new to the subject, I have two tables related to each other, one for departments and one for users, I want to know how many users there are in each department DepartmentController.php public function index() { return Inertia::render(‘back/app/departments/index’, [ ‘filters’ => request()->all(‘visibility’, ‘status’, ‘search’), ‘departments’ => Department::orderBy(‘name’)->get(), ‘total_members’ => User::where(‘department_id’)->count(), dd(User::where(‘department_id’)->count()) ]); } Index.vue […]

How can the css variable from be changed dynamically from `Laravel Nova`?

I am using Nova Settings in which a Color picker field is used. NovaServiceProvider- OptimistDigitalNovaSettingsNovaSettings::addSettingsFields([ Panel::make(‘Colors’, [ Color::make(‘Primary color’)->slider(), Color::make(‘Secondary color’)->slider(), ]), ]); $primary-color = nova_get_setting(‘primary_color’); In my CSS file – :root { –primary-color: rgb(255, 0, 0); //want the nova color setting to be used here –secondary-color: rgb(255, 197, 6); } How can the Nova […]

Updating Files in Production causes Issues with Laravel Mix

I am using Laravel 8 / Vue 2 in my stack. I have a folder in my resources directory that contains json files that need to be accessible to users via javascript. These json files are also updated on occasion through laravel jobs. Now I am able to update these files and access them fine […]

How to protect laravel api route from outside GET request

I’m building the backend with laravel and then using Vue as front-end. Data is accessed over api calls using axios. Now I have this relatively simple task but I can’t seem to find the proper solution. I want one of the routes to be easily consumable by Vue compoenents without the need to log in, […]

Implementing RBAC in Laravel Tutorial

This article was published on my personal blog Role-Based Access Control, or RBAC, is the ability to add roles or restrict actions for users. It can be done in a general, high-level way, for example, to disallow some users from login into the admin panel. It can also be done more specifically, for example, allowing […]

Laravel One of Many Eloquent Relationship (latestOfMany – oldestOfMany – ofMany)

Eloquent relationships is coming to Laravel 8.42 Many times you will see that a model may have many related models, yet you want to easily retrieve the “latest” or “oldest” related model of the relationship. For example, a User model may be related to many BrowserHistory models. // Get Latest Browser History public function latestBrowserHistory(){ […]

Tutorial – Payment Gateway Integration

We are living in the era of technology, To develop a powerful application with smooth runs – you need to select the right set of technologies. Right now, the combination of Laravel and Vue.js is very popular and provides significant results to clients. Specially the need for this combination is increasing for E-commerce websites. Today, […]

How Should an Ideal "Deploy PHP via GitHub Actions" Hosting Service Look Like?

Hi everyone, I’m Robert, Product Owner at IONOS. We recently launched a hosting tool called Deploy Now, that allows users to deploy static sites via GitHub Actions. We would like to move on to PHP in the next step. Thus, my question: How should a “Deploy PHP via GitHub Actions” hosting product look like, so […]

Laravel Eloquent Skip and Take – Offset and Limit

Let’s start quickly. If you want to leave some columns in the database and take a few, is there a problem ? of course not Skip and Take User::skip(4)->take(6)->get(); DB::table(‘users’)->skip(4)->take(6)->get(); Offset and Limit User::offset(4)->limit(6)->get(); DB::table(‘users’)->offset(4)->limit(6)->get(); take can be used within a relationship to extract a certain number of products @foreach ($categories as $category) @foreach ($category->products->take(4) […]

Laravel mix issue: datepicker does not work

The datepicker works on my bootstrap folder. However, when I move everything into laravel, it does not work. I don’t really understand that how css and js work in laravel, so that is why I am here :). /resources/sass/app.scss //css @import url(‘’); @import url(‘’); //js @import url(‘’); @import url(‘[email protected]/dist/js/bootstrap.bundle.min.js’); @import url(‘’); <!–DatePicker–> <div class="col-md-4"> <h4 […]

Clean Code – Laravel

Let’s get started quickly In some cases, clean code must be used as in the following // Don’t do this Post::where(‘category_id’, $category->id) ->where(‘author_id’, $user->id) ->first(); // Do this Post::whereBelongsTo($category) ->whereBelongsTo($user, ‘author’) ->first(); // Don’t do this $post->author_id == $user->id; // Do this $post->author()->is($user); I hope you enjoyed the code. Source: DEV Community

How to use tooltip action button in datatable

I want to add tooltip on my button view. This is the view: I process the data using serverside & ajax datatable, This is my js for call data: var table = $(‘.diagnosis-table’).DataTable({ processing: true, serverSide: true, responsive: true, ajax: "/claim/claimDiagnosis/" + lastSegment, dom: ‘<"top"fB>rt<"bottom"lip><"clear">’, columns: [{ data: ‘diagnosis_id’, name: ‘diagnosis_id’ }, { data: ‘name’, […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.