text: .
  D9705996 left a reply on ES6 Import In Vue Components Or Globally In App.js?
  D9705996 left a reply on Running Just VUEJS Application Alongwith Blade
  @DANYAL14 - If you need to serve blade templates you can still do so with Lumen as lumen has access to Illuminate/View which includes the blade compiler.
  D9705996 left a reply on Sublime Text 3 Package Control Server Offline
  @THAVARSHAN - No worries. Can you please mark discussion as solved (as it's a 3rd party issue) just incase anyone else has the same question
  D9705996 left a reply on Factory Faker Unique() Across All Tests?
  D9705996 left a reply on Connect No Sql Collections From MySQL To Laravel
  If you have an array you can wrap it in
  collect( ... ) to make a collection. If that's not what you want then I'm not sure. Maybe if you show some code it might help.
  D9705996 left a reply on Intersect Two Collections Or Some Other Way?
  To be honest I dont think your going to find a better way to do this. It seems pretty optimal to me.the only obvious refactor would be to return the data immediately rather than assign a temp variable
  return $category_cars->intersect($color_cars);
  D9705996 left a reply on Your Understanding Of What A MySQL Schema Is?
  @DAVESTEAD - To be honest I think we argue about the different vendor definitions of what is a schema, database, etc and how they relate to laravel forever and isn't something I want to spend any real effort on.
  You want to reduce any ambiguity when you ask for help here so all I can give you is what would help me if you start a discussion that I wanted to help with.
  For 99% of times avoid the ambiguous terms completely and explain your problem in plain English, what you have tried, any errors and the relevant code as this helps more than whether its a schema, database, etc.
  Laravel hides a lot of the implementation details behind interfaces/config so details like database shouldnt matter as migrations, eloquent, etc are agnostic to this detail.
  Just remember that everyone here is doing so as part of a community and does so of there own free will so the harder you make it for us to help with unnecessary issues the less likely you are to get that help in the first place.
  D9705996 left a reply on Running Just VUEJS Application Alongwith Blade
  D9705996 left a reply on Sublime Text 3 Package Control Server Offline
  Looks like any issue with package control as when you go to in a browser you get a server error
  Server Error Sorry, apparently we ran into an error we were not expecting!
  D9705996 left a reply on Running Just VUEJS Application Alongwith Blade
  Although they have been removed from the documentation it looks like you can still serve views with lumen as it includes
  "illuminate/view": "5.7.*", in composer.
  I dont use lumen so can't confirm but theory looks good. You might want to consider using vue router to create an SPA and you can just server your static page from your webserver and consume your lumen API. Have a look at
  D9705996 left a reply on Add Functions To Vue Object
  Have a look at the documentation on how to add to the vudu prototype
  D9705996 left a reply on How Can I Get Value If I Save A Field In Json Encode With Its Id?
  @VICKYAGGARWAL - If you are new to laravel you really should spend time learning the basics. There is a good introduction series here
  You also ask why you need a pivot table... this is databass design fundamentals rather than laravel but theres also a series here
  D9705996 left a reply on Testing Laravel Mailables And Passing Data
  AssertSent checks to see if the preceding code sent a mail that matches the class and any condition s in the call back. However you are trying to use this to send the mail which wont work as you need to do something like.
  Mail::to(User::first())->send(NewBroadcastMessage::class('test_subject',message')); Mail::assertSent(NewBroadcastMessage::class, function ($mail) { return $mail->subject === 'test_subject'; });
  Thd test isn't very useful but should help you get started
  D9705996 left a reply on How Should I Handle Workflow Of My App According Global Settings?
  @ILYAPETROV - No problem... years of practice!
  D9705996 left a reply on Path To Mailables Inside A Package
  D9705996 left a reply on How Can I Get Value If I Save A Field In Json Encode With Its Id?
  Storing the related ids in a json encoded column isn't the right way to go IMO.
  You need to have a many-to-many relationship between Classes and Users (assuming a User can take many classes)
  You therefore need 3 tables, your existing users and classes and a pivot table for class_user that has a column for
  user_id and
  class_id
  Schema::table('class_user', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('user_id'); $table->unsignedInteger('class_id'); $table->unique(['user_id','class_id']); // prevent the user appearing in the same class twice $table->foreign('user_id')->references('id')->on('users'); $table->foreign('class_id')->references('id')->on('classes'); });
  Then in your User model you need to setup the relationship
  public function classes() { return $this->belongsToMany(Class::class); }
  In your class model
  public function users() { return $this->belongsToMany(User::class); }
  You can then get the user details for a specific class with
  foreach(Class::find(1)->users as $user) { dump($user->mobile); }
  or if you want all the classes for a user
  foreach(User::find(1)->classes as $class) { dump($class->name); }
  The above is assuming you have followed laravel naming conventions but if not just change to fit your specifics. You will probably have to tinker a bit to get up and running but should give you the general idea.
  D9705996 left a reply on Path To Mailables Inside A Package
  Can you share how you have configured the autoloader sections of
  composer.json for your local package?
  D9705996 left a reply on Carbon - Get Date Depending On Now() Value
  D9705996 left a reply on ES6 Import In Vue Components Or Globally In App.js?
  Personally I prefer to only import and register my components in the components that require them rather than globally. I find this helps me encapsulate my components so I can easily reuse them in other projects e.g. A task-list item component is only going to be used within my task-list component
  This also helps when you review code as you can see exactly where your components are coming from rather than having to keep going back to app.js.
  If you wanted to automatically import all of your components globally from a specific directoy you could look at this gist from Jonathan Reinink and add to your app.js
  const files = require.context('./', true, /\.vue$/i) files.keys().map(key => { const name = _.last(key.split('/')).split('.')[0] return Vue.component(name, files(key)) })
  D9705996 left a reply on Convenient And DRY Way To Save Morphable To Relationship
  @SERGEY_BRUHIN - There is an interesting article on structuring your laravel application by domain.
  D9705996 left a reply on How Should I Handle Workflow Of My App According Global Settings?
  @ILYAPETROV - To avoid having to have an if statement for each key in your store, if you match the setting name to the relationship you could loop around them (I don't know how your settings helper work so below is using the native package methods.
  $relations = ['responsible_person', 'staff']; $valuestore->put('activities', 'value'); $valuestore->put('working_places', 'value'); foreach ($valuestore->all() as $setting) { $relations[] = $setting; } $divisions = Division::with($relations)->get();
  D9705996 left a reply on Your Understanding Of What A MySQL Schema Is?
  @DAVESTEAD - > MySQL database - server/host.
  MySQL schema - table-containing "database"
  The database is not the server/host. A database server is an application running on a server which can have many databases.
  The schema is not a table containing the database. The schema defines the structure of each table within a specific database (for example you may have a different user table schema for different databases).
  I would advise to avoid any ambiguity when posting within Laracasts to stick to Laravel specific terminology e.g. rather than saying schema use migrations and show the content of the relevant migration(s), That way 99% of people will understand exactly what you mean rather than having to interpret your own domain specific language
  D9705996 left a reply on How Should I Handle Workflow Of My App According Global Settings?
  @ILYAPETROV - Could you share the link to the spatie package you are using.
  D9705996 left a reply on Is Build A Separate Real Time Server Good Idea?
  If your struggling with socket.io and node websockets havd z look at
  A php socket server that is pusher api compatible and has great docx to get you up and running really easily. Much easier than trying to split out your so lets go a separate server
  D9705996 left a reply on How Should I Handle Workflow Of My App According Global Settings?
  Have a look at the Querying Relationship Existence section of the documentation
  The
  has,
  whereHas, etc methods sound like what you need
  D9705996 left a reply on Convenient And DRY Way To Save Morphable To Relationship
  @SERGEY_BRUHIN - If you are going to reuse your classes across multiple projects you might want to consider making a package. Not the easiest thing in he world but I found this series really useful
  D9705996 left a reply on Autoload_classmap.php And Autoload_static.php In Vendor/composer
  I believe so unless you use
  --no-autoloader
  D9705996 left a reply on How To Solve This Error: `app.js:38038 POST 403 (Forbidden)`
  Have a read of the documentation on how to authorise access to private channels. You need to return a boolean from
  Broadcast::Channel method
  As test if you change to just return true, does it work.
  Broadcast::channel('notifications', function ($user) { return true; }); If so then you need to work out your authorisation logic.
  D9705996 left a reply on Queued Jobs And Withoutoverlapping
  D9705996 left a reply on Using Phpunit/ Why Phpunit Removes All Data In My Database
  @ABDULJAKUL-SALSALANI - The
  RefreshDatabase Trait will reset the database after every test. If you have configured a InMemory Database this runs
  artican migrate which you can see in the source
  It would be worth making sure that your tests are picking up the correct settings from
  phpunit.xml by creating a new temporary test and dumping the configuration settings to make sure they match
  dump(env("DB_CONNECTION")); dump(env("DB_DATABASE"));
  D9705996 left a reply on Using Phpunit/ Why Phpunit Removes All Data In My Database
  If you have added this to your
  phpunit.xml then phpunit will use an in-memory database for your tests.
  <env name="DB_CONNECTION" value="sqlite"/> <env name="DB_DATABASE" value=":memory:"/>
  Is you problem that when you run your tests you data in your non-test database is removed as this shouldn't happen with the setup above unless you are overriding anything within Laravel e.g. separate database connections on you eloquent models.
  If this is still a problem I would find a test that is causing your data to be removed and work through exactly what that test is doing and the application code it is calling to figure out a bit more detail about why your data is being removed.
  D9705996 left a reply on Laravel Working With Money
  First thing, dont work with decimals when dealing with money e.g. instead of $12.25 store as 1225 cents due to rounding issues
  For the maths I would do
  $service = 1225; $coupon = 25; $net = $service * ( 100 - $coupon) / 100;
  Gives 918.75 cents or round up to $9.19.
  D9705996 left a reply on Problem With Laravel Telescope.
  In the phpunit.xml add the following with your other env variables.
  <env name="TELESCOPE_ENABLE" value="false"/>
  This will disabld telescope shen testing see
  D9705996 left a reply on View Taking Way Too Long To Render As Text/xml
  @FLYINGGHOTI - Awesome. Glad you got your issue fixed. If you could please mark the discussion as solved that would be great.
  D9705996 left a reply on Overwrite Passport Keys Creation Location?
  Why do you want to do this?
  I had a look at the source code and the Passport class has a public
  keyPath property that is used to determine where to store the keys. However I dont see how you would go setting the path
  There is a way go load thd keys from another location so might need to manually move the keys
  Passport::loadKeysFrom('/var/http/path/to/files');
  To be honest I would leave as is unless you have a deal breaker reason to change
  D9705996 left a reply on Bug Fix/Extend Laravel 5.3 "custom" Project
  @OVERTHANE - I had a look at your github repo and I have the following starters advice
  For each of your issue create a test to prove that you can reproduce the issue. Then fix it and close the issue I know you have been asked not to but you dont want to accidentally break it again later you can then be sure forever that this bit of your codd work
  Havd a look at about creating branches/ merge requests. Really useful for tracking the changes you make for each issue in isolation and let's you review in the future, it's also how anyone else can contribute to your project (e.g. if I wanted to fix an issue for you I could create a copy of your repo, make the changes and then create a merge request that you could approve, reject, discuss)
  Your routes dont follow restful convention e.g. using post routes to delete things. Not an issue as such but sticking to a convention helps readability
  Your models are using a weird hybrid of raw SQL and query builder for no obvious reason. A lot of the code could be simplified with eloquent -
  Your controllers have validation logic all over the place and is pretty bespoke. Look at form requests as they can do z lot of the heavy lifting for you in a centralised place.
  Authentication is being performed in your controller routes with repeated code. You can use the auth middleware to remove this and use policies for your authorization.
  Ids are being passed as request parameters. Look at route model binding to automatically get model by its id -
  I know you aren't really in a position to refactorwrite tests so you might have to keep going with what you've got but I would try chipping away at some of the code if you can as it will get easier and the above are the quickest wins IMO but I feel for you as you have inherited an absolute beast
  Good luck
  D9705996 left a reply on Bug Fix/Extend Laravel 5.3 "custom" Project
  @OVERTHANE - > Unfortunately my employer, upon knowing that I was performing tests careful and properly, ordered me to skip testing suites and attempt to apply the fixes directly to the code.
  WOW. I know from previous experience the world of pain you will end up in without a test suite. A small seemingly innocuous change breaks core functionality, you have a fear of change as you dont have confidence to make changes xo everything takes many times more, debugging problems is a nightmare as the breaking change might have been months ago.
  For your own sanity if nothing else I would continue testing as much as you can without compromising your employers delivery dates.
  It's easier to ask for forgiveness than permission!!!
  If you want a good reference book I highly recommend refactoring by Martin Fowler. I have 1st edition which is java orientated bug still relevant but link is for the new one which is javascript
  D9705996 left a reply on Existing Dynamic Form Builder Library?
  @NULLREFERENCE - No problem - If the links helps solve your issue can you please mark the discussion as resolved.
  D9705996 left a reply on Laravel HTTP Tests
  @DANYAL14 - Ok I have had a chance to test my last response and it doesn't work. Looking at this seems to suggest that Laravel intercepts the HTTP requests and handles them internally, which I suppose makes sense as HTTP tests work without needing to have a web server running.
  If you still need to query an external site you can do this but you wont be able to use the in-built framework helpers and assertions. You will need to install an HTTP client like Guzzle and then you can write your tests to actually hit the API as per the below test class that tests a response from google contains the text Google.
  <?php namespace Tests\Feature; use Tests\TestCase; use GuzzleHttp\Client; use Symfony\Component\HttpFoundation\Response; class ExternalUrlTest extends TestCase { protected $client; public function setUp() { $this->client = new Client(); parent::setUp(); } public function testExternalUrl() { $response = $this->client->get(''); $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); $this->assertContains('Google', $response->getBody()->getContents()); } }
  If I run these tests I get
  PHPUnit 7.5.1 by Sebastian Bergmann and contributors. ==> Tests\Feature\ExternalTest ✓ Time: 1.32 seconds, Memory: 20.00MB
  However if I change the
  assertContains to somethign that doesn;t exist the error message isn't very helpful
  PHPUnit 7.5.1 by Sebastian Bergmann and contributors. ==> Tests\Feature\ExternalTest ✖ Time: 1.58 seconds, Memory: 20.00MB ✖ There was 1 failure: 1) Tests\Feature\ExternalTest::testExternalUrl sprintf(): Too few arguments
  To be honest I would look at testing your API separately as doing so through this method is goign to be a PITA
  D9705996 left a reply on Existing Dynamic Form Builder Library?
  I've not seen any specific packages but you might want go look at this for inspiration
  D9705996 left a reply on Queued Jobs And Withoutoverlapping
  Have a look at setting expirations on your jobs
  You should just need to add this function to your job. Amend the contents with you specific needs for when jobs should timeout.
  public function retryUntil() { return now()->addSeconds(5); }
  D9705996 left a reply on Laravel HTTP Tests
  @DANYAL14 - Looking through the source code of the
  MakesHttpRequest trait I can see that when you use the get, post, etc they defer to a call method that uses the following to create the url to query
  protected function prepareUrlForRequest($uri) { if (Str::startsWith($uri, '/')) { $uri = substr($uri, 1); } if (! Str::startsWith($uri, 'http')) { $uri = config('app.url').'/'.$uri; } return trim($uri, '/'); }
  So it looks as if you actually don't need to do anything special other than us the full uri with the protocol prefix e.g. your original should work
  $this->get('')->assertStatus(200);
  Iv not shat error are you getting?
  D9705996 left a reply on Suggest Me A License For This CMS I Built Over Last 2 Years That I Plan To Open Source
  @NIKOCRAFT - My understanding of Apache is that any change from the licenced file needs documented).
  For gplv3 and mpl seem pretty similar (from my layman's perspective). You really need to review each licence and translate to what you are happy for you software to be used.
  Again as stated by myself, martinbean and danieloplata, having a licence file wont stop other developers cloning your repository (I'm assuming your going to make available via github or similar) and using it however they want from a technical perspective. What the licence gives you is recourse if someone does something that breaches the provided licence but is not an easy thing to pursue, either from a time or financial perspective.
  I would think out some scenarios, both good and bad, over how users/developers can use your software once you open source it and how you would handle them. E.g. someone clones you repo, changes some basic css and repackaged as their own. Is this ok, if not what you going to do? Sue them? What If someone finds one of your vue components useful and copies it as is into their own separate project. Is this ok.
  You have already spent the 2 years developing the product you can't get the time/resource back so I would focus on making your CMS the best CMS you can, adding new features, fixing bugs and generally fostering a community around the product, which shouldnt be an issue given your feedback to date rather than the little details of which licence to use.
  D9705996 left a reply on Suggest Me A License For This CMS I Built Over Last 2 Years That I Plan To Open Source
  Looking at this post it does seem like the Apache license is a good middle ground between MIT and GPL (and gives a good comparison with MIT/GPL).
  If you do choose the Apache Licence this requirement might be off putting for developers
  A limitation of this license for developers is that it requires you to add prominent notifications of any changes you make to a file.
  D9705996 left a reply on Suggest Me A License For This CMS I Built Over Last 2 Years That I Plan To Open Source
  You might find this site useful to get an easy to follow traffic light system of what you can cannot do under the terms of each licence
  If you look at the full list of common licences you will see that at a high level they are all pretty similar so you are probably going to need to dig into each one to find something that fits your specific use case.
  Just remember that once you open source your project (and bravo for giving back to the community) the licence you choose does not prevent anyone from using your project in-appropriately, it just means you may be able to to action to stop them if they do.
  If this is a real concern to you I would strongly urge taking expert advice. There are numerous companies available but won't be free.
  D9705996 left a reply on Load Views From Memory
  When you call a view from your application Laravel will compile the blade template into PHP and cache the contents in
  storage/framework/views so that subsequent requests for the same content do not need to recompile the template.
  I am not aware of a way within the framework to configure the view cache to use an alternate in memory cache like Redis.
  I would be surprised if the disk I/O caused by reading views from disk would cause a huge amount of Disk I/O but there are tools like iostat and pidstat that you can use to determine if this is a bottleneck for you.
  One possible solution would be to mount the view cache folder as a separate tmpfs mountpoint
  mount -t tmpfs -o size=128M tmpfs /your/path/storage/framework/views
  This will temporarily mount the folder in memory (with a max size of 128Mb which you can tweak). if you want to make this permanent you need to add to
  /etc/fstab as per link above.
  Feel free to try but to be honest IMO you are going to get limited benefits.
  D9705996 left a reply on New Posts Are Always 6 Hours Ago.
  This looks to be an issue with timezones as I am seeing new posts as 5 hours out. I tried changing me time zone to Eastern US & Canada and can see your post as 5 minutes ago.
  I tried using some chrome extension to spoof the timezone but they dont work (I suspect as the times shown are relateive).
  Might be worth raising with Jeffrey via the Support link at the bottom of the page but I vaguely recall him tweeting about trying to fix this last year so he is probably aware.
  D9705996 left a reply on Building An App To Use To Record Maintenance Reports
  You might want to take a look at this repo for inspiration
  For your database schema you would want to have a form table which has a one to many relationship to a form element table (choose whatever table names make sense). This will allow you to build up your forms dynamically without separate tables/models per form.
  One hint would be to store an integer order column on the form element table so you know which order to display the form.
  D9705996 left a reply on Your Understanding Of What A MySQL Schema Is?
  @DAVESTEAD - As you can see from the comments, there really isn't a 100% definition of the tdchnical differences between a database and a schema, especially as different RDMS vendors give then different meanings.
  If you are looking for a laracasts defintion to help explain your problems in a discussion you won't go far wrong with
  Database is the configured connection from
  config/database.php and schema is the content of you migrations that are used to build the tables, indexes, foreign keys, etc with the configured database. If you are not using migrations then it would be the output of
  DESCRIBE <%YOUR_TABLE%> from you mysql command line or equivalent Sequel pro (not on Mac so not sure what this is)
  D9705996 left a reply on Unit Test For Morph Many To Many
  For a unit test you could still use
  assertInstanceOf e.g.
  $desk = new Desk(); $this->assertInstanceOf( 'Illuminate\Database\Eloquent\Relations\MorphMany', $desk->categoryable() );
  Rinse and repeat for your other relationships.