gitwithravish

Full Stack Developer at Unocoin

Member Since 1 Year Ago

Bangalore, India

Experience Points
72,860
Total
Experience

2,140 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
326
Lessons
Completed
Best Reply Awards
48
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 15
72,860 XP
May
09
2 days ago
Activity icon

Replied to Microservices Using Laravel

Agree to that. Not trying to implement microservices ofcourse.

The reason why I put this post is this - We consulted a couple of solution architect for an enterprise application.

Both the architects asked us to consider nosql over sql saying "nosql is scalable whereas mysql is difficult to scale when app hits a certain threshold. Its very difficult to do horizontal scaling for mysql". and "monolithi app can lead to many problems when app is big which can be solved using microservices. Everyone is using microservice."

Their overshining confidence dragged me here to do some digging. But I feel that people exaggerate new technologies so much that makes the classic approaches look bad. Which is not true.

Thanks @martinbean

Activity icon

Started a new Conversation Microservices Using Laravel

Any courses, articles or other resources to see the implementation of microservices in action ?

I have been reading case studies of companies like Uber and how they decided to convert from monolithic architecture to microservice architecture. These studies showed that an application was divided into microservices such as payments, pasanger management, driver management etc.

I could not find a single resource that explains how it gets implemented on development level.

  • How the api endpoints look like ? Is a common api gateway used which connects all small microservice apis ? Or the app uses all different apis directly ?
  • Are these services literally an application deployment in itself ?
  • Some microservices has its own database. If that is so then what about the common data of that app ? For instance how the user_ids are passed in microservice's dbs ?

Please share some resources to implement microservices in using laravel.

May
08
3 days ago
Activity icon

Replied to Multiple Array Checkbox With Vuejs Not Working ...

HTML

<tr v-for="subject in subjects" :key="'subject-'+subject.id">
    <td class="is-vcentered">
        <field>
            <input type="checkbox" :value="subject.id" v-model="selectedSubjects"> {{ subject.name }}
            <input type="number"
                v-model="selectedSubjects['hours_number']"
                :value="subject.hours_number" />
                {{ subject.hours_number }}
        </field>
    </td>
</tr>

SCRIPT

new Vue({
  el: '...',
  data: {
    selectedSubjects: ['a','b','c'],
  }
})

https://vuejs.org/v2/guide/forms.html#Checkbox

May
06
5 days ago
Activity icon

Replied to Advice On How To Manage The Comment List And Replies To Comments

Well, right now there is only one partial blade file that handles comments and replies. If you want to give different css to comments and replies. There are two ways to go.

Option 1

Write different code for comment and reply under the same file by putting conditions. Now you apply different css to replies and different css to main comment. replies.blade.php

@foreach($comments as $comment)
	@if(is_null($comment->parent_id))
		// write html-css for comment
	@else
		// write html-css for reply
	@endif
@endforeach 

Option 2

If the code is getting messy then create two partial files comments.blade.php and replies.blade.php. Call the second partial from the first one if the comment has replies.

@marcolino922

Activity icon

Replied to Advice On How To Manage The Comment List And Replies To Comments

@marcolino922 go trough the links i have shared. That explains everything.

Activity icon

Replied to Same VueJS Template On Multiple Subdomains

Code reusability is not an issue. Even if a pull assets from a centralized custom npm package, they will still be loaded from server instead of cache while changing the subdomain.

Imagine u have two identical projects which identical files. You have implemented caching. But if you go from 1st domain to 2nd domain, your assets will be reloaded from the 2nd server now, even they are identical. I want those to be loaded from the cache or i want the server to recognise that the assets in the cache will do.

This can be done if i include URL of the asset for instance. The next subdomain will also expect for the first url and thus it will be loaded from cache.

But I dont know if that's gonna work how I think and also, in frontend frameworks, scripts and styles gets added dynamically with the component in chunks. And there are many other framework specific things that I am not sure of finding an alternative for.

May
05
6 days ago
Activity icon

Awarded Best Reply on Returns All Products In Addition To The Sum Of Pivot Quantity And Amount For Each Product

Using query builder

  • Join product table and invoice table
  • Define calculated columns
  • Group by based on product_id
DB::table('products')
	 ->leftJoin('product_invoices', 'product_invoices.product_id', 'products.id')
     ->select(
			'products.id', 
			'products.name', 
			DB::raw('sum(product_invoice.quantity) as total_quantity'),
			DB::raw('sum(product_invoice.amount) as total_amount') 
		)
     ->groupBy('product_id')
	 ->get();

Hope that helps @mqandeel

Activity icon

Started a new Conversation Same VueJS Template On Multiple Subdomains

I have multiple apps hosted each on its own subdomain, backed by same organisation.

I am using a template in all the projects. Is there any way to optimise the assets using some kind of caching ?

Because usually the users tend to jump from one subdomains to the other and since the projects are hosted separately, but the resource files are mostly similar since its a common template used in all the projects. Almost same 80% of assets get loaded again from different server when user go to other subdomain.

Is there anyway to optimise the projects? Is there some standard solution to store the asset files on some cloud platform or something ? So that all project can then call to that same url for loading assets ?

Any thought / experience / blog / article related to this will be helpful :)

Thanks.

Activity icon

Replied to Returns All Products In Addition To The Sum Of Pivot Quantity And Amount For Each Product

@mqandeel That was a spelling mistake. I updated my answer. You just have to use correct table names. Try the query again.

Activity icon

Replied to Toggle Button

Use accepted rule rather than required

"coupon_accepted" => "accepted"
May
04
1 week ago
Activity icon

Awarded Best Reply on How To Calculate Time Difference Plus Sum This Based On Grouping

You're welcome @davyc :)

That's weird that it did not get uploaded here!

Anyways I am writing it in this again so that you can mark it as solved. Cheers

Time::select(
			'times.*',
			DB::raw('sum(TIMESTAMPDIFF(minute, stop, start)) AS total_time'),
		)
         ->groupBy('user_id')
        ->get();
Activity icon

Started a new Conversation User Activity Logs - Database Vs Text Files

There are many opinions about using log files over database for saving user activity logs. But in following requirements, using log files does not solve the problem.

Example

  • An e-commerce website where the rates of the product keep changing based on the user settings or manual update. These changes need to be logged. There is an active rates table and for valid reasons, these logs cannot be stored in that active_rates table.
  • Information from the logs need to be retrieved at times. For example, when a user inquires about incorrect behaviours in the product prices, we need to perform complex queries on those logs which is not possible to perform on file based logs. (Even if we try to divide the files into multiple files and folders for search and sort ease)

So, as I have mentioned, storing logs in the database is needed.

There are dozens of user_actions for which activity logs need to be saved.

Questions

  • Should I save the logs in another database ? It is expected to have thousands of entries each day and the log table is required to contain at least a year long data. Therefore the log table would have millions of rows at pick time.
  • Is one table is okay with action_type_id or making multiple tables for each action make sense?
Activity icon

Started a new Conversation Good Practices To Share Common Data Across Multiple Databases

Example scenario

service-provider.com
  • This website is used for SSO
  • It has a user dashboard with user resources details, billing details for the services user uses for each of his resources, etc.
  • The user can subscribe his resources to different services hosted on different subdomains as mentioned below
app1.service-provider.com  
app2.service-provider.com  
app3.service-provider.com
  • Each subdomain provides a unique service
  • Each subdomain has a backend api and frontend website in VueJS. `

Single Database Approach:

Followings are the reasons why I do not want to consider this.

  • The number of subdomains will reach 10-12 eventually. Each will have some data heavy tables, cron jobs, analytics, system logs etc.
  • I do not want a single employee to be able to see the entire database. There will be dedicated team of developers for each app and they will work with only the app specific separate api and frontend project

Questions that I have with multiple database approach

  1. How do I share the user details from parent domain to subdomains and its databases ? Should I add user_id and admin_id columns to subdomain databases without defining foreign key constraints? If yes, then what if I want to move one app database to another server ? In that case the foreign key constraint won't work right ?
  2. How do I access the common data in subdomains? Through main domain api or by making direct connection with the db ?
  3. Is it okay to replicate common data across apps ? (I don't think that's a good way to go about it)
  4. Are there any articles about multiple database design for sso project ?

Any help would be really appreciated. Thank you.

Activity icon

Replied to How To Calculate Time Difference Plus Sum This Based On Grouping

You're welcome @davyc :)

That's weird that it did not get uploaded here!

Anyways I am writing it in this again so that you can mark it as solved. Cheers

Time::select(
			'times.*',
			DB::raw('sum(TIMESTAMPDIFF(minute, stop, start)) AS total_time'),
		)
         ->groupBy('user_id')
        ->get();
Activity icon

Replied to Single JWT Based Authentication System Among Multiple Websites Using Vue

@fylzero Thanks for the tip. Actually want to design a database structure for this.

I have multiple applications (20+) as subdomains. 80% of the data will be separate for each application. However couple of applications have more than 50% in common.

All these applications should not have separate user base. One user in parent domain should be allowed to access any app on subdomain.

There are some common data that all subdomains would want to access. e.g. users, user-roles-permissions, user-subscriptions, user-notification settings. etc.

All the subdomains also requires foreign key derived from this common data. Example, user_id.

One option is to create a big database and put all in but I do not think its a good idea because the subdomains will keep increasing and load on each app will keep increasing. And also, I would want to isolate api and front end project of all the apps separate from each other so that company employees do not get to see all the company code in one single big api project and one single big database .

So I basically want to create api-frontend project couple for all subdomains and one for parent domain as well, which will have a login page and an admin dashboard. (Something like Atlassian and its products like JIRA). But my question is how do I connect the parent domain database with subdomain apps ?

  • Should I pass user_id to all the sub domain databases from parent database ? Should I create user_id column in subdomains but not assign referencial integrity to the parent domain's database ?
  • How do I fetch the common data from parent database? Direct connection ? API ? If I use direct connection then I can actually use the eloquent models and its methods to write short code that does more. But i dont know if that is a good enough reason to do so....

I would really appreciate if you can share your thoughts on this. You seem like an experience one :)

May
03
1 week ago
Activity icon

Replied to How To Calculate Time Difference Plus Sum This Based On Grouping

Sorry, syntax error. Here you go.

Time::select(
			'times.*',
			DB::raw('TIMESTAMPDIFF(minute, stop, start) AS minutes'),
			DB::raw('sum(minutes) as total_time')
		)
         ->groupBy('user_id')
        ->get();
May
01
1 week ago
Activity icon

Replied to Returns All Products In Addition To The Sum Of Pivot Quantity And Amount For Each Product

Using query builder

  • Join product table and invoice table
  • Define calculated columns
  • Group by based on product_id
DB::table('products')
	 ->leftJoin('product_invoices', 'product_invoices.product_id', 'products.id')
     ->select(
			'products.id', 
			'products.name', 
			DB::raw('sum(product_invoice.quantity) as total_quantity'),
			DB::raw('sum(product_invoice.amount) as total_amount') 
		)
     ->groupBy('product_id')
	 ->get();

Hope that helps @mqandeel

Activity icon

Replied to Advice On How To Manage The Comment List And Replies To Comments

Option 1

  • comments and replies table

https://laracasts.com/discuss/channels/eloquent/how-to-get-posts-with-comments-and-replies

Option 2

  • comments table to store both
  • This one might feel a little tricky but it is a good design. You really dont need to make two tables. Reply can be considered as comment on another comment.
  • A column parent_id can be made to link parent comment. A column with parent_id null means its a comment, and any comment with integer parent_id means its a reply to comment if defined in the given column.
  • In this case you can also achieve nested comments/replies.
  • Note that in the following link there are two columns commentable_type, and commentable_id. It is used when your application has comments on multiple things like posts, videos etc. In that case this polymorphic approach is useful. But since your application is "little" you might not need these. You can instead have only one column post_id

https://www.codecheef.org/article/create-your-own-multilevel-nested-comments-system-in-laravel

Hope this helps @marcolino922

Activity icon

Replied to Call To A Member Function Where() On String

public function getLastInvoice()
{
     return $this->where('user_id', Auth::id())->latest('id')->first() ?? null;
}
Activity icon

Started a new Conversation Single JWT Based Authentication System Among Multiple Websites Using Vue

I have one domain with multiple subdomains. The domain and subdomain websites are individual vue projects. All are connected with multiple apis, that are connected with single database.

The authentication system in the main domain is JWT based.

If a user is logged into main domain, he should be allowed to access any subdomain. If he has not logged in then he should be redirected from subdomain to main domain's log in page.

My question is how will all projects know about the JWT token? How do I achieve a communication bridge between all these projects.

Activity icon

Replied to Hide Mutators Data In Eager Loading Data

  • One way is to remove those fields from $appends array attribute in your model class. But then if in some cases you do need those fields, then it will again be tricky.
  • Other way to go about it is to use some kind of transformer class or simply loop through the collection and remove it. Though it might feel a little extra work.
  • Apart from that you can try this trick. It doesn't feel perfect but it will get the job done.

https://stackoverflow.com/a/43849449/9817945

@kundefine

Activity icon

Replied to Updating Vue Array To Use In For Loop Doesn't Show Data

Since many JavaScript frameworks also use "curly" braces to indicate a given expression should be displayed in the browser, you may use the @ symbol to inform the Blade rendering engine an expression should remain untouched. For example:

https://laravel.com/docs/8.x/blade#blade-and-javascript-frameworks

Activity icon

Replied to How To Calculate Time Difference Plus Sum This Based On Grouping

Yes you are doing it completely wrong.

Do it like this. First you define that calculated column using sql function TIMESTAMPDIFF, then you group by user_id with sum total value of that calculated column ;)

Time::selectRaw('times.*, TIMESTAMPDIFF(minute, stop, start) AS minutes', 'sum(minutes) as total_time')
         ->groupBy('user_id')
        ->get();
Activity icon

Replied to Updating Vue Array To Use In For Loop Doesn't Show Data

You cannot load ajax data like that. Vue will not detect the tag since the virtual dom is already rendered and after that you are making this ajax call.

You will have to handle it at javascript level.

Activity icon

Replied to Checking If A Value Is Present Using Jquery.inArray()

@anand_aks Hey anand. You need to do it like this

if(jQuery.inArray(barcode, Object.keys(data['session'])) !== -1)
{
	// barcode exist in the array
}

Apr
30
1 week ago
Activity icon

Replied to How Can I Add Emoji To My Comments Section

You can use javascript to add emoji selector on your comment textarea. Saving the textarea on laravel will not be any different. Just ensure your database is using utf8mb4.

This jquery plugin should do the job for you @kikismedia

https://www.jqueryscript.net/demo/twemoji-emoji-keyboard/

Apr
29
1 week ago
Activity icon

Awarded Best Reply on Portfolio Site For A New Graduate In Computer Engineering.

  • A portfolio is about self branding. You basically have to showcase your skills. If you are going to showcase your skills in some fancy fonts saying i know html, css, js, some framework etc etc, you are falling into the general category of developers. Every other developer is doing that.

  • As far as I have experienced, good companies where you would like to work will not be impressed easily. Because your CV/Portfolio is just talking. it is not showing anything. Your portfolio should not talk a lot, its rude. Rather It should show off.

  • So i suggest, just do one project at least. Anything, small-medium-big, whatever. But if you do some project, put it live and provide link, it gives your portfolio confidence. Now you are not just talking like every other developer.

  • In addition to this, if you wanna grow as an IT professional in a company, you must have good communication skills. I have seen people getting promoted that are less skilled than others but are very good at communication and have good self confidence. And its fair because job routines of it professionals on higher position includes communication in every area. With team members, with their bosses and most importantly, with third party companies and service providers. So I suggest you should do a certification in one of such courses. There are some descent ones on coursera. Most of the online certifications are not worth it, to be honest, but it can still add some more value to your portfolio if you are just starting off and dont have kickass skills.

  • Apart from this, if you are making a website, then make sure that at least that website performs fast enough. If you are applying for a job profile where the company is looking for professionals who are good at quality and performance, then having a fast website is a must.

what could I talk about, to impress a company

If you get an interview, then do good research about the company and go. At least know their reputation in the market, client base and their service/product. In fact in the interview, take the authority and ask them a couple of questions about their company. Also, understand, a company would hire you only if you can solve a problem for them. So you should have an answer ready to why they should hire you.

Hope that helps @villdar

Activity icon

Replied to Laravel User Registration Failes.

show code that gets executed on this->post('/register'...

Apr
28
1 week ago
Activity icon

Replied to Portfolio Site For A New Graduate In Computer Engineering.

  • A portfolio is about self branding. You basically have to showcase your skills. If you are going to showcase your skills in some fancy fonts saying i know html, css, js, some framework etc etc, you are falling into the general category of developers. Every other developer is doing that.

  • As far as I have experienced, good companies where you would like to work will not be impressed easily. Because your CV/Portfolio is just talking. it is not showing anything. Your portfolio should not talk a lot, its rude. Rather It should show off.

  • So i suggest, just do one project at least. Anything, small-medium-big, whatever. But if you do some project, put it live and provide link, it gives your portfolio confidence. Now you are not just talking like every other developer.

  • In addition to this, if you wanna grow as an IT professional in a company, you must have good communication skills. I have seen people getting promoted that are less skilled than others but are very good at communication and have good self confidence. And its fair because job routines of it professionals on higher position includes communication in every area. With team members, with their bosses and most importantly, with third party companies and service providers. So I suggest you should do a certification in one of such courses. There are some descent ones on coursera. Most of the online certifications are not worth it, to be honest, but it can still add some more value to your portfolio if you are just starting off and dont have kickass skills.

  • Apart from this, if you are making a website, then make sure that at least that website performs fast enough. If you are applying for a job profile where the company is looking for professionals who are good at quality and performance, then having a fast website is a must.

what could I talk about, to impress a company

If you get an interview, then do good research about the company and go. At least know their reputation in the market, client base and their service/product. In fact in the interview, take the authority and ask them a couple of questions about their company. Also, understand, a company would hire you only if you can solve a problem for them. So you should have an answer ready to why they should hire you.

Hope that helps @villdar

Activity icon

Awarded Best Reply on Query Foreign Key

Ensure that the value of $this->sortBy is customers.name

Activity icon

Replied to Query Foreign Key

Ensure that the value of $this->sortBy is customers.name

Activity icon

Awarded Best Reply on Syntax Error Or Access Violation: 1055. ID Isn't In GROUP BY

When you fetch relationship with eloquent, it makes two query. Therefore this query won't work the way you are expecting.

Try to do this using query builder. Something like this,

Cart::leftJoin('users', 'users.id', '=', 'carts.user_id')
  ->groupBy('carts.user_id')
  ->get();

There are some tricks to get it working with eloquent. I recommend checking out this

https://p.softonsofa.com/tweaking-eloquent-relations-how-to-get-hasmany-relation-count-efficiently/

Activity icon

Replied to Laravel 8 - 400 Bad Request Error

Not able to understand the context. Provide more information

Activity icon

Replied to 'sanctum/csrf-cookie' Has Been Blocked By CORS Policy

Ensure to put asterisk in this value :P

cors.php

'allowed_origins' => ['*'],

Run php artisan config:cache and try again

Activity icon

Replied to Transactions With Multiple Database Connections

@janewinkler This looks okay to me, but if you want to do this in fewer lines then do this

DB::transaction(function($conn){
    DB::connection('db2')->transaction(function($conn){
        // do your magic here
    });
});
Activity icon

Replied to Excluding Holidays From My Holidays Table From Date Range

Short answer

I don't think there is any efficient way to get this done. It is more about database design rather then the ORM. A quick inefficient way is to use ->whereNotIn('date',$holidays) and get it done.

Efficient way

  • Its not that straightforward to get it working efficiently. When you have to work with dates like this, where type of day (weekday/weekend), holidays, season etc play a role in business logic and fetching queries, you should create a calendar table.
  • A calendar table contains all the dates with meta date columns like is_weekend, is_holiday, is_last_day_of_week, is_last_day_of_month etc.
  • Then you simply make a query on calendar table filtering holidays and join your target table to get results
  • Also, you should keep the date column in target table reference to the calendar table for better performance.

Hope that makes sense to you.

Activity icon

Replied to Syntax Error Or Access Violation: 1055. ID Isn't In GROUP BY

When you fetch relationship with eloquent, it makes two query. Therefore this query won't work the way you are expecting.

Try to do this using query builder. Something like this,

Cart::leftJoin('users', 'users.id', '=', 'carts.user_id')
  ->groupBy('carts.user_id')
  ->get();

There are some tricks to get it working with eloquent. I recommend checking out this

https://p.softonsofa.com/tweaking-eloquent-relations-how-to-get-hasmany-relation-count-efficiently/

Activity icon

Replied to Connecting Multiple Subdomains To Single Laravel Project

I am not using valet.

I am running subdomain.localhost:8000 and its not working like that.

Activity icon

Replied to Query Foreign Key

Why do you want two select methods ? You can get the job done within one only ! @chris1989

$calculatedCol = \DB::raw('charges.*,SUM(taskscharges - payment) as balance');
$charges = charge::query()
            ->search($this->search)
         	->select('charges.*', 'customers.name', $calculatedCol)
            ->join('customers', 'charges.customer_id', '=', 'customers.id')
            ->groupBy('id')
            ->orderBy($this->sortBy, $this->sortDirection)
            ->paginate($this->perPage);
Apr
27
2 weeks ago
Activity icon

Awarded Best Reply on Validation Using Closures

If you have 3 tabs, then make 3 validators

// create validator for 1st tab
$validator = Validator::make($request->all(), [
	'field_1' => 'rules...',
	'field_2' => 'rules...'
	...
]);

// check if tab 1 fails
if($validator->fails()){
	// return error with tab name
}

// create validator for 2nd tab
$validator = Validator::make($request->all(), $tab2Rules);


// check if tab 1 fails
if($validator->fails()){
	// return error with tab name
}

@prospero hope that helps :)

Activity icon

Replied to Connecting Multiple Subdomains To Single Laravel Project

@fylzero can you suggest something for faking subdomains while working on local ?

Activity icon

Replied to Validation Using Closures

If you have 3 tabs, then make 3 validators

// create validator for 1st tab
$validator = Validator::make($request->all(), [
	'field_1' => 'rules...',
	'field_2' => 'rules...'
	...
]);

// check if tab 1 fails
if($validator->fails()){
	// return error with tab name
}

// create validator for 2nd tab
$validator = Validator::make($request->all(), $tab2Rules);


// check if tab 1 fails
if($validator->fails()){
	// return error with tab name
}

@prospero hope that helps :)

Apr
26
2 weeks ago
Activity icon

Replied to Validation Using Closures

Well there could be many simple approaches for that. But if you want to go with only this sort of design, then create a validator object inside the closure. Validate using the existing rules and take action based on validation failure/success.

Again, this is a bad practice, but if you want to just do it this way then you can do it like that.

Activity icon

Started a new Conversation Connecting Multiple Subdomains To Single Laravel Project

  • I want to connect 5 subdomains to same laravel instance.
  • Show landing page depending on the subdomain
  • Show same registration and login page and dashboard under construction page for all subdomains.

Will this work without any issues if I simply point my sub domains to same ip ?

Apr
24
2 weeks ago
Activity icon

Replied to What Is The Cleanest Way To Split Validation Logic Into Multiple Files

I don't understand why this is a "problem" anyway !

So what I want is, to separate the validation logic into multiple files, but keep the relevant parts together that belongs to one specific field. I hope you understand my problem.

That is exactly what custom rule is for.

Do you have some code that you want to use in multiple custom rules without duplicating ?

Can you give actual example from your project that's what exactly is bothering you @kisgaben ?